Skip to content

Commit 1e08861

Browse files
committed
Adjust ENTROPY_SCALE_FACTOR for FIPS
1 parent 5c020c6 commit 1e08861

1 file changed

Lines changed: 8 additions & 21 deletions

File tree

wolfcrypt/src/random.c

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -246,37 +246,24 @@ 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
259249
/* The security strength for the RNG is the target number of bits of
260250
* entropy you are looking for in a seed. */
261251
#ifndef RNG_SECURITY_STRENGTH
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
252+
/* SHA-256 requires a minimum of 256-bits of entropy. */
253+
#define RNG_SECURITY_STRENGTH (256)
272254
#endif
273255

274256
#ifndef ENTROPY_SCALE_FACTOR
275257
/* The entropy scale factor should be the whole number inverse of the
276258
* minimum bits of entropy per bit of NDRNG output. */
277259
#if defined(HAVE_ENTROPY_MEMUSE)
278260
/* Full strength, conditioned entropy is requested of MemUse Entropy. */
279-
#define ENTROPY_SCALE_FACTOR (1)
261+
#if defined(HAVE_FIPS) && defined(HAVE_FIPS_VERSION) && \
262+
(HAVE_FIPS_VERSION >= 2)
263+
#define ENTROPY_SCALE_FACTOR (4)
264+
#else
265+
#define ENTROPY_SCALE_FACTOR (1)
266+
#endif
280267
#elif defined(HAVE_AMD_RDSEED)
281268
/* This will yield a SEED_SZ of 16kb. Since nonceSz will be 0,
282269
* we'll add an additional 8kb on top. */

0 commit comments

Comments
 (0)