[RFC PATCH v1 24/50] crypto4xx_core: Use more appropriate seed for PRNG

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A PRNG doesn't need the full security guarantees of
get_random_bytes() (and a 64-bit seed can be brute-forced
anyway); get_random_u32() is quite sufficient.

Signed-off-by: George Spelvin <lkml@xxxxxxx>
Cc: James Hsiao <jhsiao@xxxxxxxx>
Cc: Christian Lamparter <chunkeey@xxxxxxxxx>
Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Cc: linux-crypto@xxxxxxxxxxxxxxx
---
 drivers/crypto/amcc/crypto4xx_core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c
index 7d6b695c4ab3f..0fc41ffe3ff9a 100644
--- a/drivers/crypto/amcc/crypto4xx_core.c
+++ b/drivers/crypto/amcc/crypto4xx_core.c
@@ -53,7 +53,6 @@ static void crypto4xx_hw_init(struct crypto4xx_device *dev)
 	union ce_ring_control ring_ctrl;
 	union ce_part_ring_size part_ring_size;
 	union ce_io_threshold io_threshold;
-	u32 rand_num;
 	union ce_pe_dma_cfg pe_dma_cfg;
 	u32 device_ctrl;
 
@@ -79,10 +78,8 @@ static void crypto4xx_hw_init(struct crypto4xx_device *dev)
 	writel(dev->pdr_pa, dev->ce_base + CRYPTO4XX_PDR_BASE);
 	writel(dev->pdr_pa, dev->ce_base + CRYPTO4XX_RDR_BASE);
 	writel(PPC4XX_PRNG_CTRL_AUTO_EN, dev->ce_base + CRYPTO4XX_PRNG_CTRL);
-	get_random_bytes(&rand_num, sizeof(rand_num));
-	writel(rand_num, dev->ce_base + CRYPTO4XX_PRNG_SEED_L);
-	get_random_bytes(&rand_num, sizeof(rand_num));
-	writel(rand_num, dev->ce_base + CRYPTO4XX_PRNG_SEED_H);
+	writel(get_random_u32(), dev->ce_base + CRYPTO4XX_PRNG_SEED_L);
+	writel(get_random_u32(), dev->ce_base + CRYPTO4XX_PRNG_SEED_H);
 	ring_size.w = 0;
 	ring_size.bf.ring_offset = PPC4XX_PD_SIZE;
 	ring_size.bf.ring_size   = PPC4XX_NUM_PD;
-- 
2.26.0




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux