mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 1/2] crypto: ecc: use HWRNG for random numbers
@ 2025-04-17  6:21 Ahmad Fatoum
  2025-04-17  6:21 ` [PATCH master 2/2] crypto: imx-scc: blobgen: " Ahmad Fatoum
  2025-04-22  8:25 ` [PATCH master 1/2] crypto: ecc: " Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2025-04-17  6:21 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The kernel's get_random_bytes provides random numbers suitable for crypto
purposes, while in barebox, we need to use get_crypto_bytes for that.

This footgun needs to be fixed, but until we do, let's make sure crypto
code doesn't use a badly seeded PRNG.

Fortunately crypto_ecdh_shared_secret is currently unused and this
doesn't affect any upstream users.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 crypto/ecc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/ecc.c b/crypto/ecc.c
index d91948bddbde..b90fe0e74809 100644
--- a/crypto/ecc.c
+++ b/crypto/ecc.c
@@ -1621,7 +1621,7 @@ int crypto_ecdh_shared_secret(unsigned int curve_id, unsigned int ndigits,
 
 	nbytes = ndigits << ECC_DIGITS_TO_BYTES_SHIFT;
 
-	get_random_bytes(rand_z, nbytes);
+	get_crypto_bytes(rand_z, nbytes);
 
 	pk = ecc_alloc_point(ndigits);
 	if (!pk) {
-- 
2.39.5




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH master 2/2] crypto: imx-scc: blobgen: use HWRNG for random numbers
  2025-04-17  6:21 [PATCH master 1/2] crypto: ecc: use HWRNG for random numbers Ahmad Fatoum
@ 2025-04-17  6:21 ` Ahmad Fatoum
  2025-04-22  8:25 ` [PATCH master 1/2] crypto: ecc: " Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2025-04-17  6:21 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The kernel's get_random_bytes provides random numbers suitable for crypto
purposes, while in barebox, we need to use get_crypto_bytes for that.

This footgun needs to be fixed, but until we do, let's make sure crypto
code doesn't use a badly seeded PRNG.

Fixes: b62a31a9069b ("crypto: add new imx-scc driver")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/crypto/imx-scc/scc-blobgen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/imx-scc/scc-blobgen.c b/drivers/crypto/imx-scc/scc-blobgen.c
index 530d0840f810..a444386dab5a 100644
--- a/drivers/crypto/imx-scc/scc-blobgen.c
+++ b/drivers/crypto/imx-scc/scc-blobgen.c
@@ -67,7 +67,7 @@ static int imx_scc_blob_encrypt(struct blobgen *bg, const char *modifier,
 	req.dst = blob;
 	req.nbytes = bufsiz;
 
-	get_random_bytes(req.info, MAX_IVLEN);
+	get_crypto_bytes(req.info, MAX_IVLEN);
 
 	ret = imx_scc_cbc_des_encrypt(&req);
 	if (ret)
-- 
2.39.5




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH master 1/2] crypto: ecc: use HWRNG for random numbers
  2025-04-17  6:21 [PATCH master 1/2] crypto: ecc: use HWRNG for random numbers Ahmad Fatoum
  2025-04-17  6:21 ` [PATCH master 2/2] crypto: imx-scc: blobgen: " Ahmad Fatoum
@ 2025-04-22  8:25 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2025-04-22  8:25 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Thu, 17 Apr 2025 08:21:51 +0200, Ahmad Fatoum wrote:
> The kernel's get_random_bytes provides random numbers suitable for crypto
> purposes, while in barebox, we need to use get_crypto_bytes for that.
> 
> This footgun needs to be fixed, but until we do, let's make sure crypto
> code doesn't use a badly seeded PRNG.
> 
> Fortunately crypto_ecdh_shared_secret is currently unused and this
> doesn't affect any upstream users.
> 
> [...]

Applied, thanks!

[1/2] crypto: ecc: use HWRNG for random numbers
      https://git.pengutronix.de/cgit/barebox/commit/?id=4532f50b8a8a (link may not be stable)
[2/2] crypto: imx-scc: blobgen: use HWRNG for random numbers
      https://git.pengutronix.de/cgit/barebox/commit/?id=cc8b962b1dca (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-22  9:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-17  6:21 [PATCH master 1/2] crypto: ecc: use HWRNG for random numbers Ahmad Fatoum
2025-04-17  6:21 ` [PATCH master 2/2] crypto: imx-scc: blobgen: " Ahmad Fatoum
2025-04-22  8:25 ` [PATCH master 1/2] crypto: ecc: " Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox