Myths about /dev/urandom
Note from 2024: This article was published on March 16th, 2014 . It is still correct in its discussion of entropy and randomness, but the Linux kernel random number generator has been reworked several times since then and does not look like this anymore. Good news: the separation between /dev/urandom and /dev/random is practically gone.
There are a few things about /dev/urandom and /dev/random that are repeated again and again. Still they are false.
I’m mostly talking about reasonably recent Linux systems, not other UNIX-like systems.
/dev/urandom is insecure. Always use /dev/random for cryptographic purposes.
Fact: /dev/urandom is the preferred source of cryptographic randomness on UNIX-like systems.
/dev/urandom is a pseudo random number generator, a PRNG, while /dev/random is a “true” random number generator.
Fact: Both /dev/urandom and /dev/random are using the exact same CSPRNG (a cryptographically secure pseudorandom number generator). They only differ in very few ways that have nothing to do with “true” randomness.
/dev/random is unambiguously the better choice for cryptography. Even if /dev/urandom were comparably secure, there’s no reason to choose the latter.
Fact: /dev/random has a very nasty problem: it blocks.
... continue reading