From: George Spelvin <lkml@sdf.org>
To: linux-kernel@vger.kernel.org, lkml@sdf.org
Cc: James Hsiao <jhsiao@amcc.com>,
Christian Lamparter <chunkeey@gmail.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
linux-crypto@vger.kernel.org
Subject: [RFC PATCH v1 24/50] crypto4xx_core: Use more appropriate seed for PRNG
Date: Wed, 27 Mar 2019 07:56:49 -0400 [thread overview]
Message-ID: <202003281643.02SGhGKO009144@sdf.org> (raw)
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@sdf.org>
Cc: James Hsiao <jhsiao@amcc.com>
Cc: Christian Lamparter <chunkeey@gmail.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org
---
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
reply other threads:[~2020-03-28 16:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202003281643.02SGhGKO009144@sdf.org \
--to=lkml@sdf.org \
--cc=chunkeey@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=jhsiao@amcc.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).