From: mbrugger <matthias.bgg@kernel.org>
To: u-boot@lists.denx.de
Subject: [PATCH v2 1/2] lib: uuid: use RNG device if present
Date: Fri, 18 Dec 2020 10:10:33 +0100 [thread overview]
Message-ID: <X9xyCSSzSJoC5VvM@ziggy.stardust> (raw)
In-Reply-To: <20201218093719.6a7caf50@blackhole>
On Fri, Dec 18, 2020 at 09:37:28AM +0100, Torsten Duwe wrote:
> On Wed, 16 Dec 2020 17:28:06 +0100
> matthias.bgg at kernel.org wrote:
>
> > @@ -249,9 +251,22 @@ void gen_rand_uuid(unsigned char *uuid_bin)
> > {
> > u32 ptr[4];
> > struct uuid *uuid = (struct uuid *)ptr;
> > - int i;
> > -
> > - srand(get_ticks() + rand());
> > + int i, ret;
> > + struct udevice *devp;
> > + u8 randv = 0;
> ^^
> Only 1 byte? The UUID could use some more, and, having a HW RNG, it
> doesn't hurt to seed it with more entropy here. I suggest using u32 as
> well.
>
> > +
> > +#if defined(CONFIG_DM_RNG)
> > + ret = uclass_get_device(UCLASS_RNG, 0, &devp);
> > + if (ret) {
> > + ret = dm_rng_read(devp, &randv, sizeof(randv));
> > + if (ret < 0)
> > + randv = 0;
> > + }
>
> See my reply to the cover letter. I'd suggest to wrap this with
> if (IS_ENABLED(CONFIG_DM_RNG))
> instead, likewise for the MAC.
Sounds good, I'll send a new version addressing both issues.
Thanks for the review.
Matthias
next prev parent reply other threads:[~2020-12-18 9:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-16 16:28 [PATCH v2 0/2] Use RNG to get random behaviour matthias.bgg at kernel.org
2020-12-16 16:28 ` [PATCH v2 1/2] lib: uuid: use RNG device if present matthias.bgg at kernel.org
2020-12-18 8:37 ` Torsten Duwe
2020-12-18 9:10 ` mbrugger [this message]
2020-12-19 2:29 ` Simon Glass
2020-12-20 16:59 ` Torsten Duwe
2020-12-20 18:17 ` Simon Glass
2020-12-23 10:24 ` Torsten Duwe
2020-12-29 3:32 ` Simon Glass
2021-01-20 11:17 ` Matthias Brugger
2021-01-20 19:50 ` Simon Glass
2021-01-20 19:56 ` Matthias Brugger
2020-12-23 10:09 ` Matthias Brugger
2020-12-16 16:28 ` [PATCH v2 2/2] net: Use NDRNG device in srand_mac() matthias.bgg at kernel.org
2020-12-19 2:29 ` Simon Glass
2020-12-18 8:31 ` [PATCH v2 0/2] Use RNG to get random behaviour Torsten Duwe
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=X9xyCSSzSJoC5VvM@ziggy.stardust \
--to=matthias.bgg@kernel.org \
--cc=u-boot@lists.denx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.