Skip to content

Commit ddd1464

Browse files
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.
1 parent 0301940 commit ddd1464

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

library/ctr_drbg.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ int mbedtls_ctr_drbg_self_test( int verbose )
732732

733733
test_offset = 0;
734734
mbedtls_ctr_drbg_set_entropy_len( &ctx, 32 );
735+
mbedtls_ctr_drbg_set_nonce_len( &ctx, 0 );
735736
CHK( mbedtls_ctr_drbg_seed( &ctx,
736737
ctr_drbg_self_test_entropy,
737738
(void *) entropy_source_pr,
@@ -756,6 +757,7 @@ int mbedtls_ctr_drbg_self_test( int verbose )
756757

757758
test_offset = 0;
758759
mbedtls_ctr_drbg_set_entropy_len( &ctx, 32 );
760+
mbedtls_ctr_drbg_set_nonce_len( &ctx, 0 );
759761
CHK( mbedtls_ctr_drbg_seed( &ctx,
760762
ctr_drbg_self_test_entropy,
761763
(void *) entropy_source_nopr,

tests/suites/test_suite_ctr_drbg.function

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static void ctr_drbg_validate_internal( int reseed_mode, data_t * nonce,
4545
/* CTR_DRBG_Instantiate(entropy[:entropy->len], nonce, perso, <ignored>)
4646
* where nonce||perso = nonce[nonce->len] */
4747
mbedtls_ctr_drbg_set_entropy_len( &ctx, entropy_chunk_len );
48+
mbedtls_ctr_drbg_set_nonce_len( &ctx, 0 );
4849
TEST_ASSERT( mbedtls_ctr_drbg_seed(
4950
&ctx,
5051
mbedtls_test_entropy_func, entropy->x,

0 commit comments

Comments
 (0)