|
|
![]() |
||||
|
|
|
|
|
|
Without input from external devices, a computer cannot get random data. There are methods to generate psuedo-random data and even seed the generator to give different sets of random data. But most of these systems are very easy to attack. The data is often predictable or simple attacks can be launched to guess the initializing state of the generator and recreate an entire sessions worth of data. Getting truly random data into a computer is practically impossible because outside the computer it's hard to get such data. But we can get fairly good random data-- good enough so it couldn't be guessed or predictions made about it. There are several ways to get random data from the outside world though various input devices: keyboard, mouse, hard drives, microphones, ect. Probably the easiest method to acquire external random data is from the keyboard. Everyone has a keyboard and most programs require keys to be pressed during operation of the program. Therefore, this is a source of random data that may not require any extra steps. One could try and have a user press keys at random and use which keys they press as the random data source. But that is actually rather predictable. Try typing in a bunch of random characters sometime and look at the frequency of each character typed. You will likely find certain keys are pressed much more often than others. So using which keys pressed is not a good source for random data. However, using time between key presses is a good source for random data. There is always delay between key presses when someone types. Even a very good typist can not type at a perfect rate. We can use this to our advantage. A simple loop like this can be used to measure the delay between key presses: function GetChar : char; var RandomData : byte; begin RandomData := 0; while not KeyPressed do Inc( RandomData ); { Pass random data to generator } GetChar
:= ReadKey; As you see, 'RandomData' is a number that is continuously
incremented while waiting for a key to be pressed. It is an 8-bit
number and so it will reset to zero after 256 increments. This is
useful because most computers can run this loop at great speeds and the
counter will reset a great number of times before a key press is registered.
When the key stroke is registered, the number in 'RandomData'
is anyone's guess-- precisely what we are looking for. So, using
this function will generate 8-bits of random data for every key pressed.
If someone uses a 20 character passphrase, that is 160-bits of good random
data generated.
|