Adding an Entropy Source to a Random Number Generator in the Right Way

I am tasked with creating a random number generator for the embedded system. Currently, entropy sources using AMP are keyboard input and other variables such as signal strength and battery power.

I used PolarSSL , which has an awesome portable SSL library for embedded systems. However, with the exception of the documentation, there is very little about this on the Internet!

I think that I am not adding entropy sources to my entropy drive in the right way. This causes problems with the CTR-DRBG module , which returns an error in Init. ( Initial error -52) Since the RNG is for the embedded system, there is no initial entropy from the system, therefore, an error. ( LINK ) I have no errors when I test the same RNG on another standard OS like Windows. Here are some of the codes related to it.

    // Global Variables.
ctr_drbg_context ctx;
entropy_context etx;

// Inside Main
entropy_init( &etx );
// Add entropy sources

// Initializing CTR_DRBG
printf("Before ctrdrbg: %d", err);
err = ctr_drbg_init( &ctx, entropy_func, &etx,  (const unsigned char *) "RANDOM_GEN", 10 );
if( err != 0 )
{
   printf("Failed in ctr_drbg init!: %d", err);
} 

Output: Error on Ctr_drbg init: -52

I tried this for about a week, not having time. Almost give up !! Does anyone out there want to help?

+4
source share
1 answer

First the actual answer:

, Windows, , , , "" .

, CTR-DRBG, 48 ( ).

, 48 , 256 (ENTROPY_MAX_LOOP) . , all ! , , , ( POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED).

, "" ( 0, ).

:

. ( ( 100 ) . , . ... "kickstart" , RNG , - , , . source ir ctr_drbg. , ( 0) -.

: , !

+3

All Articles