From: David Laight <David.Laight@ACULAB.COM>
To: 'Peter Korsgaard' <peter@korsgaard.com>,
"Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: James Hilliard <james.hilliard1@gmail.com>,
"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: Fri, 1 Apr 2022 08:12:28 +0000 [thread overview]
Message-ID: <2949fa8776db4c96800e1df8e39a8ec2@AcuMS.aculab.com> (raw)
In-Reply-To: <87bkxm2gix.fsf@dell.be.48ers.dk>
I used the following small program instead of dd to credit the entropy.
+#include <linux/random.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+/* Just writing to /dev/urandom doesn't credit any entropy
+ * so the crng remains uninitialised.
+ * So use the relevant ioctl instead. */
+
+int main(int argc, char **argv)
+{
+ int fd;
+ int len;
+ struct {
+ struct rand_pool_info info;
+ int buf[4096];
+ } rnd_info;
+
+ if (!argv[1])
+ return 1;
+
+ fd = open(argv[1], O_RDONLY);
+ if (fd < 0)
+ return 1;
+ len = read(fd, rnd_info.buf, sizeof rnd_info.buf);
+ close(fd);
+ if (len <= 0)
+ return 1;
+
+ fd = open("/dev/urandom", O_RDWR);
+ if (fd < 0)
+ return 1;
+ rnd_info.info.entropy_count = len * 8;
+ rnd_info.info.buf_size = len;
+
+ len = ioctl(fd, RNDADDENTROPY, &rnd_info);
+
+ return len ? 1 : 0;
+}
Seems to do the trick.
Something that size is probably a candidate for busybox.
Although it does really need to run before udev is initialised.
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
next prev parent reply other threads:[~2022-04-01 8: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
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 [this message]
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=2949fa8776db4c96800e1df8e39a8ec2@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=Jason@zx2c4.com \
--cc=buildroot@buildroot.org \
--cc=james.hilliard1@gmail.com \
--cc=peter@korsgaard.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.