by nodesocket · 11y ago · 0 comments
When in doubt, use unix, and <updated>/dev/urandom</updated>
Also, here is a command (to my knowledge secure) which generates a nice random 20 length alphanumeric:
LC_CTYPE=C < /dev/urandom tr -dc A-Za-z0-9 | head -c20/dev/urandom is the same cryptographically secure PRNG as /dev/random, except that /dev/random will superstitiously block when it thinks entropy has been "consumed". (CSPRNGs do not meaningfully "consume" entropy.)
If you use /dev/random for the mythical warm fuzzies, you might also be misunderstanding other things. Don't be superstitious. Use /dev/urandom.
[1] http://www.2uo.de/myths-about-urandom/
[2] http://www.mail-archive.com/cryptography@randombit.net/msg04...
[0] Technically, it is correct to say that we do consume entropy in an information theoretic sense. However, this is not particularly revelent, as the CSPRNG is still (believed to be) secure in a complexity theoretic sense. If it turns out that the CSPRNG is not secure in a complexity theoretic sense, then we have bigger issues to worry about then a broken RNG.
Also, you mixed up random and urandom, but no matter. People should not code for the case where their distribution's boot sequence totally fucks up.
There are no security concerns with /dev/urandom
In brief, wifi routers need to generate unique crypto keys. The programmers started off using /dev/random, observed that blocking, and switched to /dev/urandom. The problem was that they were generating the keys at first boot, before any entropy had accumulated, with the result that many, many devices wound up with similar or identical keys.
The right answer is Linux's new getrandom syscall, whose default mode "blocks if the entropy pool has not yet been initialized", but thereafter acts like /dev/urandom. But on systems where that syscall is not available, I'm skeptical that using /dev/urandom is sane design.