Skip to contentSkip to conversation

hwrng: Pass entropy to add_hwgenerator_randomness() in bits, not bytes

PATCH Applied Stephen Boyd 3 participants 3 messages Jul 25, 2014 – Aug 5, 2014 Hardware random number generator core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwrng: Pass entropy to add_hwgenerator_randomness() in bits, not bytes

rng_get_data() returns the number of bytes read from the hardware. The entropy argument to add_hwgenerator_randomness() is passed directly to credit_entropy_bits() so we should be passing the number of bits, not bytes here.

Fixes be4000bc464 "hwrng: create filler thread"
Cc Torsten Duwe <[email protected]>
---
 drivers/char/hw_random/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/hw_random/core.c +1 -1
index dc80cdab733d..6e02ec103cc7 100644
@@ -362,7 +362,7 @@ static int hwrng_fillfn(void *unused)
 			continue;
 		}
 		add_hwgenerator_randomness((void *)rng_fillbuf, rc,
-					   (rc*current_quality)>>10);
+					   rc * current_quality * 8 >> 10);
 	}
 	hwrng_fill = NULL;
 	return 0;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Stephen Boyd

rng_get_data() returns the number of bytes read from the hardware. The entropy argument to add_hwgenerator_randomness() is passed directly to credit_entropy_bits() so we should be passing the number of bits, not bytes here.

Absolutely correct.

Quoted 29 lines
Fixes be4000bc464 "hwrng: create filler thread"
Cc Torsten Duwe <[email protected]>
---
 drivers/char/hw_random/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/hw_random/core.c +1 -1
index dc80cdab733d..6e02ec103cc7 100644
@@ -362,7 +362,7 @@ static int hwrng_fillfn(void *unused)
 			continue;
 		}
 		add_hwgenerator_randomness((void *)rng_fillbuf, rc,
-					   (rc*current_quality)>>10);
+					   rc * current_quality * 8 >> 10);
 	}
 	hwrng_fill = NULL;
 	return 0;
Signature · 8 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#2 lore raw
Quoted 9 lines · Torsten Duwe
Quoted 4 lines · Stephen Boyd

rng_get_data() returns the number of bytes read from the hardware. The entropy argument to add_hwgenerator_randomness() is passed directly to credit_entropy_bits() so we should be passing the number of bits, not bytes here.

Absolutely correct.

Applied, thanks.

- Ted