# Adding entropy to /dev/random

### A hard RNG is good to find

The recent statistical analysis for drumbeat reminded me I could do with a proper source of random numbers, not generated by a pseudorandom feedback action. Back in the early 1990s I was looking at statistical profiling of execution on microcontrollers, I was surprised then to discover that only by making the sampling period random could I get a true picture of execution distribution. If the address bus was sampled at a fixed rate, say 100kHz, instead of a true picture it would be distorted by activity that was happening at some fraction or harmonic of the sampling frequency. So you would alias out pieces of loops completely or get a bloated count for other areas. Only by true randomness in the sampling timing could you see the reality -- a paradox.### Analogue RNG methodologies

A Google or two around showed that most of the techniques are analogue one way or the other. Many of the methods suffer from a problematic need to amplify some very tiny source of noise, a Zener diode or avalanche transistor junction, by really huge amounts, 90dB or more. There are a couple of suppliers of RF "noise diodes" with flat spectra across a wide frequency range, but they are hard to source.### Digital non-pseudorandom technique

However there is one technique which while still relying on analogue noise is basically digital -- to run multiple chains of unlocked inverting oscillators and xor the outputs. The unlocked oscillators have no reference at all, they're basically an inverter fed back on its own input -- in fact a chain of inverters. Such a circuit oscillates according to the period of the total delay through the inverter chain... and that is highly sensitive to temperature. Normally with synchronous digital design we choose a clock rate for a circuit that is just below the maximum possible at the worst temperature it is expected to operate at -- and after that we can forget about temperature. But with this asynchronous unlocked oscillator concept, the micro- and macro- temperature dependence is revealed in all its freaky glory, causing the oscillation to drift unpredictably slightly every cycle and over larger period with gross temperature fluctuations.### RFC4086

RFC4086 mentions a recommendation for a RNG based on unlocked inverter chains that is found in IEEE 802.11i.This has three unlocked, wandering oscillator chains of different lengths being summed at an XOR gate.|\ |\ |\ +-->| >0-->| >0-- 19 total --| >0--+-------+ | |/ |/ |/ | | | | | +----------------------------------+ V +-----+ |\ |\ |\ | | output +-->| >0-->| >0-- 23 total --| >0--+--->| XOR |------> | |/ |/ |/ | | | | | +-----+ +----------------------------------+ ^ ^ | | |\ |\ |\ | | +-->| >0-->| >0-- 29 total --| >0--+------+ | | |/ |/ |/ | | | | | +----------------------------------+ | | Other randomness, if available ---------+