4 years, 5 months ago.

Executing mbedtls_ctr_drbg_seed returns fail.

I want to try the RSA functions and my code is as follows:

mbedtls_ctr_drbg_init( &ctr_drbg );

mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, MBEDTLS_MD_SHA256 );

mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &DP ); mbedtls_mpi_init( &DQ ); mbedtls_mpi_init( &QP );

printf( "\n . Seeding the random number generator..." );

fflush( stdout );

mbedtls_entropy_init( &entropy );

if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, (const unsigned char *) pers, strlen( pers ) ) ) != 0 ) { printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret ); goto exit; }

After executing mbedtls_ctr_drbg_seed(), it returns MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED. I still check the entropy information after executing mbedtls_entropy_init(). The resource of entropy is all null.

Is there anything I should concern? (ex: open the definition of mbedTLS_config.h or thers.)

Be the first to answer this question.