From: Matthias Brugger <matthias.bgg@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH 2/2] net: Use NDRNG device in srand_mac()
Date: Wed, 16 Dec 2020 16:56:28 +0100 [thread overview]
Message-ID: <4cf5c298-e417-602a-96b8-71dcd11e4807@gmail.com> (raw)
In-Reply-To: <20201216142014.43a583c4@blackhole.lan>
On 16/12/2020 14:20, Torsten Duwe wrote:
> On Wed, 16 Dec 2020 11:41:17 +0100
> matthias.bgg at kernel.org wrote:
>
>> From: Matthias Brugger <mbrugger@suse.com>
>>
>> When calling srand_mac we use a weak seed dependent on the
>> mac address. If present, use a RNG device instead to incerase entropy.
>>
>> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
>>
>> ---
>>
>> net/net_rand.h | 18 +++++++++++++++++-
>> 1 file changed, 17 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/net_rand.h b/net/net_rand.h
>> index 4bf9bd817e..600c3d825e 100644
>> --- a/net/net_rand.h
>> +++ b/net/net_rand.h
>> @@ -10,6 +10,7 @@
>> #define __NET_RAND_H__
>>
>> #include <common.h>
>> +#include <rng.h>
>>
>> /*
>> * Return a seed for the PRNG derived from the eth0 MAC address.
>> @@ -37,7 +38,22 @@ static inline unsigned int seed_mac(void)
>> */
>> static inline void srand_mac(void)
>> {
>> - srand(seed_mac());
>> +#if defined(CONFIG_DM_RNG)
>> + int ret;
>> + struct udevice *devp;
>> + u32 randv = 0;
>> +
>> + ret = uclass_get_device(UCLASS_RNG, 0, &devp);
>> + if (ret) {
>> + ret = dm_rng_read(dev, randv, sizeof(randv));
> Haven't tested this (yet), but shouldn't this be
> ret = dm_rng_read(devp, &randv, sizeof(randv));
> ^ ^ ?
Ups, yes you are right. I'll send a v2.
Regards,
Matthias
next prev parent reply other threads:[~2020-12-16 15:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-16 10:41 [PATCH 0/2] Use RNG to get random behaviour matthias.bgg at kernel.org
2020-12-16 10:41 ` [PATCH 1/2] lib: uuid: use RNG device if present matthias.bgg at kernel.org
2020-12-16 13:22 ` Torsten Duwe
2020-12-16 10:41 ` [PATCH 2/2] net: Use NDRNG device in srand_mac() matthias.bgg at kernel.org
2020-12-16 13:20 ` Torsten Duwe
2020-12-16 15:56 ` Matthias Brugger [this message]
2020-12-16 13:17 ` [PATCH 0/2] Use RNG to get random behaviour Torsten Duwe
2020-12-16 13:42 ` Peter Robinson
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=4cf5c298-e417-602a-96b8-71dcd11e4807@gmail.com \
--to=matthias.bgg@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox