Skip to content

Commit 019a420

Browse files
authored
Merge pull request #9568 from kareem-wolfssl/zd20947
Add a flag which allows requesting exactly SEED_SZ and using the full seed to instantiate the DRBG during RNG init.
2 parents 09ce46e + 8de470b commit 019a420

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

.wolfssl_known_macro_extras

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,7 @@ WOLFSSL_RENESAS_RZN2L
859859
WOLFSSL_RENESAS_TLS
860860
WOLFSSL_RENESAS_TSIP_IAREWRX
861861
WOLFSSL_REQUIRE_TCA
862+
WOLFSSL_RNG_USE_FULL_SEED
862863
WOLFSSL_RSA_CHECK_D_ON_DECRYPT
863864
WOLFSSL_RSA_DECRYPT_TO_0_LEN
864865
WOLFSSL_RW_THREADED

wolfcrypt/src/random.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,11 +739,15 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
739739
{
740740
int ret = 0;
741741
#ifdef HAVE_HASHDRBG
742+
#if !defined(HAVE_FIPS) && defined(WOLFSSL_RNG_USE_FULL_SEED)
743+
word32 seedSz = SEED_SZ;
744+
#else
742745
word32 seedSz = SEED_SZ + SEED_BLOCK_SZ;
743746
WC_DECLARE_VAR(seed, byte, MAX_SEED_SZ, rng->heap);
744747
#ifdef WOLFSSL_SMALL_STACK_CACHE
745748
int drbg_scratch_instantiated = 0;
746749
#endif
750+
#endif
747751
#endif
748752

749753
(void)nonce;
@@ -945,7 +949,11 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
945949
#endif
946950
if (ret == DRBG_SUCCESS)
947951
ret = Hash_DRBG_Instantiate((DRBG_internal *)rng->drbg,
952+
#if defined(HAVE_FIPS) || !defined(WOLFSSL_RNG_USE_FULL_SEED)
948953
seed + SEED_BLOCK_SZ, seedSz - SEED_BLOCK_SZ,
954+
#else
955+
seed, seedSz,
956+
#endif
949957
nonce, nonceSz, rng->heap, devId);
950958
} /* ret == 0 */
951959

0 commit comments

Comments
 (0)