Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

On linux systems, one can check for available entropy (useful to know if you're tapping /dev/random for any PRNG purposes) with

cat /proc/sys/kernel/random/entropy_avail

However, there is no equivalent of /proc on a Mac (AFAIK). How can I check for available system entropy on a Mac? I'm running OS X 10.7.3 (Lion)


To update with some of my comments under Kyle's answer — One of the reasons for Macs not displaying this information is that it isn't needed (in most cases). Linux systems will block calls to /dev/random if there isn't enough entropy in the pool. On Macs, it periodically keeps adding to the entropy pool using the SecurityServer daemon.

However, it also notes that if the daemon fails for some reason, the output quality will decline without any indication of failure:

The quality of its output is however dependent on regular addition of appropriate entropy. If the SecurityServer system daemon fails for any reason, output quality will suffer over time without any explicit indication from the random device itself.

So even though the amount of entropy is not made available easily, it doesn't mean it isn't there and there might be instances where its knowledge might be helpful.

share|improve this question
    
Do you really need to check, or just make sure there's enough stuff in there to use? See developer.apple.com/library/mac/#documentation/Darwin/Reference/… Quote: "Paranoid programmers can counteract this risk somewhat by collecting entropy of their choice (e.g. from keystroke or mouse timings) and seeding it into random directly before obtaining important random numbers." –  Chris W. Rea Mar 20 '12 at 22:03
    
I just need to make sure there's enough to use. –  rm -rf Mar 20 '12 at 22:09
add comment

2 Answers 2

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.

share|improve this answer
1  
This is not entirely correct. Using an algorithm does't make it infinite entropy. What they mean is that on Linux, it blocks when the entropy pool is low, whereas on mac: "Additional entropy is fed to the generator regularly by the SecurityServer daemon from random jitter mea surements of the kernel." So basically, it takes care of it and also saves some entropy to disk for use immediately after startup. It also says that while Yarrow is resilient, the quality is dependent on regular addition of entropy — something which won't be necessary if it were truly infinite entropy –  rm -rf Apr 2 '12 at 20:20
1  
It further says that: "If the SecurityServer system daemon fails for any reason, output quality will suffer over time without any explicit indication from the random device itself" I'll admit that OSX has made it easy to not have to worry about the actual entropy value, but doesn't mean that there isn't one... Btw, I was referring to this man page in my quotes above –  rm -rf Apr 2 '12 at 20:21
    
@R.M True, I was thinking more in terms of whether or not a call to /dev/random would block than the quality of the entropy –  Kyle Cronin Apr 2 '12 at 20:21
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.