Major upgrade to FreeBSD’s /dev/random
svnweb.freebsd.org
svnweb.freebsd.org
Together with his appearance here on HN, I very much doubt he's going to change his position anytime soon.
He thinks the criticism of Linux's random device is purely academic. Maybe he's right, he's certainly way better qualified than I am, but I'm still very unimpressed by how the Linux guys just dismiss any discussion for a changed random device.
Well, they implemented getrandom quickly. Let's take it as a promising sign.
"A read from the /dev/urandom device will not block waiting for more entropy."
In fact, there seem to be some strange ideas about urandom floating around on the internet. For example, from http://stackoverflow.com/questions/3690273/did-i-understand-...
The entropy pool and blocking read of /dev/random is used as a safe-guard to ensure the impossibility of predicting the random number; if, for example, an attacker exhausted the entropy pool of a system, it is probable, though highly unlikely with today's technology, that he can predict the output of /dev/urandom which hasn't been reseeded for a long time (though doing that would also require the attacker to exhaust the system's ability to collect more entropies, which is also astronomically improbably).
This implies that urandom needs to be "reseeded" periodically in order to maintain its security.
My understanding is that if urandom has been seeded with 256 bits of entropy, then it's impossible for any attacker to ever predict urandom in any circumstance. If you don't know the seed, then predicting urandom is as impossible as decrypting AES-256 ciphertext that was encrypted with a random 256-bit key. Which is to say, computationally infeasible.
Is that correct? If so, what sort of C code or startup shell script would you recommend running in order to ensure 256 bits of entropy have been collected by the kernel and used as a seed for urandom?
Think about this for a moment: whoever wrote the /dev/random manual page seems to simultaneously believe that
(1) we can't figure out how to deterministically expand one 256-bit /dev/random output into an endless stream of unpredictable keys (this is what we need from urandom), but
(2) we _can_ figure out how to use a single key to safely encrypt many messages (this is what we need from SSL, PGP, etc.).
For a cryptographer this doesn't even pass the laugh test.
See also his recent blog post [2].
[1] http://www.mail-archive.com/cryptography@randombit.net/msg04...
That's great.
(Academic ref: http://www.ieee-security.org/TC/SP2014/papers/Not-So-RandomN...)
http://sockpuppet.org/blog/2014/02/25/safely-generate-random...
The system call interface Linux is pursuing is better than random(4) on any platform; random generation should be a system call and not a device.
> FreeBSD’s kernel crypto RNG doesn’t block regardless of whether you use /dev/random or urandom. Unless it hasn’t been seeded, in which case both block. This behavior, unlike Linux’s, makes sense. Linux should adopt it.
The system call is arguably better, sure, but it should also be quite possible to fix /dev/urandom to just block when unseeded so we can finally put this issue to rest.
EDIT: this is in 3.17, so it will be a while before it is commonly available.
Documented in: https://lwn.net/Articles/605828/
See this paper for further details: https://factorable.net/weakkeys12.extended.pdf
This has been a huge problem in the embedded device world. We need something reliably secure, not just secure after a while. /dev/urandom does not fit this criteria. Currently the best reliable option for Linux applications is to seed a CSPRNG from /dev/random and run it in usermode. Which can also be quite error prone. This is why I think this syscall is a very good improvement over the current state of things.
You don't have to take my word for it; look at the design of the Nacl library --- that's Bernstein, Schwabe, and Lange --- for an example of "just use urandom".
Sure, /dev/urandom is a good general strategy, I'm not disagreeing with you there, but it's not perfect and it very easily could be made better by simply blocking when needed to gather more entropy. getrandom() seems like a much better solution, providing an RNG without these idiosyncrasies.
Patching /dev/urandom to block if it's not seeded on boot seems like a winning strategy to me. Why aren't we doing that?