[clug-talk] Random numbers in Linux: an example

Mark Carlson carlsonmark at gmail.com
Thu Sep 8 09:33:35 PDT 2005


Hello everybody,

This is my first email to the list, so forgive me if this is off-topic
or formatted incorrectly.

Last night at the meeting during the GPG demonstration someone asked
why you should move your mouse around during the key generation.  I
had mistakenly said that it was the standard C library that offers two
methods of obtaining random numbers.  When I got home I looked for the
functions and found out I was incorrect.  It is the kernel itself that
offers these two methods.  And if you want to check it out, it's
pretty cool (and it only takes a couple seconds to do.)

At your shell, type in the command: 
od -t x1 /dev/random

Notice that it only spits out a small amount of data (if nothing else
on your system is doing any I/O).  Now move your mouse around (from
corner to corner on your screen) or hit a bunch of keys on your
keyboard.  Hopefully there will be more data generated as you do this.

The other way of obtaining random numbers using the kernel is to get
it from /dev/urandom.  To test this out, get ready to hit Ctrl+C to
kill the program as it generates a lot of data very quickly.  Now type
into your shell:
od -t x1 /dev/urandom

Anyways, I had fun at the first meeting I attended and I hope to see
you all next month :-)

-Mark Carlson



More information about the clug-talk mailing list