Do I measure right and performance of TRNG random generator is about 100 bytes per seconds ?
Bus clock - 60 Mhz.
The True Random Number Generator is a very high quality entropy source but takes a long time to complete its operation. I think that idea is to use it to seed a Pseudo Random Number Generator for subsequent use (which will be implemented in SW) and not to use it to generate each random number.
Hi Mark !
Yes, it is typical technique to use it, but it would be nice to know if my digits are correct for be sure if everything configured properly.
As you will know, the TRNG generates 16 long words of entropy each time it is used ( (64 bytes).
When I test this it takes typically between 590ms and 650ms, which would give approx. 10ms per byte, which corresponds to your 100bytes/s (or 10ms per byte).
I use this configuration on the K82F:
POWER_UP_ATOMIC(3, TRNG0); // power up TRNG0 TRNG0_MCTL = (TRNG_MCTL_PRGM | TRNG_MCTL_RST_DEF); // ensure we are in programming mode with defaults set TRNG0_FRQMIN = 0; TRNG0_FRQMAX = 0x03ffff; // the default maximum value is too low and causes a frequency count failure if not increased TRNG0_SDCTL = ((1600 << 16) | (2500)); // entropy delay and sample size reduced to half of default TRNG0_MCTL = (TRNG_MCTL_PRGM_RUN | TRNG_MCTL_SAMP_MODE_VON_NEUMANN | TRNG_MCTL_TRNG_ACC | TRNG_MCTL_OSC_DIV_1); // set to run mode with TRNG access
Thank you !
Pseudo random generator from standart C library rand() utilize some global buffers what cause problem to run code with User privileges.
Better to allocate this buffer from RTOS Task stack and use after that in context of this task.
Do you know any public implementation of pseudo random generator what available with source code ?
Try mbedTLS as reference.
They use a 16 byte long counter which is seeded from an entropy source [which can bet quite complicated if there is no good source] (TRNG would be used for this since it is an excellent source).It then performs an AES_ECB (AES256) encryption to generate 16 bytes of output and increments the 16 byte before each use. The 16 bytes of output are used as random numbers.
It sometimes re-seeds itself (based on elapsed time or a number of utilisations).
Since the K80 can do AES256 in HW this algorithm looks suitable.
Retrieving data ...