Path: cactus.org!milano!cs.utexas.edu!uunet!comp.vuw.ac.nz!waikato.ac.nz!
+     aukuni.ac.nz!cs18.cs.aukuni.ac.nz!pgut1
Newsgroups: sci.crypt

Subject: Simple hardware RNG
Message-ID: <1992Oct22.070717.28400@cs.aukuni.ac.nz>
From: pgut1@cs.aukuni.ac.nz (Peter Gutmann)
Date: Thu, 22 Oct 1992 07:07:17 GMT
Organization: Computer Science Dept. University of Auckland
Lines: 92

The following is a simple hardware noise generator which you can throw together
using junk box parts in about 10 minutes.  It's based on thermal noise in a
zener diode, and is powered by its own supply to reduce the chance of noise
from the computers supply being coupled in.

There are three stages to the circuit:

1. The noise generator, a reverse-biased zener.  The random motion of
   electrons inside it causes random fluctuations in the voltage across it.
   I had a BZX85 9V1 zener so I used that (or at least that's what I assume it
   is - the lettering's worn off).  You could probably use a special noise
   diode if you can find one.  A quick flip through about 2 feet of suppliers
   catalogues hasn't turned up anything, and even then they're probably just
   std. diodes which have passed some sort of noise certifying test.

2. An amplifier for the diode noise.  The output from the zener is fairly low-
   level, so I fed it through an op-amp.  The diode noise is fed in through a 
   0.1uF capacitor to the 741, which is set up as a differential amplifier, ie
   one which amplifies the difference in the signals at its two inputs.

3. A pulse shaper to get a nice square wave from the noise output of the 741,
   fed in via another 0.1uF capacitor.  You can use anything here, a schmitt
   trigger or some sort of buffer - I ripped a 4049 out of a logic probe.
   You can just use anything that can be wired up to buffer/clean up a signal.

Here's the circuit diagram ("schematic" to US people):

+9V
 O-o----o-----------------------+
   |    |                       |                 Res.
   |   Res.                     |            +-- 8.2M --+
   |   100k                     |            |          |       Schmitt trigger
   |    |   Zener        Cap.   |      Res.  |  |\      |             or
  Res.  o--|BZY88<--o-- 0.1uF --)----- 10k --o--|- \    |    Cap.   Buffer
  10k   |    9V1    |           |               |Op- \--o-- 0.1uF ----|>----o-O
   |   Cap.        Res.        Pot.    Res.     |amp /                      |
   |  0.1uF        68k         10k <-- 10k -----|+ /                  BZY88 5V1
0V |    |           |           |               |/                          |
 O-o----)-----------)-----------)-------------------------------------------o-O
   |    |           |           |
  Res.  |           |           |              eg 741           eg 2 inverters
  10k   |           |           |                                 from 4049
   |    |           |           |
 O-o----o-----------o-----------+
-9V

The component values are very noncritical - I had a batch of 10k resistors left
over from an R-2R D/A converter (not that you can tell from looking at the
circuit :-), as well as a generic boxfull of 0.1uF decoupling capacitors.  The
op-amp used was a 741, the buffer was two gates from a 4049 but you could wire
in just about anything.

If you were feeling really paranoid about noise from the computer PSU getting
into the circuit, you could feed the final signal through an optocoupler.  I
just clipped it at 5V and fed it into the printer port "Ready" input.  You
could probably get away with the 9V driving one of the serial port handshaking
signals if you don't have a printer port.

Ideally the generator should be powered by two 9V batteries.  I never have any
that aren't flat so I used a conventional mains power supply.

The only thing which needs adjusting is the duty cycle, which can be changed by
varying the 10k pot.  If you've got one, you can hook an oscilloscope to the
output of the op-amp and check for a 50/50 duty cycle.  However a much more
precise measurement can be made by hooking the thing to your computer and
timing the duty cycle.  The control afforded by the pot is a bit rough, it may
be better to substitute a multiturn one for better control.  However the final
product will still drift a bit with temperature.  It's probably easier to
compensate in software for any bias or drift in the signal.  Alternatively you
could take advantage of the fact that buffers come six to a chip (4050) and use
an LM348 (quad 741) to get 4 bits at a time, with one bit in each pair set up
to cancel the bias on the second bit.  If you were feeling really ambitious you
could get an octal buffer and two 348's and generate a byte at a time.

As to the performance of the circuit, for it's simplicity it performs amazingly
well.  It may not use a NIST-certified noise generator, but it is a reasonably
good random noise generator, provided it's driven off it's own power supply,
has compensation for bias in the duty cycle, and possibly an optocoupler in the
output.

If anyone has any comments or improvements I'd be interested in hearing from
them.  I'm also interested in any construction hints people have, or comments
on important details I've neglected to mention, or alternative components which
can be used - I've assumed some knowledge of electronics for this, I wasn't
quite sure what level to pitch it at.  Finally, if anyone builds one of the
more ambitious setups (4 or 8 bits at a time) I'd be interested in what sort of
results they give.

Peter.
--
    pgut1@cs.aukuni.ac.nz || peterg@kcbbs.gen.nz || peter@nacjack.gen.nz
			  (In order of preference)