From: Rasmus Villemoes <ravi@prevas.dk>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: Tom Rini <trini@konsulko.com>,
heinrich.schuchardt@canonical.com, hugo.cornelis@essensium.com,
sjg@chromium.org, paulerwan.rio@gmail.com, al.kochet@gmail.com,
ada@thorsis.com, philippe.reynes@softathome.com,
u-boot@lists.denx.de
Subject: Re: [PATCH 1/1] tools: use cryptographically safe RNG
Date: Fri, 15 Nov 2024 08:18:17 +0100 [thread overview]
Message-ID: <87ttc9m0cm.fsf@prevas.dk> (raw)
In-Reply-To: <87plmx1h4r.fsf@bloch.sibelius.xs4all.nl> (Mark Kettenis's message of "Fri, 15 Nov 2024 01:21:24 +0100")
On Fri, Nov 15 2024, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>> Date: Thu, 14 Nov 2024 11:39:27 -0600
>> From: Tom Rini <trini@konsulko.com>
>>
>> On Thu, Nov 14, 2024 at 06:35:44PM +0100, Heinrich Schuchardt wrote:
>> > Tom Rini <trini@konsulko.com> schrieb am Do., 14. Nov. 2024, 18:27:
>> >
>> > > On Sat, Nov 02, 2024 at 05:32:59PM +0100, Heinrich Schuchardt wrote:
>> > >
>> > > > The PRNG implementing the random() function only has 2^31 states and
>> > > > therefore is unsafe to use for cryptography. Use arc4random() instead.
>> > > >
>> > > > Fixes: cc34f04efd63 ("tools: image-host.c: use random instead of rand")
>> > > > Addresses-Coverity-ID: 312953 Calling risky function
>> > > > Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
>> > > > ---
>> > > > tools/image-host.c | 35 +++--------------------------------
>> > > > 1 file changed, 3 insertions(+), 32 deletions(-)
>> > >
>> > > Now I get:
>> > > /home/uboot/u-boot/u-boot/tools/image-host.c: In function
>> > > 'fit_image_setup_cipher':
>> > > /home/uboot/u-boot/u-boot/tools/image-host.c:439:17: warning: implicit
>> > > declaration of function 'arc4random_buf' [-Wimplicit-function-declaration]
>> > > 439 | arc4random_buf((void *)info->iv,
>> > > info->cipher->iv_len);
>> > > | ^~~~~~~~~~~~~~
>> > > /usr/bin/ld: tools/image-host.o: in function `fit_image_cipher_data':
>> > > image-host.c:(.text+0xb41): undefined reference to `arc4random_buf'
>> > > collect2: error: ld returned 1 exit status
>> > > make[3]: *** [scripts/Makefile.host:104: tools/dumpimage] Error 1
>> > >
>> > > in the docker container. I gather this means arc4random_buf is not as
>> > > widely available as assumed.
>> > >
>> >
>> > glibc 2.36 is required published 2022-08. Ubuntu Jammy is 22.04.
>>
>> Yeah, that's likely (a) too new and (b) strange because:
>> https://source.denx.de/u-boot/u-boot/-/jobs/945810 and so is jammy
>> 22.04.
>
> Linking against libbsd might be an alternative on older systems.
Or use getrandom(), which according to the man page has been exposed via
glibc since glibc 2.25. Or just read from /dev/urandom which should work
everywhere.
Rasmus
next prev parent reply other threads:[~2024-11-15 7:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-02 16:32 [PATCH 1/1] tools: use cryptographically safe RNG Heinrich Schuchardt
2024-11-14 17:26 ` Tom Rini
2024-11-14 17:35 ` Heinrich Schuchardt
2024-11-14 17:39 ` Tom Rini
2024-11-15 0:21 ` Mark Kettenis
2024-11-15 7:18 ` Rasmus Villemoes [this message]
2024-11-15 8:34 ` Heinrich Schuchardt
2024-11-15 10:41 ` Rasmus Villemoes
2024-11-15 11:19 ` Torsten Duwe
2024-11-15 14:32 ` Mark Kettenis
2024-11-15 19:21 ` Rasmus Villemoes
2024-11-15 22:48 ` Mark Kettenis
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=87ttc9m0cm.fsf@prevas.dk \
--to=ravi@prevas.dk \
--cc=ada@thorsis.com \
--cc=al.kochet@gmail.com \
--cc=heinrich.schuchardt@canonical.com \
--cc=hugo.cornelis@essensium.com \
--cc=mark.kettenis@xs4all.nl \
--cc=paulerwan.rio@gmail.com \
--cc=philippe.reynes@softathome.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.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 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.