3 ms·
> RLY? How on earth can a read from /dev/random be non blocking if it does not have sufficient entropy? In short, to answer your question, I am not aware of an
by atoponce 9y ago
> RLY? How on earth can a read from /dev/random be non blocking if it does not have sufficient entropy?
In short, to answer your question, I am not aware of any /dev/random that will not block if not sufficiently seeded with enough entropy. Linux is the only kernel where /dev/random always blocks when the input pool entropy estimate is low. This is highly criticized in most security communities.
Mac OS X and iOS have implemented the FreeBSD CSPRNG, of which /dev/random is a symlink to /dev/urandom. The CSPRNG blocks on boot until it's sufficiently seeded with hardware timing events. Once seeded, it never blocks again.
On NetBSD, /dev/random sometimes blocks, although not as notoriously as Linux. However, it will fully block on boot until sufficiently seeded, after which it no longer blocks.
OpenBSD also provides no functional difference between /dev/random and /dev/urandom. Both will block until sufficiently seeded.
As far as I know, on every Unix-like operating system, data is saved from the generator to disk on shutdown, and on boot, that data is read into the CSPRNG as an unpredictable seed. With every GNU/Linux operating system I can think of, this happens as part of the install, so on first boot, the kernel is already sufficiently seeded with random data.
On FreeBSD, this seed is saved to "/var/db/entropy-file". On GNU/Linux, either "/var/lib/systemd/random-seed" or "/var/lib/urandom/random-seed" depending on whether or not you're using systemd. I'm not sure of NetBSD saves a seed to disk or not, as it's been many years since I've last run NetBSD seriously.
- JdeBP 9y agoThe saved seed file on OpenBSD is /etc/random.seed . NetBSD has the /etc/rc.d/random_seed service, which uses the same filename as FreeBSD.