Linux – the correct available entropy on UNIX systems

linuxrandom

I have three questions related to entropy on UNIX systems:

  1. I check entropy on Linux using: cat /proc/sys/kernel/random/entropy_avail. Is this the standard place with information about available entropy defined in POSIX?
  2. What is the correct available I should expect? I heard that entropy should be equal or more than 100 and that there may be a problem if entropy is constantly below 100.
  3. Is this entropy used by /dev/random or does it also has anything to do with /dev/urandom?

Best Answer

/dev/random is not standardized. POSIX doesn't provide any way of generating cryptographically secure random data and doesn't have any notion of entropy.

The Linux kernel's entropy calculation corresponds to an information-theoretic model of entropy which is not relevant to practical use. The only case where this is relevant is on a new device which has never had time to accumulate entropy (this includes live distributions; installed systems save their entropy from one boot to the next). Apart from this situation, there is always enough entropy, because entropy does not deplete. Since Linux's /dev/random blocks when it thinks it doesn't have enough entropy, use /dev/urandom, which never blocks. Using /dev/urandom is good for everything including generating cryptographic keys (except, as mentioned above, on a freshly minted device).

In summary:

  1. No, this is not standard.
  2. You don't care.
  3. Use /dev/urandom.

Many, but not all unix systems have /dev/urandom and /dev/random. See the Wikipedia page for a more detailed discussion.

Related Question