diff options
| author | Matt Mackall <mpm@selenic.com> | 2010-05-20 05:55:01 -0400 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2010-05-20 05:55:01 -0400 |
| commit | e954bc91bdd4bb08b8325478c5004b24a23a3522 (patch) | |
| tree | aa5affa35b799f8a71a6b6740c9828832e05085c | |
| parent | 921bae54693f26d01fb8e10ee6968b5cd8184551 (diff) | |
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 <mpm@selenic.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
| -rw-r--r-- | drivers/char/random.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index 2fd3d39995d5..8d85587b6d4f 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
| @@ -257,6 +257,7 @@ | |||
| 257 | #define INPUT_POOL_WORDS 128 | 257 | #define INPUT_POOL_WORDS 128 |
| 258 | #define OUTPUT_POOL_WORDS 32 | 258 | #define OUTPUT_POOL_WORDS 32 |
| 259 | #define SEC_XFER_SIZE 512 | 259 | #define SEC_XFER_SIZE 512 |
| 260 | #define EXTRACT_SIZE 10 | ||
| 260 | 261 | ||
| 261 | /* | 262 | /* |
| 262 | * The minimum number of bits of entropy before we wake up a read on | 263 | * The minimum number of bits of entropy before we wake up a read on |
| @@ -414,7 +415,7 @@ struct entropy_store { | |||
| 414 | unsigned add_ptr; | 415 | unsigned add_ptr; |
| 415 | int entropy_count; | 416 | int entropy_count; |
| 416 | int input_rotate; | 417 | int input_rotate; |
| 417 | __u8 *last_data; | 418 | __u8 last_data[EXTRACT_SIZE]; |
| 418 | }; | 419 | }; |
| 419 | 420 | ||
| 420 | static __u32 input_pool_data[INPUT_POOL_WORDS]; | 421 | static __u32 input_pool_data[INPUT_POOL_WORDS]; |
| @@ -714,8 +715,6 @@ void add_disk_randomness(struct gendisk *disk) | |||
| 714 | } | 715 | } |
| 715 | #endif | 716 | #endif |
| 716 | 717 | ||
| 717 | #define EXTRACT_SIZE 10 | ||
| 718 | |||
| 719 | /********************************************************************* | 718 | /********************************************************************* |
| 720 | * | 719 | * |
| 721 | * Entropy extraction routines | 720 | * Entropy extraction routines |
| @@ -862,7 +861,7 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf, | |||
| 862 | while (nbytes) { | 861 | while (nbytes) { |
| 863 | extract_buf(r, tmp); | 862 | extract_buf(r, tmp); |
| 864 | 863 | ||
| 865 | if (r->last_data) { | 864 | if (fips_enabled) { |
| 866 | spin_lock_irqsave(&r->lock, flags); | 865 | spin_lock_irqsave(&r->lock, flags); |
| 867 | if (!memcmp(tmp, r->last_data, EXTRACT_SIZE)) | 866 | if (!memcmp(tmp, r->last_data, EXTRACT_SIZE)) |
| 868 | panic("Hardware RNG duplicated output!\n"); | 867 | panic("Hardware RNG duplicated output!\n"); |
| @@ -951,9 +950,6 @@ static void init_std_data(struct entropy_store *r) | |||
| 951 | now = ktime_get_real(); | 950 | now = ktime_get_real(); |
| 952 | mix_pool_bytes(r, &now, sizeof(now)); | 951 | mix_pool_bytes(r, &now, sizeof(now)); |
| 953 | mix_pool_bytes(r, utsname(), sizeof(*(utsname()))); | 952 | mix_pool_bytes(r, utsname(), sizeof(*(utsname()))); |
| 954 | /* Enable continuous test in fips mode */ | ||
| 955 | if (fips_enabled) | ||
| 956 | r->last_data = kmalloc(EXTRACT_SIZE, GFP_KERNEL); | ||
| 957 | } | 953 | } |
| 958 | 954 | ||
| 959 | static int rand_initialize(void) | 955 | static int rand_initialize(void) |
