CTR_DRBG: explicitly set entropy_nonce_len=0 when desired

No behavior change. Prepare for a future version that will set the
entropy nonce length to a nonzero value by default.
This commit is contained in:
Gilles Peskine 2019-10-22 20:33:56 +02:00
parent c949de06ec
commit 0ed378aa02
2 changed files with 3 additions and 0 deletions

View file

@ -732,6 +732,7 @@ int mbedtls_ctr_drbg_self_test( int verbose )
test_offset = 0; test_offset = 0;
mbedtls_ctr_drbg_set_entropy_len( &ctx, 32 ); mbedtls_ctr_drbg_set_entropy_len( &ctx, 32 );
mbedtls_ctr_drbg_set_nonce_len( &ctx, 0 );
CHK( mbedtls_ctr_drbg_seed( &ctx, CHK( mbedtls_ctr_drbg_seed( &ctx,
ctr_drbg_self_test_entropy, ctr_drbg_self_test_entropy,
(void *) entropy_source_pr, (void *) entropy_source_pr,
@ -756,6 +757,7 @@ int mbedtls_ctr_drbg_self_test( int verbose )
test_offset = 0; test_offset = 0;
mbedtls_ctr_drbg_set_entropy_len( &ctx, 32 ); mbedtls_ctr_drbg_set_entropy_len( &ctx, 32 );
mbedtls_ctr_drbg_set_nonce_len( &ctx, 0 );
CHK( mbedtls_ctr_drbg_seed( &ctx, CHK( mbedtls_ctr_drbg_seed( &ctx,
ctr_drbg_self_test_entropy, ctr_drbg_self_test_entropy,
(void *) entropy_source_nopr, (void *) entropy_source_nopr,

View file

@ -45,6 +45,7 @@ static void ctr_drbg_validate_internal( int reseed_mode, data_t * nonce,
/* CTR_DRBG_Instantiate(entropy[:entropy->len], nonce, perso, <ignored>) /* CTR_DRBG_Instantiate(entropy[:entropy->len], nonce, perso, <ignored>)
* where nonce||perso = nonce[nonce->len] */ * where nonce||perso = nonce[nonce->len] */
mbedtls_ctr_drbg_set_entropy_len( &ctx, entropy_chunk_len ); mbedtls_ctr_drbg_set_entropy_len( &ctx, entropy_chunk_len );
mbedtls_ctr_drbg_set_nonce_len( &ctx, 0 );
TEST_ASSERT( mbedtls_ctr_drbg_seed( TEST_ASSERT( mbedtls_ctr_drbg_seed(
&ctx, &ctx,
mbedtls_test_entropy_func, entropy->x, mbedtls_test_entropy_func, entropy->x,