Everything2
Near Matches
Ignore Exact
Full Text
Everything2

/dev/random

"/dev/random" is also a: user

created by SiliconJesus

(thing) by randombit (2.2 hr) (print)   ?   (I like it!) 1 C! Sun Jun 08 2003 at 17:58:33

The pseudo-device /dev/random exists due to a collision between modern networks, and the historical design of the Unix operating system. First, we assume that the users of a system need cryptography, either in a form they use directly (ie, PGP), or that the system uses on their behalf (SSL and IPSec). All such cryptography requires the generation of a large amount of random or pseudo-random bits. There are other uses for such random bits, but these are few and far between, and /dev/random was initially designed for crypto, which is why it tries so hard to be cryptographically secure.

As computers are mostly deterministic, it is very hard to generate entropy without interacting with something analog (like a user, or a free-running oscillator). Often these are not available (consider, for example, a web server farm), and even if they are, Unix helpfully prevents us from talking to them directly. For example, Unix ttys are almost always in "cooked" mode, meaning you can't get useful timing information from typing like the old PGP versions used - there are multiple levels of indirection between the keyboard and your program. This type of layering also makes it hard to get useful entropy from packet arrival times, mouse movements, and so on - at least, from userspace.

Thus, in 1994 noted Linux kernel hacker Theodore Ts'o wrote a driver for Linux, which takes information about hard to predict events like keyboard and mouse use, packet and disk drive timings, and so on, and uses it to seed a cryptographically secure random number generator. A process can then open up the 'file' /dev/random (usually a character device), and read out random bytes. The driver keeps an estimate of how much entropy remains in the pool - if it goes below 0 then any reads will block until more entropy is added. This driver is primarily useful for authors of serious crypto software, though many other applications (like Perl) have been known to take a bit or two now and then.

The /dev/random driver was quickly ported to the open source BSD systems, and is also included in MacOS X (not surprising, as OS X is a BSD derivative). Oct 3, 2003: I have now found out that it is also included by default in new versions of Solaris, IRIX, AIX, and HP-UX. This essentially covers all of the Unix variants likely to exist within 5 years (compare with UnixWare, Tru64, etc).

Even MS-DOS has an (third party) implementation of it, apparently. A common alternative to /dev/random on other systems is EGD, though I figure within 5 years 90% of Unix systems will have a /dev/random, from increasing Linux/*BSD use, and others adopting the idea for their own systems. (10/2/03: I was right!)

For those unfamiliar with Unix device semantics, I'll point out that /dev/random is actually just the usual file system name used to access this driver - there is nothing intrinsic about the string /dev/random that makes it generate random bytes (one could easily swap /dev/zero and /dev/random - good times!).

The actual driver is implemented in drivers/char/random.c in the Linux source tree.


printable version
chaos

Compromising /dev/random /dev/full catting weird things to /dev/audio random number generator
entropy pool /dev/null Using /dev/audio to eavesdrop Ways to get random numbers
cp /dev/zero /dev/null /dev/tty /dev/zero Mac OS
EGD What do guys think of girls who hook up with pseudo-random guys? /dev Quantum Weather Butterfly
cat /proc/kcore > /dev/dsp0 Brak Presents The Brak Show Starring Brak pi cat /dev/whoop-ass
Pseudorandom number generator pseudo-random Top 100 countries ranked by population You're running Linux on what?
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
After stirring Everything, these nodes rose to the top:
Destruction of Syntax - Imagination without Strings - Words-in-Freedom
Nazca Lines
Steve Jobs
The Young Americans
Love is not an emotion
Claude Lévi-Strauss
The Eugenics Problem
George Grosz
A sandwich is not a sammich
Between the Testaments - The Hellenistic Period
Thanks from our Hearts
Matt Drudge
Stuffed full o' Nodes Day 2004
New Writeups
Glowing Fish
Tualatin River(place)
The Jacket
Words of Advice(idea)
keepinitreal
Why buy the cow when you can get the milk for free?(idea)
John_Fox
Good Intentions Gone Wrong(person)
Cuckowski
Slavonic Princess(poetry)
Heitah
Posthumous Oscar(thing)
ignis_glaciesque
University of South Florida(place)
ignis_glaciesque
Flogstaskriket(idea)
liveforever
Caesar's last breath(idea)
dagnyswaggart
she wants to believe(personal)
antigravpussy
he doesn't know, but her eyes widen too far(thing)
dagnyswaggart
Wild tides guard her secrets(poetry)
Lord Brawl
Caesar's last breath(poetry)
locke baron
Forgotten things in space(fiction)
sitaraika
Colours(idea)
This page courtesy of The Everything Development Company