random: simplify fips mode
PATCH 1/1 random: simplify fips mode
Rather than dynamically allocate 10 bytes, move it to static allocation. This saves space and avoids the need for error checking.
Signed-off-by Matt Mackall <[email protected]>
drivers/char/random.c +3 -7
@@ -257,6 +257,7 @@#define INPUT_POOL_WORDS 128#define OUTPUT_POOL_WORDS 32#define SEC_XFER_SIZE 512 +#define EXTRACT_SIZE 10/* * The minimum number of bits of entropy before we wake up a read on
@@ -414,7 +415,7 @@unsigned add_ptr;int entropy_count;int input_rotate; -__u8 *last_data; +__u8 last_data[EXTRACT_SIZE ]; };static __u32 input_pool_data[INPUT_POOL_WORDS ];
@@ -714,8 +715,6 @@ }#endif -#define EXTRACT_SIZE 10 -/********************************************************************* * * Entropy extraction routines
@@ -862,7 +861,7 @@while (nbytes) {extract_buf (r, tmp); -if (r->last_data) { +if (fips_enabled) {spin_lock_irqsave (&r->lock, flags);if (!memcmp (tmp, r->last_data,EXTRACT_SIZE ))panic ("Hardware RNG duplicated output!\n" );
@@ -951,9 +950,6 @@ now =ktime_get_real ();mix_pool_bytes (r, &now,sizeof (now));mix_pool_bytes (r,utsname (),sizeof (*(utsname ()))); -/* Enable continuous test in fips mode */ -if (fips_enabled) - r->last_data =kmalloc (EXTRACT_SIZE ,GFP_KERNEL ); }static int rand_initialize (void )
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Quoted 4 lines · Matt Mackall
Rather than dynamically allocate 10 bytes, move it to static allocation. This saves space and avoids the need for error checking.
Signed-off-by Matt Mackall <[email protected]>
Patch applied. Thanks a lot!
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt