Applications can then check if the kernel is ready to do RNG and if not, handle the delay themselves.
But I guess that would break some applications so there might be another way (extra device for early boot randomness? ioctl?)
Applications can then check if the kernel is ready to do RNG and if not, handle the delay themselves.
But I guess that would break some applications so there might be another way (extra device for early boot randomness? ioctl?)
The proper fix is to change the boot scripts to not assume that the CRNG will be available directly after boot.
..for you. Other people have a different threat model where availability is ranked above RNG strength in the first minute of booting. Making security decisions not based on any sort of threat model considerations is zealotry/cargo-culting, IMO.
Above all else, the rule is that the kernel shouldn't cause userspace regressions. Something that works now must continue working later.
Atleast from what I know.
After seeding, there is no point in blocking on a lack of entropy, which is why it is recommended to use /dev/urandom in the first place.
So getrandom(2) will block until the pool is seeded, and all newly written application should use it, and existing applications should switch to it. But you still need to try to lazily generated random keys, and think very hard about whether you really need to generate cryptographic grade random numbers before the user logs in.
E.g., if on a platform with a hardware RNG then it should never be necessary to block: just read 128 bits out of the hardware RNG & generate a stream of random numbers.
On a platform without a hardware RNG, could one require a previous seed? An installer could install the seed in some persistent storage somewhere, so there's no need to do this even on boot. A VM system needs someway to atomically read the seed & then write a new seed.
On a platform without a hardware RNG and without a previous seed (i.e., the very first boot after a hand-install or something), could the system require the user to type keys until it has collected 128 bits of entropy?
I'm not certain if there's a good answer on systems with no hardware RNG, no previous seed and no input capability. Maybe CPU timing loops or somesuch?
It'd be also be nice were there a filesystem interface to getrandom(2) …
Requiring a previous seed requires a way to get access to the seed, early enough in the boot that it is available to kernel users who are trying to use randomness for address space randomization and for stack canaries. But in early boot the kernel may not be sufficiently initialized to read from persistent storage, and there are many, many bootloaders.
The reason why there is no file system interface to getrandom(2) is that a file system interface is subject to file descriptor exhaustion attacks. It was OpenBSD which designed the getentropy(2) system call, and getrandom(2) was modelled after it. Basically, getrandom(2) is getentropy(2) with an extra flags parameter added.
Typically, the crypto is needed for network communication. It can provide some randomness too...
https://lists.freedesktop.org/archives/systemd-devel/2018-Ma...