Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years ago.
It returns MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED when executing mbedtls_ctr_drbg_seed().
Dear Sirs:
I want to try the RSA functions and my code is as follows:
mbedtls_rsa_context rsa; mbedtls_entropy_context entropy; mbedtls_ctr_drbg_context ctr_drbg; mbedtls_mpi N, P, Q, D, E, DP, DQ, QP; FILE *fpub = NULL; FILE *fpriv = NULL; const char *pers = "rsa_genkey"; mbedtls_aes_context aes; mbedtls_dhm_context dhm;
int ret = 1; int exit_code = MBEDTLS_EXIT_FAILURE;
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.)
Thanks!