views:

333

answers:

5

I made a tongue-in-cheek comment to this question about making a hardware RNG.

Does anyone know of any simple plans or can anyone descibe a simple hardware based RNG and the software to drive it?

Go to Radio Shack. Buy a diode, an NTR resistor, a capacitor and serial cable. Cut off the end of the serial cable that does not fit on your computer. Solder the diode and resistor in series between pins DTR and DSR of the cable. Solder the capacitor between DSR and TXD pins. Write a small C program to do the following: Set DTR to 1. Start Timer. Monitor DSR until it goes to 1. Stop Timer. Calculate resistance from elapsed time. Retreive serveral bits from that value to use as part of random number. Repeat until enough bits have accumulated.

+2  A: 

If you have a Linux box, you already have /dev/random.

S.Lott
this is not a bad answer. /dev/random picks random bits from real-world unpredictable sources, like keyboard/network timings. if you have a VIA processor, it uses the included quantum-noise RNG
Javier
The only drawback is: if you have no reliable source of entropy that the kernel knows about, then reading on this can easily block. And the worst thing: it usually only blocks under heavy load when you need lots of entropy, so you can easily miss it when testing.
Joachim Sauer
+2  A: 

Diode shot-noise is pretty good. Amplify, A/D convert and sample.

Dave Gamble
Use the sound input if you need a quick-n-dirty A/D.
Mark Ransom
And debias the input.
Yann Ramin
+1  A: 

Some server motherboards already have hardware random number generators (intel make some). This is not a joke.

Tim Williscroft
This was only one the i820 series chipsets, which are long obsolete.
Yann Ramin
VIA and AMD also shipped (might still do) hardware RNG's. The VIA one is simple and described over at wikipedia: hardware random number generator
Tim Williscroft
+1  A: 

Indeed not a joke:

(from Wikipedia)

"The Intel 80802 Firmware Hub chip included a hardware RNG using two free running oscillators, one fast and one slow. A thermal noise source (non-commonmode noise from two diodes) is used to modulate the frequency of the slow oscillator, which then triggers a measurement of the fast oscillator. That output is then debiased using a von Neumann type decorrelation step (see below). The output rate of this device is somewhat less than 100,000 bit/s. This chip was an optional component of the 840 chipset family that supported an earlier Intel bus. It is not included in modern PCs.

All VIA C3 microprocessors have included a hardware RNG on the processor chip since 2003. Instead of using thermal noise, raw bits are generated by using four freerunning oscillators which are designed to run at different rates. The output of two are XORed to control the bias on a third oscillator, whose output clocks the output of the fourth oscillator to produce the raw bit. Minor variations in temperature, silicon characteristics, and local electrical conditions cause continuing oscillator speed variations and thus produce the entropy of the raw bits. To further ensure randomness, there are actually two such RNGs on each chip, each positioned in different environments and rotated on the silicon. The final output is a mix of these two generators. The raw output rate is tens to hundreds of megabits per second, and the whitened rate is a few megabits per second. User software can access the generated random bit stream using new non-privileged machine language instructions."

Cahit
A: 

No matter your external source, you need to be very careful attention to debiasing the output of the generator, and doing continuous tests to ensure your generator hasn't started oscillating in a periodic fashion for any number of reasons. FIPS 140 contains some guidelines.

Here is an example project using reverse biased transistors. I recommend using 2n4124 parts which can be driven at about 9.6V (+5V USB, doubled, schottky diode) for optimum results.

Yann Ramin