Skip to content

Commit fe105d4

Browse files
Add a flag which allows requesting exactly SEED_SZ and using the full seed to instantiate the DRBG during RNG init.
This flag can not be used with FIPS.
1 parent d5723d0 commit fe105d4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

wolfcrypt/src/random.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,12 +811,16 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
811811
{
812812
int ret = 0;
813813
#ifdef HAVE_HASHDRBG
814+
#if !defined(HAVE_FIPS) && defined(WOLFSSL_RNG_USE_FULL_SEED)
815+
word32 seedSz = SEED_SZ;
816+
#else
814817
word32 seedSz = SEED_SZ + SEED_BLOCK_SZ;
815818
WC_DECLARE_VAR(seed, byte, MAX_SEED_SZ, rng->heap);
816819
int drbg_instantiated = 0;
817820
#ifdef WOLFSSL_SMALL_STACK_CACHE
818821
int drbg_scratch_instantiated = 0;
819822
#endif
823+
#endif
820824
#endif
821825

822826
(void)nonce;
@@ -1018,7 +1022,11 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
10181022
#endif
10191023
if (ret == DRBG_SUCCESS)
10201024
ret = Hash_DRBG_Instantiate((DRBG_internal *)rng->drbg,
1025+
#if defined(HAVE_FIPS) || !defined(WOLFSSL_RNG_USE_FULL_SEED)
10211026
seed + SEED_BLOCK_SZ, seedSz - SEED_BLOCK_SZ,
1027+
#else
1028+
seed, seedSz,
1029+
#endif
10221030
nonce, nonceSz, rng->heap, devId);
10231031
if (ret == 0)
10241032
drbg_instantiated = 1;

0 commit comments

Comments
 (0)