Ubuntu – How is entropy gathered for /dev/random in Precise

12.04deviceskernelsource code

With a standard install of Ubuntu 12.04 how is the entropy for /dev/random gathered.

Is the install smart enough set up any hardware generation available, will it use user based sources like keyboard interupts by default?

Edit: Just to be clear, I'm looking for the specific configuration that comes with the install (or how to find it), I'm not looking how it might be done in theory.

Best Answer

This is complicated question. I will answer by quoting from few sources.

From Linux manpage

The character special files /dev/random and /dev/urandom (present since Linux 1.3.30) provide an interface to the kernel's random number generator. File /dev/random has major device number 1 and minor device number 8. File /dev/urandom has major device number 1 and minor device number 9.

The random number generator gathers environmental noise from device drivers and other sources into an entropy pool. The generator also keeps an estimate of the number of bits of noise in the entropy pool. From this entropy pool random numbers are created.

In Ubuntu 12.04 default kernel is 3.11.

From wiki

The Linux kernel generates entropy from keyboard timings, mouse movements, and IDE timings and makes the random character data available to other operating system processes through the special files /dev/random and /dev/urandom. This capability was introduced in Linux version 1.3.30.

From Linux manpage

When read, the /dev/random device will only return random bytes within the estimated number of bits of noise in the entropy pool. /dev/random should be suitable for uses that need very high quality randomness such as one-time pad or key generation. When the entropy pool is empty, reads from /dev/random will block until additional environmental noise is gathered.

Quote from random sources, from kernel 3.11.10.10

 * Theory of operation
 * ===================
 *
 * Computers are very predictable devices.  Hence it is extremely hard
 * to produce truly random numbers on a computer --- as opposed to
 * pseudo-random numbers, which can easily generated by using a
 * algorithm.  Unfortunately, it is very easy for attackers to guess
 * the sequence of pseudo-random number generators, and for some
 * applications this is not acceptable.  So instead, we must try to
 * gather "environmental noise" from the computer's environment, which
 * must be hard for outside attackers to observe, and use that to
 * generate random numbers.  In a Unix environment, this is best done
 * from inside the kernel.
 *
 * Sources of randomness from the environment include inter-keyboard
 * timings, inter-interrupt timings from some interrupts, and other
 * events which are both (a) non-deterministic and (b) hard for an
 * outside observer to measure.  Randomness from these sources are
 * added to an "entropy pool", which is mixed using a CRC-like function.
 * This is not cryptographically strong, but it is adequate assuming
 * the randomness is not chosen maliciously, and it is fast enough that
 * the overhead of doing it on every interrupt is very reasonable.
 * As random bytes are mixed into the entropy pool, the routines keep
 * an *estimate* of how many bits of randomness have been stored into
 * the random number generator's internal state.

Yes it is smart enough to use user based sources, but you can configure more if you want.

There are kernels with random generators that have more entropy sources such including noise on audio inputs and others like video, coolers censors, etc. Look here if interesting in audio entropy. I hope you will find others kernels by yourself.

But /dev/random should be enough for most tasks by default.

Also read this question on stackoverflow

Related Question