Description
The crate's documentation says:
We always choose failure over returning insecure “random” bytes.
And it calls out NetBSD as an example of a platform where it chooses to block rather than fail when the system CSPRNG isn't fully seeded.
However, the NetBSD sysctl(7) man page linked to in the docs says this:
kern.arandom (KERN_ARND)
Returns independent uniformly distributed bytes at random each
time, as many as requested up to 256, derived from the system
entropy pool; see rnd(4).
Reading kern.arandom is equivalent to reading up to 256 bytes at
a time from /dev/urandom: reading kern.arandom never blocks, and
once the system entropy pool has full entropy, output subse-
quently read from kern.arandom is fit for use as cryptographic
key material. For example, the arc4random(3) library routine
uses kern.arandom internally to seed a cryptographic pseudorandom
number generator.
This doesn't sound like it provides the same guarantees this crate aims to provide.
If the maintainers here agree, it might be wise to replace the kern.arandom path with a Linux-like path that polls /dev/random before reading from /dev/urandom, and enable the getrandom path for a first choice on NetBSD when 10.0 comes out (or maybe immediately?). But I can see that the crate was actually switched away from that exact strategy in #115 because it drained /dev/random. (I didn't know poll did that! That's very unfortunate.)
If the crate's contract isn't being upheld on NetBSD (and FreeBSD where getrandom isn't available), that seems like too big a problem to ignore. It might be a good idea to talk to the NetBSD developers about this, since they're the ones who had trouble with the old strategy and might have insight into alternatives and whether this is a real problem in the first place... I'll ping @alarixnia, since they submitted #115.