How can I check for available entropy?

Solution 1:

This is not a solution, but a clarification of how entropy is gathered and used in Linux.

Linux actually has two different entropy pools:

/dev/random and /dev/urandom.

The former is a true random pool, fed by system entropy sources.
The latter is more of a PRNG such as those found on the BSD's and OS X.

However, even urandom requires a seed of 'real' random entropy in order to produce quality pseudo-random data. On recent kernels, a complete lack of entropy in /dev/random will still not block urandom, but urandom will re-use the last valid seed until more entropy becomes available. Because urandom is nonblocking, most services that require a steady stream of entropy use it rather than relying on /dev/random.

There are still some services however, such as various SSL suites, which can't make do with pseudo-random entropy, but require a truly unpredictable entropy source. In this case, urandom (or any other PRNG) can't be used, and /dev/random comes into play.

Solution 2:

Mac OS X simply uses Yarrow. Even FreeBSD went further and switched to its improved version called "Fortuna".

Yarrow's strength is limited by the size of the key. For example, Yarrow-160 has an effective key size of 160 bits. If the security requires 256 bits, Yarrow-160 is not capable of doing the job.

All-in-all this is another reminder Apple's priorities don't include security/robustness or anything like this.

Solution 3:

Mac OS X, like FreeBSD, does not rely on external sources of entropy. Instead, it uses a pseudorandom number generator based on the Yarrow algorithm. Because it's using an algorithm and not an entropy pool, there's no need to make sure there's "enough" entropy - you will always be able to read from /dev/random without blocking.

So, to answer your question, unless you are "paranoid" and need to base your entropy on external sources (keystrokes/mouse movements/etc), in which case you have to do it yourself, the amount of available entropy for /dev/random use is always infinite.