From: "Theodore Y. Ts'o" <tytso@mit.edu>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: louiscollard@chromium.org,
"open list:HARDWARE RANDOM NUMBER GENERATOR CORE"
<linux-crypto@vger.kernel.org>,
mpm@selenic.com, Herbert Xu <herbert@gondor.apana.org.au>,
Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
gary.hook@amd.com, m@bues.ch,
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
apronin@chromium.org,
Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
linux@mniewoehner.de, david.bild@xaptum.com
Subject: Re: [PATCH v2] Allow hwrng to initialize crng.
Date: Thu, 13 Dec 2018 22:58:21 -0500 [thread overview]
Message-ID: <20181214035821.GD20880@thunk.org> (raw)
In-Reply-To: <CAKv+Gu9sWw=VHjYivokAkhGP+p1P15bs3ThfRghARNesW5kyOA@mail.gmail.com>
On Thu, Dec 13, 2018 at 10:48:07AM +0100, Ard Biesheuvel wrote:
> > @@ -64,13 +65,19 @@ static size_t rng_buffer_size(void)
> > static void add_early_randomness(struct hwrng *rng)
> > {
> > int bytes_read;
> > - size_t size = min_t(size_t, 16, rng_buffer_size());
> > + /* Read enough to initialize crng. */
> > + size_t size = min_t(size_t,
> > + 2*CHACHA20_KEY_SIZE,
>
> This should be as symbolic constant that retains its meaning even if
> we move away from ChaCha20 or modify the current implementation
Also, rng_buffer_size() could be less than 2*hCHACHA20_KEY_SIZE, at
which point your goal wouldn't be realized. What I'd recommend is to
keep the line:
size_t size = min_t(size_t, 16, rng_buffer_size());
But to loop until rng_is_initialized() returns true or bytes_read is
0. If you want to be paranoid, you could also break out of the loop
it isn't initialized after, say, 8 times through the loop.
Cheers,
- Ted
next prev parent reply other threads:[~2018-12-14 3:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-13 9:18 [PATCH v2] Allow hwrng to initialize crng Louis Collard
2018-12-13 9:48 ` Ard Biesheuvel
2018-12-14 3:12 ` Louis Collard
2018-12-14 3:58 ` Theodore Y. Ts'o [this message]
2018-12-14 7:56 ` Jarkko Sakkinen
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=20181214035821.GD20880@thunk.org \
--to=tytso@mit.edu \
--cc=apronin@chromium.org \
--cc=ard.biesheuvel@linaro.org \
--cc=arnd@arndb.de \
--cc=david.bild@xaptum.com \
--cc=gary.hook@amd.com \
--cc=gregkh@linuxfoundation.org \
--cc=herbert@gondor.apana.org.au \
--cc=jarkko.sakkinen@linux.intel.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@mniewoehner.de \
--cc=louiscollard@chromium.org \
--cc=m@bues.ch \
--cc=mpm@selenic.com \
--cc=mst@redhat.com \
--cc=prasannatsmkumar@gmail.com \
/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.