Skip to contentSkip to conversation

hwrng: core - allow perfect entropy from hardware devices

PATCH In review Keith Packard 2 participants 4 messages Mar 18, 2015 Hardware random number generator core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwrng: core - allow perfect entropy from hardware devices

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.

---
 drivers/char/hw_random/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/hw_random/core.c +2 -1
index 1500cfd..b726683 100644
@@ -98,7 +98,8 @@ static inline 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);
Signature · 1 line
2.1.4
maintainer
#1 lore raw
Quoted 5 lines · Keith Packard

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.

Please cc all hwrng patches to [email protected] so that it gets picked up by patchworks. Thanks!

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#2 lore raw
Quoted 2 lines · Herbert Xu

Please cc all hwrng patches to [email protected] so that it gets picked up by patchworks. Thanks!

Thanks! I didn't catch that in the MAINTAINERS file. Might be a good thing to add?

Signature · 1 line
-keith
maintainer
#3 lore raw
Quoted 7 lines · Keith Packard
Quoted 2 lines · Herbert Xu

Please cc all hwrng patches to [email protected] so that it gets picked up by patchworks. Thanks!

Thanks! I didn't catch that in the MAINTAINERS file. Might be a good thing to add?

I think we've already added this to the MAINTAINERS file but it was done fairly recently.

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt