All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: "'Jason A. Donenfeld'" <Jason@zx2c4.com>,
	James Hilliard <james.hilliard1@gmail.com>,
	Arnout Vandecappelle <arnout@mind.be>,
	"Yann E. MORIN" <yann.morin.1998@free.fr>,
	buildroot <buildroot@buildroot.org>
Subject: Re: [Buildroot] [PATCH v3] package/urandom-scripts: actually credit seed files via seedrng
Date: Tue, 29 Mar 2022 06:12:41 +0000	[thread overview]
Message-ID: <cc188e7013f94bb5a39f87e78c2e697b@AcuMS.aculab.com> (raw)
In-Reply-To: <20220329050401.110856-1-Jason@zx2c4.com>

From: Jason A. Donenfeld
> Sent: 29 March 2022 06:04
> 
> The RNG can't actually be seeded from a shell script, due to the
> reliance on ioctls. For this reason, the seedrng project provides a
> basic script meant to be copy and pasted into projects like buildroot
> and tweaked as needed: <https://git.zx2c4.com/seedrng/about/>.
> 
> This commit imports it into buildroot and wires up the init scripts to
> call it. This also is a significant improvement over the current init
> script, which doesn't credit entropy and whose hashing in shell scripts
> is sort of fragile.
> 
> As seedrng.c is a short tiny C program, we include this here in the
> package, like a few other packages do. Later we'll investigate adding
> this to busybox, but for now, this is a good start and a positive step
> in the right direction.

It isn't that tiny, this bloats out to quite a lot of code.

> +#define G(r, i, a, b, c, d) do { \
> +	a += b + m[blake2s_sigma[r][2 * i + 0]]; \
> +	d = ror32(d ^ a, 16); \
> +	c += d; \
> +	b = ror32(b ^ c, 12); \
> +	a += b + m[blake2s_sigma[r][2 * i + 1]]; \
> +	d = ror32(d ^ a, 8); \
> +	c += d; \
> +	b = ror32(b ^ c, 7); \
> +} while (0)
> +
> +#define ROUND(r) do { \
> +	G(r, 0, v[0], v[ 4], v[ 8], v[12]); \
> +	G(r, 1, v[1], v[ 5], v[ 9], v[13]); \
> +	G(r, 2, v[2], v[ 6], v[10], v[14]); \
> +	G(r, 3, v[3], v[ 7], v[11], v[15]); \
> +	G(r, 4, v[0], v[ 5], v[10], v[15]); \
> +	G(r, 5, v[1], v[ 6], v[11], v[12]); \
> +	G(r, 6, v[2], v[ 7], v[ 8], v[13]); \
> +	G(r, 7, v[3], v[ 4], v[ 9], v[14]); \
> +} while (0)
> +		ROUND(0);
> +		ROUND(1);
> +		ROUND(2);
> +		ROUND(3);
> +		ROUND(4);
> +		ROUND(5);
> +		ROUND(6);
> +		ROUND(7);
> +		ROUND(8);
> +		ROUND(9);

I've not looked at why the code is doing this.
If you are feeding data that has come from the RNG back in
as state/entropy why does it contain a copy of blake2?

I was expecting to see a program that copied stdin to /dev/urandom
in a manner that actually credited entropy.
About 10 lines of code.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2022-03-29  6:12 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-27  5:48 [Buildroot] [PATCH] package/urandom-scripts: actually credit seed files via seedrng Jason A. Donenfeld
2022-03-27 18:01 ` James Hilliard
2022-03-27 19:36   ` Arnout Vandecappelle
2022-03-27 19:58     ` James Hilliard
2022-03-27 20:08       ` Jason A. Donenfeld
2022-03-27 20:10         ` Jason A. Donenfeld
2022-03-27 20:24           ` [Buildroot] [PATCH v2] " Jason A. Donenfeld
2022-03-27 20:29             ` James Hilliard
2022-03-29  5:04             ` [Buildroot] [PATCH v3] " Jason A. Donenfeld
2022-03-29  6:12               ` David Laight [this message]
2022-03-30 16:32               ` Peter Korsgaard
2022-03-30 16:57                 ` David Laight
2022-03-30 17:13                 ` Jason A. Donenfeld
2022-03-31 14:50                   ` Jason A. Donenfeld
2022-03-31 14:57                   ` [Buildroot] [PATCH v4] " Jason A. Donenfeld
2022-03-31 15:16                     ` David Laight
2022-03-31 15:46                       ` David Laight
2022-03-31 17:11                   ` [Buildroot] [PATCH v3] " Peter Korsgaard
2022-04-01  8:12                     ` David Laight
2022-04-01  9:22                       ` Jason A. Donenfeld
2022-04-01 10:11                         ` David Laight
2022-04-01 10:17                           ` Jason A. Donenfeld
2022-04-01 10:57                   ` James Hilliard
2022-04-01 11:04                     ` Jason A. Donenfeld
2022-04-01 11:34                       ` David Laight
2022-04-02 17:08                         ` Arnout Vandecappelle
2022-04-03  7:30                           ` David Laight
2022-04-04 14:32                             ` Jason A. Donenfeld
2022-04-03  9:42                           ` Yann E. MORIN
2022-04-03 23:13                             ` James Hilliard
2022-04-04 14:40                               ` Jason A. Donenfeld
2022-04-04 14:38                             ` Jason A. Donenfeld
2022-03-27 20:25           ` [Buildroot] [PATCH] " James Hilliard
2022-03-27 20:26             ` Jason A. Donenfeld

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=cc188e7013f94bb5a39f87e78c2e697b@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=Jason@zx2c4.com \
    --cc=arnout@mind.be \
    --cc=buildroot@buildroot.org \
    --cc=james.hilliard1@gmail.com \
    --cc=yann.morin.1998@free.fr \
    /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.