Depending on kernel version, Linux implements add_disk_randomness()
, add_input_randomness()
, and add_interrupt_randomness()
as entropy sources. These correspond to Disk I/O events, Keyboard and Mouse Events, and Interrupt (IRQ) events. See random.c for exact implementation. These sources conditioned, mixed, and stored internally and used to feed blocking /dev/random
and non-blocking /dev/urandom
drivers. In this case, non-blocking means that a call to /dev/urandom
will always produce output even if the entropy pool contains no entropy. However unlikely, /dev/urandom
use can lead to low-entropy seeding and predictable deterministic RNG. This in turn can lead to broken crypto with RSA being especially vulnerable to low-entropy conditions. So you shouldn't use /dev/urandom
for cryptography. However, boot time /dev/urandom
entropy is persistently problematic on headless systems and would require additional entropy sources to operate correctly.
Easiest solution to insufficient boot entropy is to enable RdRand
(or RdSeed
) via hw_rand
, but that requires trusting Intel (and now AMD) black-box implementation. If you happen to use QorlQ then there is an equivalent SEC functionality.
Alternatively, there are software true(?) random number generators that you can implement. My recommendation is CPU Time Jitter by Stephan Muller as it is a well-documented design and easy to integrate with existing system. Keep in mind, it must be compiled without optimizations for maximum entropy results.
urandom
? It seems to do exactly what you need. – Marco Oct 13 '13 at 12:57/dev/urandom
solves the problem, I just want to know if I can feed /dev/random with disk reads, keystrokes, mouse movements etc. Just curious – Aman Gupta Oct 13 '13 at 13:14add_keystroke_randomness
inside/linux/random.h
. So there can be a way to say simulate the entire works of shakesphere as a background process by calling that function in turn adding entropy to/dev/random
– Aman Gupta Oct 13 '13 at 13:49/dev/random
, no? – frostschutz Oct 13 '13 at 13:58