From: David Laight <David.Laight@ACULAB.COM>
To: "'Jason A. Donenfeld'" <Jason@zx2c4.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Guenter Roeck <linux@roeck-us.net>,
"Dominik Brodowski" <linux@dominikbrodowski.net>,
Theodore Ts'o <tytso@mit.edu>, "Jann Horn" <jannh@google.com>
Subject: RE: [PATCH] random: allow writes to /dev/urandom to influence fast init
Date: Wed, 23 Mar 2022 11:45:55 +0000 [thread overview]
Message-ID: <0f9b31b346504d28a908d16884df5e02@AcuMS.aculab.com> (raw)
In-Reply-To: <YjqLAWbZ8K7eg3Fw@zx2c4.com>
From: Jason A. Donenfeld
> Sent: 23 March 2022 02:51
>
> On Tue, Mar 22, 2022 at 8:16 PM David Laight <David.Laight@aculab.com> wrote:
> > Never mind scripts that try to immediately save a new seedfile [1].
> >
> > What about code run by later startup scripts that wants random numbers.
> > They really do want the seedfile data to be used.
> > If it isn't used then they are likely to get very weak random numbers.
> >
> > You can't really expect startup scripts to be issuing ioctl requests.
>
> To be clear, this "expect[ation]" of yours is very much a new
> expectation. Crediting bits has required an ioctl since forever. Those
> shell scripts have been broken forever. The proposal here is to add new
> behavior to support those old broken shell scripts.
...
I personally won't have expected the behaviour for long!
I was only trying to get a buildroot system to initialise the
random number generator last year.
But I'm sure I read some of the documentation as well as looking
at the scripts and the kernel sources.
The buildroot scripts actually need fixing so they actually
add entropy on older kernel.
I do remember looking at one of the kernel entropy stores
(probably the Linux one) a few years back and thinking
that it was over-complex and probably didn't actually work
that well in reality.
IIRC it saved 'entropy bytes' and the number of bits of entropy
they represented - and then read out enough bytes to get
the required entropy to reseed the PRNG.
Now if your PRNG has N bits of state. In principle at least
after you've output N bits someone can solve the simultaneous
equations and determine the PRNG state.
But as soon as you use a cryptographic hash function that
is not really possible in any reasonable timeframe.
(Is even MD5 that broken?)
But the 'entropy store' can just stir in new bytes and
count the number of entropy bits.
Then it doesn't really care how random the bytes are.
(Apart from an estimation of how 'full' it is.)
Copy bits to the PRNG and you reduce the number of
bits in the entropy store - but continue just stirring
in new data.
I've often wondered whether the RC5 algorithm would
make a good entropy store.
Just cycle the algorithm with each entropy byte as
is done when setting each key byte.
Clearly you don't want to use the RC5 output as random data.
But it ought to be plenty good enough to keep entropy.
The only real problem is that RC5 is pretty horrid on
the data cache, and probably a bit big for per-cpu data.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2022-03-23 11:46 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-22 19:14 Jason A. Donenfeld
2022-03-22 20:42 ` Linus Torvalds
2022-03-22 23:54 ` Jason A. Donenfeld
2022-03-23 2:15 ` David Laight
2022-03-23 2:50 ` Jason A. Donenfeld
2022-03-23 8:43 ` Rasmus Villemoes
2022-03-24 14:12 ` Jason A. Donenfeld
2022-03-23 11:45 ` David Laight [this message]
2022-03-23 3:35 ` Theodore Ts'o
2022-03-23 4:00 ` Jason A. Donenfeld
2022-03-23 12:31 ` Theodore Ts'o
2022-05-23 17:59 ` Pavel Machek
2022-03-23 4:30 ` Alex Xu (Hello71)
2022-03-23 4:47 ` Jason A. Donenfeld
2022-03-23 14:01 ` David Laight
2022-03-23 19:53 ` Jason A. Donenfeld
2022-03-24 18:01 ` Eric Biggers
2022-03-24 3:18 ` Jason A. Donenfeld
2022-03-24 16:28 ` Alex Xu (Hello71)
2022-03-24 17:20 ` Jason A. Donenfeld
2022-03-24 19:03 ` Alex Xu (Hello71)
2022-03-24 18:26 ` Eric Biggers
2022-03-24 18:31 ` Jason A. Donenfeld
2022-06-19 16:44 ` Pavel Machek
2022-03-24 19:53 ` Eric Biggers
2022-03-24 20:25 ` Jason A. Donenfeld
2022-06-19 16:56 ` Pavel Machek
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=0f9b31b346504d28a908d16884df5e02@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=Jason@zx2c4.com \
--cc=jannh@google.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@dominikbrodowski.net \
--cc=linux@roeck-us.net \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
/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
all inboxes | Powered by JetHome®