Skip to content

Commit

Permalink
hwrng: core - allow perfect entropy from hardware devices
Browse files Browse the repository at this point in the history
Hardware random number quality is measured from 0 (no entropy) to 1024
(perfect entropy). Allow hardware devices to assert the full range by
truncating the device-provided value at 1024 instead of 1023.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Keith Packard authored and Herbert Xu committed Mar 18, 2015
1 parent 7094e8e commit 506bf0c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/char/hw_random/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ static int hwrng_init(struct hwrng *rng)
add_early_randomness(rng);

current_quality = rng->quality ? : default_quality;
current_quality &= 1023;
if (current_quality > 1024)
current_quality = 1024;

if (current_quality == 0 && hwrng_fill)
kthread_stop(hwrng_fill);
Expand Down

0 comments on commit 506bf0c

Please sign in to comment.