Skip to content

Commit 5c020c6

Browse files
committed
Increase RNG_SECURITY_STRENGTH for FIPS
1 parent 6bde6af commit 5c020c6

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

wolfcrypt/src/random.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,29 @@ int wc_RNG_GenerateByte(WC_RNG* rng, byte* b)
246246
#define RESEED_INTERVAL WC_RESEED_INTERVAL
247247

248248

249+
/* For FIPS builds, the user should not be adjusting the values. */
250+
#if defined(HAVE_FIPS) && \
251+
defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
252+
#if defined(RNG_SECURITY_STRENGTH) \
253+
|| defined(ENTROPY_SCALE_FACTOR) \
254+
|| defined(SEED_BLOCK_SZ)
255+
256+
#error "Do not change the RNG parameters for FIPS builds."
257+
#endif
258+
#endif
249259
/* The security strength for the RNG is the target number of bits of
250260
* entropy you are looking for in a seed. */
251261
#ifndef RNG_SECURITY_STRENGTH
252-
/* SHA-256 requires a minimum of 256-bits of entropy. */
253-
#define RNG_SECURITY_STRENGTH (256)
262+
#if defined(HAVE_FIPS) && \
263+
defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
264+
/* SHA-256 requires a minimum of 256-bits of entropy. The goal
265+
* of 1024 will provide 4 times that. */
266+
#define RNG_SECURITY_STRENGTH (1024)
267+
#else
268+
/* If not using FIPS or using old FIPS, set the number down a bit.
269+
* More is better, but more is also slower. */
270+
#define RNG_SECURITY_STRENGTH (256)
271+
#endif
254272
#endif
255273

256274
#ifndef ENTROPY_SCALE_FACTOR

0 commit comments

Comments
 (0)