Clock Drift - Random Number Generators

Random Number Generators

See also: Hardware random number generator#Clock drift

Computer programs often need high quality random numbers, especially for cryptography. There are several similar ways clock drift can be used to build random number generators (RNGs).

One way to build a hardware random number generator is to use two independent clock crystals, one that for instance ticks 100 times per second and one that ticks 1 million times per second. On average the faster crystal will then tick 10,000 times for each time the slower one ticks. But since clock crystals are not precise, the exact number of ticks will vary. That variation can be used to create random bits. For instance, if the number of fast ticks is even, a 0 is chosen, and if the number of ticks is odd, a 1 is chosen. Thus such a 100/1000000 RNG circuit can produce 100 somewhat random bits per second. Typically such a system is biased—it might for instance produce more zeros than ones—and so hundreds of somewhat-random bits are "whitened" to produce a few unbiased bits.

There is also a similar way to build a kind of "software random number generator". This involves comparing the timer tick of the operating system (the tick that usually is 100–1000 times per second) and the speed of the CPU. If the OS timer and the CPU run on two independent clock crystals the situation is ideal and more or less the same as the previous example. But even if they both use the same clock crystal the process/program that does the clock drift measurement is "disturbed" by many more or less unpredictable events in the CPU such as interrupts and other processes and programs that runs at the same time. Thus the measurement will still produce fairly good random numbers. Some argue they are then not true random numbers but they seem to be good enough for most needs.

Note that most hardware random number generators such as the ones described above are fairly slow. Therefore most programs only use them to create a good seed that they then feed to a pseudorandom number generator or a cryptographically secure pseudorandom number generator to produce many random numbers fast.

Read more about this topic:  Clock Drift

Famous quotes containing the words random and/or number:

    We should stop looking to law to provide the final answer.... Law cannot save us from ourselves.... We have to go out and try to accomplish our goals and resolve disagreements by doing what we think is right. That energy and resourcefulness, not millions of legal cubicles, is what was great about America. Let judgment and personal conviction be important again.
    Philip K. Howard, U.S. lawyer. The Death of Common Sense: How Law Is Suffocating America, pp. 186-87, Random House (1994)

    At thirty years a woman asks her lover to give her back the esteem she has forfeited for his sake; she lives only for him, her thoughts are full of his future, he must have a great career, she bids him make it glorious; she can obey, entreat, command, humble herself, or rise in pride; times without number she brings comfort when a young girl can only make moan.
    Honoré De Balzac (1799–1850)