Skip to content

Commit af84f0f

Browse files
committed
SHA512-DRBG default ENTROPY_SCALE_FACTOR on par with SHA256-DRBG
1 parent 7593377 commit af84f0f

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

wolfssl/wolfcrypt/random.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,16 @@ struct OS_Seed {
262262
* vectors (seedlen = 440 bits for SHA-256, 888 bits for SHA-512 per
263263
* SP 800-90A Table 2).
264264
*
265-
* When the SHA-512 DRBG is enabled we also enforce a floor of
266-
* DRBG_SHA512_SEED_LEN (111 bytes / 888 bits) so the raw seed is never
267-
* shorter than the internal state, even with ENTROPY_SCALE_FACTOR = 1. */
265+
* In FIPS mode (ENTROPY_SCALE_FACTOR >= 4) the base is already >= 128 bytes
266+
* which exceeds DRBG_SHA512_SEED_LEN (111), so both DRBGs use the same
267+
* seed size. In non-FIPS mode we use the base for both DRBGs so that
268+
* enabling SHA-512 DRBG does not inflate the per-init entropy cost.
269+
* SP 800-90A requires only security_strength bits (256 = 32 bytes) of
270+
* entropy regardless of hash size; hash_df compresses the seed material
271+
* into the internal V/C state vectors. */
268272
#define WC_DRBG_SEED_SZ_BASE (RNG_SECURITY_STRENGTH*ENTROPY_SCALE_FACTOR/8)
269273

270-
#if defined(WOLFSSL_DRBG_SHA512) && \
274+
#if defined(HAVE_FIPS) && defined(WOLFSSL_DRBG_SHA512) && \
271275
(WC_DRBG_SEED_SZ_BASE < DRBG_SHA512_SEED_LEN)
272276
#define WC_DRBG_SEED_SZ DRBG_SHA512_SEED_LEN
273277
#else

0 commit comments

Comments
 (0)