Network Working Group Donald E. Eastlake, 3rd
OBSOLETES RFC 1750 Jeffrey I. Schiller
Steve Crocker
Expires Januray 2001 July 2000
Randomness Requirements for Security
---------- ------------ --- --------
Status of This Document
This document is intended to become a Best Current Practice.
Comments should be sent to the authors. Distribution is unlimited.
This document is an Internet-Draft and is in full conformance with
all provisions of Section 10 of RFC2026. Internet-Drafts are working
documents of the Internet Engineering Task Force (IETF), its areas,
and its working groups. Note that other groups may also distribute
working documents as Internet-Drafts.
Internet-Drafts are draft documents valid for a maximum of six
months. Internet-Drafts may be updated, replaced, or obsoleted by
other documents at any time. It is not appropriate to use Internet-
Drafts as reference material or to cite them other than as a
``working draft'' or ``work in progress.''
The list of current Internet-Drafts can be accessed at
http://www.ietf.org/ietf/1id-abstracts.txt
The list of Internet-Draft Shadow Directories can be accessed at
http://www.ietf.org/shadow.html.
D. Eastlake, J. Schiller, S. Crocker [Page 1]
INTERNET DRAFT Randomness Requirements for Security July 2000
Abstract
Security systems today are built on increasingly strong cryptographic
algorithms that foil pattern analysis attempts. However, the security
of these systems is dependent on generating secret quantities for
passwords, cryptographic keys, and similar quantities. The use of
pseudo-random processes to generate secret quantities can result in
pseudo-security. The sophisticated attacker of these security
systems may find it easier to reproduce the environment that produced
the secret quantities, searching the resulting small set of
possibilities, than to locate the quantities in the whole of the
number space.
Choosing random quantities to foil a resourceful and motivated
adversary is surprisingly difficult. This document points out many
pitfalls in using traditional pseudo-random number generation
techniques for choosing such quantities. It recommends the use of
truly random hardware techniques and shows that the existing hardware
on many systems can be used for this purpose. It provides
suggestions to ameliorate the problem when a hardware solution is not
available. And it gives examples of how large such quantities need
to be for some particular applications.
Acknowledgements
Special thanks to the authors of "Minimal Key Lengths for Symmetric
Ciphers to Provide Adequate Commercial Security" which is
incorporated as Appendix A.
The following persons (in alpahbetic order) contributed to RFC 1750,
the predeceasor of this document:
David M. Balenson, Don T. Davis, Carl Ellison, Marc Horowitz,
Christian Huitema, Charlie Kaufman, Steve Kent, Hal Murray, Neil
Haller, Richard Pitkin, Tim Redmond, Doug Tygar.
D. Eastlake, J. Schiller, S. Crocker [Page 2]
INTERNET DRAFT Randomness Requirements for Security July 2000
Status of This Document....................................1
Abstract...................................................2
Acknowledgements...........................................2
Table of Contents..........................................3
1. Introduction............................................5
2. Requirements............................................6
3. Traditional Pseudo-Random Sequences.....................8
4. Unpredictability.......................................10
4.1 Problems with Clocks and Serial Numbers...............10
4.2 Timing and Content of External Events.................11
4.3 The Fallacy of Complex Manipulation...................11
4.4 The Fallacy of Selection from a Large Database........12
5. Hardware for Randomness................................13
5.1 Volume Required.......................................13
5.2 Sensitivity to Skew...................................13
5.2.1 Using Stream Parity to De-Skew......................14
5.2.2 Using Transition Mappings to De-Skew................15
5.2.3 Using FFT to De-Skew................................16
5.2.4 Using Compression to De-Skew........................16
5.3 Existing Hardware Can Be Used For Randomness..........17
5.3.1 Using Existing Sound/Video Input....................17
5.3.2 Using Existing Disk Drives..........................17
6. Recommended Non-Hardware Strategy......................18
6.1 Mixing Functions......................................18
6.1.1 A Trivial Mixing Function...........................18
6.1.2 Stronger Mixing Functions...........................19
6.1.3 Diff-Hellman as a Mixing Function...................20
6.1.4 Using a Mixing Function to Stretch Random Bits......21
6.1.5 Other Factors in Choosing a Mixing Function.........21
6.2 Non-Hardware Sources of Randomness....................22
6.3 Cryptographically Strong Sequences....................23
6.3.1 Traditional Strong Sequences........................23
6.3.2 The Blum Blum Shub Sequence Generator...............24
7. Key Generation Standards...............................26
7.1 US DoD Recommendations for Password Generation........26
7.2 X9.17 Key Generation..................................26
8. Examples of Randomness Required........................28
8.1 Password Generation..................................28
D. Eastlake, J. Schiller, S. Crocker [Page 3]
INTERNET DRAFT Randomness Requirements for Security July 2000
8.2 A Very High Security Cryptographic Key................29
8.2.1 Effort per Key Trial................................29
8.2.2 Meet in the Middle Attacks..........................29
8.2.3 Other Considerations................................30
9. Conclusion.............................................32
10. Security Considerations...............................32
Appendix: Minimal Secure Key Lengths Study................33
Appendix: Abstract........................................33
A.1. Encryption Plays an Essential Role in Protecting.....34
A.1.1 There is a need for information security............34
A.1.2 Encryption to protect confidentiality...............35
A.1.3 There are a variety of attackers....................36
A.1.4 Strong encryption is not expensive..................37
A.2. Brute-Forece is becoming easier......................37
A.3. 40-Bit Key Lengths Offer Virtually No Protection.....39
A.4. Even DES with 56-Bit Keys Is Increasingly Inadequate.40
A.4.1 DES is no panacea today.............................40
A.4.2 There are smarter avenues of attack than brute force41
A.4.3 Other algorithms are similar........................41
A.5. Appropriate Key Lengths for the Future --- A Proposal42
Appendix: About the Authors...............................44
Appendix: Acknowledgement.................................45
References................................................46
Authors Addresses.........................................49
File Name and Expiration..................................49
D. Eastlake, J. Schiller, S. Crocker [Page 4]
INTERNET DRAFT Randomness Requirements for Security July 2000
1. Introduction
[Other than the addition of Appendix A, the changes in this version
from RFC 1750 are relatively minor. Comments and suggestions are
solicited.]
Software cryptography is coming into wider use. Systems like IPSEC,
TLS, S/MIME, PGP, DNSSEC, Kerberos, etc. are maturing and becoming a
part of the network landscape [DNSSEC, IPSEC, MAIL*, TLS]. By
comparison, when the previous version of this document [RFC 1750] was
issued in 1994, about the only cryptographic security specification
in the IETF was the Privacy Enhanced Mail protocol [MAIL PEM].
These systems provide substantial protection against snooping and
spoofing. However, there is a potential flaw. At the heart of all
cryptographic systems is the generation of secret, unguessable (i.e.,
random) numbers.
For the present, the lack of generally available facilities for
generating such unpredictable numbers is an open wound in the design
of cryptographic software. For the software developer who wants to
build a key or password generation procedure that runs on a wide
range of hardware, the only safe strategy so far has been to force
the local installation to supply a suitable routine to generate
random numbers. To say the least, this is an awkward, error-prone
and unpalatable solution.
It is important to keep in mind that the requirement is for data that
an adversary has a very low probability of guessing or determining.
This will fail if pseudo-random data is used which only meets
traditional statistical tests for randomness or which is based on
limited range sources, such as clocks. Frequently such random
quantities are determinable by an adversary searching through an
embarrassingly small space of possibilities.
This informational document suggests techniques for producing random
quantities that will be resistant to such attack. It recommends that
future systems include hardware random number generation or provide
access to existing hardware that can be used for this purpose. It
suggests methods for use if such hardware is not available. And it
gives some estimates of the number of random bits required for sample
applications.
D. Eastlake, J. Schiller, S. Crocker [Page 5]
INTERNET DRAFT Randomness Requirements for Security July 2000
2. Requirements
Probably the most commonly encountered randomness requirement today
is the user password. This is usually a simple character string.
Obviously, if a password can be guessed, it does not provide
security. (For re-usable passwords, it is desirable that users be
able to remember the password. This may make it advisable to use
pronounceable character strings or phrases composed on ordinary
words. But this only affects the format of the password information,
not the requirement that the password be very hard to guess.)
Many other requirements come from the cryptographic arena.
Cryptographic techniques can be used to provide a variety of services
including confidentiality and authentication. Such services are
based on quantities, traditionally called "keys", that are unknown to
and unguessable by an adversary.
In some cases, such as the use of symmetric encryption with the one
time pads [CRYPTO*] or the US Data Encryption Standard [DES], the
parties who wish to communicate confidentially and/or with
authentication must all know the same secret key. In other cases,
using what are called asymmetric or "public key" cryptographic
techniques, keys come in pairs. One key of the pair is private and
must be kept secret by one party, the other is public and can be
published to the world. It is computationally infeasible to
determine the private key from the public key. [ASYMMETRIC, CRYPTO*]
The frequency and volume of the requirement for random quantities
differs greatly for different cryptographic systems. Using pure RSA
[CRYPTO*], random quantities are required when the key pair is
generated, but thereafter any number of messages can be signed
without any further need for randomness. The public key Digital
Signature Algorithm devused by the US National Institute of Standards
and Technology (NIST) requires good random numbers for each
signature. And encrypting with a one time pad, in principle the
strongest possible encryption technique, requires a volume of
randomness equal to all the messages to be processed.
In most of these cases, an adversary can try to determine the
"secret" key by trial and error. (This is possible as long as the
key is enough smaller than the message that the correct key can be
uniquely identified.) The probability of an adversary succeeding at
this must be made acceptably low, depending on the particular
application. The size of the space the adversary must search is
related to the amount of key "information" present in the information
theoretic sense [SHANNON]. This depends on the number of different
secret values possible and the probability of each value as follows:
D. Eastlake, J. Schiller, S. Crocker [Page 6]
INTERNET DRAFT Randomness Requirements for Security July 2000
-----
\
Bits-of-info = \ - p * log ( p )
/ i 2 i
/
-----
where i varies from 1 to the number of possible secret values and p
sub i is the probability of the value numbered i. (Since p sub i is
less than one, the log will be negative so each term in the sum will
be non-negative.)
If there are 2^n different values of equal probability, then n bits
of information are present and an adversary would, on the average,
have to try half of the values, or 2^(n-1) , before guessing the
secret quantity. If the probability of different values is unequal,
then there is less information present and fewer guesses will, on
average, be required by an adversary. In particular, any values that
the adversary can know are impossible, or are of low probability, can
be initially ignored by an adversary, who will search through the
more probable values first.
For example, consider a cryptographic system that uses 56 bit keys.
If these 56 bit keys are derived by using a fixed pseudo-random
number generator that is seeded with an 8 bit seed, then an adversary
needs to search through only 256 keys (by running the pseudo-random
number generator with every possible seed), not the 2^56 keys that
may at first appear to be the case. Only 8 bits of "information" are
in these 56 bit keys.
D. Eastlake, J. Schiller, S. Crocker [Page 7]
INTERNET DRAFT Randomness Requirements for Security July 2000
3. Traditional Pseudo-Random Sequences
Most traditional sources of random numbers use deterministic sources
of "pseudo-random" numbers. These typically start with a "seed"
quantity and use numeric or logical operations to produce a sequence
of values.
[KNUTH] has a classic exposition on pseudo-random numbers.
Applications he mentions are simulation of natural phenomena,
sampling, numerical analysis, testing computer programs, decision
making, and games. None of these have the same characteristics as
the sort of security uses we are talking about. Only in the last two
could there be an adversary trying to find the random quantity.
However, in these cases, the adversary normally has only a single
chance to use a guessed value. In guessing passwords or attempting
to break an encryption scheme, the adversary normally has many,
perhaps unlimited, chances at guessing the correct value and should
be assumed to be aided by a computer.
For testing the "randomness" of numbers, Knuth suggests a variety of
measures including statistical and spectral. These tests check
things like autocorrelation between different parts of a "random"
sequence or distribution of its values. They could be met by a
constant stored random sequence, such as the "random" sequence
printed in the CRC Standard Mathematical Tables [CRC].
A typical pseudo-random number generation technique, known as a
linear congruence pseudo-random number generator, is modular
arithmetic where the N+1th value is calculated from the Nth value by
V = ( V * a + b )(Mod c)
N+1 N
The above technique has a strong relationship to linear shift
register pseudo-random number generators, which are well understood
cryptographically [SHIFT*]. In such generators bits are introduced
at one end of a shift register as the Exclusive Or (binary sum
without carry) of bits from selected fixed taps into the register.
For example:
D. Eastlake, J. Schiller, S. Crocker [Page 8]
INTERNET DRAFT Randomness Requirements for Security July 2000
+----+ +----+ +----+ +----+
| B | <-- | B | <-- | B | <-- . . . . . . <-- | B | <-+
| 0 | | 1 | | 2 | | n | |
+----+ +----+ +----+ +----+ |
| | | |
| | V +-----+
| V +----------------> | |
V +-----------------------------> | XOR |
+---------------------------------------------------> | |
+-----+
V = ( ( V * 2 ) + B .xor. B ... )(Mod 2^n)
N+1 N 0 2
The goodness of traditional pseudo-random number generator algorithms
is measured by statistical tests on such sequences. Carefully chosen
values of the initial V and a, b, and c or the placement of shift
register tap in the above simple processes can produce excellent
statistics.
These sequences may be adequate in simulations (Monte Carlo
experiments) as long as the sequence is orthogonal to the structure
of the space being explored. Even there, subtle patterns may cause
problems. However, such sequences are clearly bad for use in
security applications. They are fully predictable if the initial
state is known. Depending on the form of the pseudo-random number
generator, the sequence may be determinable from observation of a
short portion of the sequence [CRYPTO*, STERN]. For example, with
the generators above, one can determine V(n+1) given knowledge of
V(n). In fact, it has been shown that with these techniques, even if
only one bit of the pseudo-random values are released, the seed can
be determined from short sequences.
Not only have linear congruent generators been broken, but techniques
are now known for breaking all polynomial congruent generators.
[KRAWCZYK]
D. Eastlake, J. Schiller, S. Crocker [Page 9]
INTERNET DRAFT Randomness Requirements for Security July 2000
4. Unpredictability
Randomness in the traditional sense described in section 3 is NOT the
same as the unpredictability required for security use.
For example, use of a widely available constant sequence, such as
that from the CRC tables, is very weak against an adversary. Once
they learn of or guess it, they can easily break all security, future
and past, based on the sequence. [CRC] Yet the statistical properties
of these tables are good.
The following sections describe the limitations of some randomness
generation techniques and sources.
4.1 Problems with Clocks and Serial Numbers
Computer clocks, or similar operating system or hardware values,
provide significantly fewer real bits of unpredictability than might
appear from their specifications.
Tests have been done on clocks on numerous systems and it was found
that their behavior can vary widely and in unexpected ways. One
version of an operating system running on one set of hardware may
actually provide, say, microsecond resolution in a clock while a
different configuration of the "same" system may always provide the
same lower bits and only count in the upper bits at much lower
resolution. This means that successive reads on the clock may
produce identical values even if enough time has passed that the
value "should" change based on the nominal clock resolution. There
are also cases where frequently reading a clock can produce
artificial sequential values because of extra code that checks for
the clock being unchanged between two reads and increases it by one!
Designing portable application code to generate unpredictable numbers
based on such system clocks is particularly challenging because the
system designer does not always know the properties of the system
clocks that the code will execute on.
Use of a hardware serial number such as an Ethernet address may also
provide fewer bits of uniqueness than one would guess. Such
quantities are usually heavily structured and subfields may have only
a limited range of possible values or values easily guessable based
on approximate date of manufacture or other data. For example, it is
likely that a company that manfactures both computers and Ethernet
adapters will, at least internally, use its own adapters, which
significantly limits the range of built in addresses.
Problems such as those described above related to clocks and serial
numbers make code to produce unpredictable quantities difficult if
D. Eastlake, J. Schiller, S. Crocker [Page 10]
INTERNET DRAFT Randomness Requirements for Security July 2000
the code is to be ported across a variety of computer platforms and
systems.
4.2 Timing and Content of External Events
It is possible to measure the timing and content of mouse movement,
key strokes, and similar user events. This is a reasonable source of
unguessable data with some qualifications. On some machines, inputs
such as key strokes are buffered. Even though the user's inter-
keystroke timing may have sufficient variation and unpredictability,
there might not be an easy way to access that variation. Another
problem is that no standard method exists to sample timing details.
This makes it hard to build standard software intended for
distribution to a large range of machines based on this technique.
The amount of mouse movement or the keys actually hit are usually
easier to access than timings but may yield less unpredictability as
the user may provide highly repetitive input.
Other external events, such as network packet arrival times, can also
be used with care. In particular, the possibility of manipulation of
such times by an adversary and the lack of history on system start up
must be considered.
4.3 The Fallacy of Complex Manipulation
One strategy which may give a misleading appearance of
unpredictability is to take a very complex algorithm (or an excellent
traditional pseudo-random number generator with good statistical
properties) and calculate a cryptographic key by starting with the
current value of a computer system clock as the seed. An adversary
who knew roughly when the generator was started would have a
relatively small number of seed values to test as they would know
likely values of the system clock. Large numbers of pseudo-random
bits could be generated but the search space an adversary would need
to check could be quite small.
Thus very strong and/or complex manipulation of data will not help if
the adversary can learn what the manipulation is and there is not
enough unpredictability in the starting seed value. Even if they can
not learn what the manipulation is, they may be able to use the
limited number of results stemming from a limited number of seed
values to defeat security.
Another serious strategy error is to assume that a very complex
pseudo-random number generation algorithm will produce strong random
D. Eastlake, J. Schiller, S. Crocker [Page 11]
INTERNET DRAFT Randomness Requirements for Security July 2000
numbers when there has been no theory behind or analysis of the
algorithm. There is a excellent example of this fallacy right near
the beginning of chapter 3 in [KNUTH] where the author describes a
complex algorithm. It was intended that the machine language program
corresponding to the algorithm would be so complicated that a person
trying to read the code without comments wouldn't know what the
program was doing. Unfortunately, actual use of this algorithm
showed that it almost immediately converged to a single repeated
value in one case and a small cycle of values in another case.
Not only does complex manipulation not help you if you have a limited
range of seeds but blindly chosen complex manipulation can destroy
the randomness in a good seed!
4.4 The Fallacy of Selection from a Large Database
Another strategy that can give a misleading appearance of
unpredictability is selection of a quantity randomly from a database
and assume that its strength is related to the total number of bits
in the database. For example, typical USENET servers process many
megabytes of information per day. Assume a random quantity was
selected by fetching 32 bytes of data from a random starting point in
this data. This does not yield 32*8 = 256 bits worth of
unguessability. Even after allowing that much of the data is human
language and probably has more like 2 or 3 bits of information per
byte, it doesn't yield 32*2.5 = 80 bits of unguessability. For an
adversary with access to the same usenet database the unguessability
rests only on the starting point of the selection. That is perhaps a
little over a couple of dozen bits of unguessability.
The same argument applies to selecting sequences from the data on a
CD/DVD recording or any other large public database. If the
adversary has access to the same database, this "selection from a
large volume of data" step buys very little. However, if a selection
can be made from data to which the adversary has no access, such as
system buffers on an active multi-user system, it may be of help.
D. Eastlake, J. Schiller, S. Crocker [Page 12]
INTERNET DRAFT Randomness Requirements for Security July 2000
5. Hardware for Randomness
Is there any hope for strong portable randomness in the future?
There might be. All that's needed is a physical source of
unpredictable numbers.
A thermal noise or radioactive decay source and a fast, free-running
oscillator would do the trick directly [GIFFORD]. This is a trivial
amount of hardware, and could easily be included as a standard part
of a computer system's architecture. Furthermore, any system with a
spinning disk or the like has an adequate source of randomness
[DAVIS]. All that's needed is the common perception among computer
vendors that this small additional hardware and the software to
access it is necessary and useful.
5.1 Volume Required
How much unpredictability is needed? Is it possible to quantify the
requirement in, say, number of random bits per second?
The answer is not very much is needed. For DES, the key is 56 bits
and, as we show in an example in Section 8, even the highest security
system is unlikely to require a keying material of over 200 bits. If
a series of keys are needed, they can be generated from a strong
random seed using a cryptographically strong sequence as explained in
Section 6.3. A few hundred random bits generated once a day would be
enough using such techniques. Even if the random bits are generated
as slowly as one per second and it is not possible to overlap the
generation process, it should be tolerable in high security
applications to wait 200 seconds occasionally.
These numbers are trivial to achieve. It could be done by a person
repeatedly tossing a coin. Almost any hardware process is likely to
be much faster.
5.2 Sensitivity to Skew
Is there any specific requirement on the shape of the distribution of
the random numbers? The good news is the distribution need not be
uniform. All that is needed is a conservative estimate of how non-
uniform it is to bound performance. Two simple techniques to de-skew
the bit stream are given below and stronger techniques are mentioned
in Section 6.1.2 below.
D. Eastlake, J. Schiller, S. Crocker [Page 13]
INTERNET DRAFT Randomness Requirements for Security July 2000
5.2.1 Using Stream Parity to De-Skew
Consider taking a sufficiently long string of bits and map the string
to "zero" or "one". The mapping will not yield a perfectly uniform
distribution, but it can be as close as desired. One mapping that
serves the purpose is to take the parity of the string. This has the
advantages that it is robust across all degrees of skew up to the
estimated maximum skew and is absolutely trivial to implement in
hardware.
The following analysis gives the number of bits that must be sampled:
Suppose the ratio of ones to zeros is 0.5 + e : 0.5 - e, where e is
between 0 and 0.5 and is a measure of the "eccentricity" of the
distribution. Consider the distribution of the parity function of N
bit samples. The probabilities that the parity will be one or zero
will be the sum of the odd or even terms in the binomial expansion of
(p + q)^N, where p = 0.5 + e, the probability of a one, and q = 0.5 -
e, the probability of a zero.
These sums can be computed easily as
N N
1/2 * ( ( p + q ) + ( p - q ) )
and
N N
1/2 * ( ( p + q ) - ( p - q ) ).
(Which one corresponds to the probability the parity will be 1
depends on whether N is odd or even.)
Since p + q = 1 and p - q = 2e, these expressions reduce to
N
1/2 * [1 + (2e) ]
and
N
1/2 * [1 - (2e) ].
Neither of these will ever be exactly 0.5 unless e is zero, but we
can bring them arbitrarily close to 0.5. If we want the
probabilities to be within some delta d of 0.5, i.e. then
N
( 0.5 + ( 0.5 * (2e) ) ) < 0.5 + d.
Solving for N yields N > log(2d)/log(2e). (Note that 2e is less than
1, so its log is negative. Division by a negative number reverses
the sense of an inequality.)
D. Eastlake, J. Schiller, S. Crocker [Page 14]
INTERNET DRAFT Randomness Requirements for Security July 2000
The following table gives the length of the string which must be
sampled for various degrees of skew in order to come within 0.001 of
a 50/50 distribution.
+---------+--------+-------+
| Prob(1) | e | N |
+---------+--------+-------+
| 0.5 | 0.00 | 1 |
| 0.6 | 0.10 | 4 |
| 0.7 | 0.20 | 7 |
| 0.8 | 0.30 | 13 |
| 0.9 | 0.40 | 28 |
| 0.95 | 0.45 | 59 |
| 0.99 | 0.49 | 308 |
+---------+--------+-------+
The last entry shows that even if the distribution is skewed 99% in
favor of ones, the parity of a string of 308 samples will be within
0.001 of a 50/50 distribution.
5.2.2 Using Transition Mappings to De-Skew
Another technique, originally due to von Neumann [VON NEUMANN], is to
examine a bit stream as a sequence of non-overlapping pairs. You
could then discard any 00 or 11 pairs found, interpret 01 as a 0 and
10 as a 1. Assume the probability of a 1 is 0.5+e and the
probability of a 0 is 0.5-e where e is the eccentricity of the source
and described in the previous section. Then the probability of each
pair is as follows:
+------+-----------------------------------------+
| pair | probability |
+------+-----------------------------------------+
| 00 | (0.5 - e)^2 = 0.25 - e + e^2 |
| 01 | (0.5 - e)*(0.5 + e) = 0.25 - e^2 |
| 10 | (0.5 + e)*(0.5 - e) = 0.25 - e^2 |
| 11 | (0.5 + e)^2 = 0.25 + e + e^2 |
+------+-----------------------------------------+
This technique will completely eliminate any bias but at the expense
of taking an indeterminate number of input bits for any particular
desired number of output bits. The probability of any particular
pair being discarded is 0.5 + 2e^2 so the expected number of input
bits to produce X output bits is X/(0.25 - e^2).
This technique assumes that the bits are from a stream where each bit
has the same probability of being a 0 or 1 as any other bit in the
stream and that bits are not correlated, i.e., that the bits are
D. Eastlake, J. Schiller, S. Crocker [Page 15]
INTERNET DRAFT Randomness Requirements for Security July 2000
identical independent distributions. If alternate bits were from two
correlated sources, for example, the above analysis breaks down.
The above technique also provides another illustration of how a
simple statistical analysis can mislead if one is not always on the
lookout for patterns that could be exploited by an adversary. If the
algorithm were mis-read slightly so that overlapping successive bits
pairs were used instead of non-overlapping pairs, the statistical
analysis given is the same; however, instead of providing an unbiased
uncorrelated series of random 1's and 0's, it instead produces a
totally predictable sequence of exactly alternating 1's and 0's.
5.2.3 Using FFT to De-Skew
When real world data consists of strongly biased or correlated bits,
it may still contain useful amounts of randomness. This randomness
can be extracted through use of the discrete Fourier transform or its
optimized variant, the FFT.
Using the Fourier transform of the data, strong correlations can be
discarded. If adequate data is processed and remaining correlations
decay, spectral lines approaching statistical independence and
normally distributed randomness can be produced [BRILLINGER].
5.2.4 Using Compression to De-Skew
Reversible compression techniques also provide a crude method of de-
skewing a skewed bit stream. This follows directly from the
definition of reversible compression and the formula in Section 2
above for the amount of information in a sequence. Since the
compression is reversible, the same amount of information must be
present in the shorter output than was present in the longer input.
By the Shannon information equation, this is only possible if, on
average, the probabilities of the different shorter sequences are
more uniformly distributed than were the probabilities of the longer
sequences. Thus the shorter sequences are de-skewed relative to the
input.
However, many compression techniques add a somewhat predictable
preface to their output stream and may insert such a sequence again
periodically in their output or otherwise introduce subtle patterns
of their own. They should be considered only a rough technique
compared with those described above or in Section 6.1.2. At a
minimum, the beginning of the compressed sequence should be skipped
and only later bits used for applications requiring random bits.
D. Eastlake, J. Schiller, S. Crocker [Page 16]
INTERNET DRAFT Randomness Requirements for Security July 2000
5.3 Existing Hardware Can Be Used For Randomness
As described below, many computers come with hardware that can, with
care, be used to generate truly random quantities.
5.3.1 Using Existing Sound/Video Input
Increasingly computers are being built with inputs that digitize some
real world analog source, such as sound from a microphone or video
input from a camera. Under appropriate circumstances, such input can
provide reasonably high quality random bits. The "input" from a
sound digitizer with no source plugged in or a camera with the lens
cap on, if the system has enough gain to detect anything, is
essentially thermal noise.
For example, on a SPARCstation, one can read from the /dev/audio
device with nothing plugged into the microphone jack. Such data is
essentially random noise although it should not be trusted without
some checking in case of hardware failure. It will, in any case,
need to be de-skewed as described elsewhere.
Combining this with compression to de-skew one can, in UNIXese,
generate a huge amount of medium quality random data by doing
cat /dev/audio | compress - >random-bits-file
5.3.2 Using Existing Disk Drives
Disk drives have small random fluctuations in their rotational speed
due to chaotic air turbulence [DAVIS]. By adding low level disk seek
time instrumentation to a system, a series of measurements can be
obtained that include this randomness. Such data is usually highly
correlated so that significant processing is needed, including FFT
(see section 5.2.3). Nevertheless experimentation has shown that,
with such processing, disk drives easily produce 100 bits a minute or
more of excellent random data.
Partly offsetting this need for processing is the fact that disk
drive failure will normally be rapidly noticed. Thus, problems with
this method of random number generation due to hardware failure are
very unlikely.
D. Eastlake, J. Schiller, S. Crocker [Page 17]
INTERNET DRAFT Randomness Requirements for Security July 2000
6. Recommended Non-Hardware Strategy
What is the best overall strategy for meeting the requirement for
unguessable random numbers in the absence of a reliable hardware
source? It is to obtain random input from a number of uncorrelated
sources and to mix them with a strong mixing function. Such a
function will preserve the randomness present in any of the sources
even if other quantities being combined are fixed or easily
guessable. This may be advisable even with a good hardware source as
hardware can also fail, though this should be weighed against any
increase in the chance of overall failure due to added software
complexity.
6.1 Mixing Functions
A strong mixing function is one which combines two or more inputs and
produces an output where each output bit is a different complex non-
linear function of all the input bits. On average, changing any
input bit will change about half the output bits. But because the
relationship is complex and non-linear, no particular output bit is
guaranteed to change when any particular input bit is changed.
Consider the problem of converting a stream of bits that is skewed
towards 0 or 1 to a shorter stream which is more random, as discussed
in Section 5.2 above. This is simply another case where a strong
mixing function is desired, mixing the input bits to produce a
smaller number of output bits. The technique given in Section 5.2.1
of using the parity of a number of bits is simply the result of
successively Exclusive Or'ing them which is examined as a trivial
mixing function immediately below. Use of stronger mixing functions
to extract more of the randomness in a stream of skewed bits is
examined in Section 6.1.2.
6.1.1 A Trivial Mixing Function
A trivial example for single bit inputs is the Exclusive Or function,
which is equivalent to addition without carry, as show in the table
below. This is a degenerate case in which the one output bit always
changes for a change in either input bit. But, despite its
simplicity, it will still provide a useful illustration.
D. Eastlake, J. Schiller, S. Crocker [Page 18]
INTERNET DRAFT Randomness Requirements for Security July 2000
+-----------+-----------+----------+
| input 1 | input 2 | output |
+-----------+-----------+----------+
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
+-----------+-----------+----------+
If inputs 1 and 2 are uncorrelated and combined in this fashion then
the output will be an even better (less skewed) random bit than the
inputs. If we assume an "eccentricity" e as defined in Section 5.2
above, then the output eccentricity relates to the input eccentricity
as follows:
e = 2 * e * e
output input 1 input 2
Since e is never greater than 1/2, the eccentricity is always
improved except in the case where at least one input is a totally
skewed constant. This is illustrated in the following table where
the top and left side values are the two input eccentricities and the
entries are the output eccentricity:
+--------+--------+--------+--------+--------+--------+--------+
| e | 0.00 | 0.10 | 0.20 | 0.30 | 0.40 | 0.50 |
+--------+--------+--------+--------+--------+--------+--------+
| 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| 0.10 | 0.00 | 0.02 | 0.04 | 0.06 | 0.08 | 0.10 |
| 0.20 | 0.00 | 0.04 | 0.08 | 0.12 | 0.16 | 0.20 |
| 0.30 | 0.00 | 0.06 | 0.12 | 0.18 | 0.24 | 0.30 |
| 0.40 | 0.00 | 0.08 | 0.16 | 0.24 | 0.32 | 0.40 |
| 0.50 | 0.00 | 0.10 | 0.20 | 0.30 | 0.40 | 0.50 |
+--------+--------+--------+--------+--------+--------+--------+
However, keep in mind that the above calculations assume that the
inputs are not correlated. If the inputs were, say, the parity of
the number of minutes from midnight on two clocks accurate to a few
seconds, then each might appear random if sampled at random intervals
much longer than a minute. Yet if they were both sampled and
combined with xor, the result would be zero most of the time.
6.1.2 Stronger Mixing Functions
The US Government Data Encryption Standard [DES] is an example of a
strong mixing function for multiple bit quantities. It takes up to
120 bits of input (64 bits of "data" and 56 bits of "key") and
produces 64 bits of output each of which is dependent on a complex
D. Eastlake, J. Schiller, S. Crocker [Page 19]
INTERNET DRAFT Randomness Requirements for Security July 2000
non-linear function of all input bits. Other strong encryption
functions with this characteristic can also be used by considering
them to mix all of their key and data input bits.
Another good family of mixing functions are the "message digest" or
hashing functions such as The US Government Secure Hash Standard
[SHA1] and the MD4, MD5 [MD4, MD5] series. These functions all take
an arbitrary amount of input and produce an output mixing all the
input bits. The MD* series produce 128 bits of output and SHA1
produces 160 bits.
Although the message digest functions are designed for variable
amounts of input, DES and other encryption functions can also be used
to combine any number of inputs. If 64 bits of output is adequate,
the inputs can be packed into a 64 bit data quantity and successive
56 bit keys, padding with zeros if needed, which are then used to
successively encrypt using DES in Electronic Codebook Mode [DES
MODES]. If more than 64 bits of output are needed, use more complex
mixing. For example, if inputs are packed into three quantities, A,
B, and C, use DES to encrypt A with B as a key and then with C as a
key to produce the 1st part of the output, then encrypt B with C and
then A for more output and, if necessary, encrypt C with A and then B
for yet more output. Still more output can be produced by reversing
the order of the keys given above to stretch things. The same can be
done with the hash functions by hashing various subsets of the input
data to produce multiple outputs. But keep in mind that it is
impossible to get more bits of "randomness" out than are put in.
An example of using a strong mixing function would be to reconsider
the case of a string of 308 bits each of which is biased 99% towards
zero. The parity technique given in Section 5.2.1 above reduced this
to one bit with only a 1/1000 deviance from being equally likely a
zero or one. But, applying the equation for information given in
Section 2, this 308 bit skewed sequence has over 5 bits of
information in it. Thus hashing it with SHA1 or MD5 and taking the
bottom 5 bits of the result would yield 5 unbiased random bits as
opposed to the single bit given by calculating the parity of the
string.
6.1.3 Diff-Hellman as a Mixing Function
Diffie-Hellman exponential key exchange is a technique that yields a
shared secret between two parties that can be made computationally
infeasible for a third party to determine even if they can observe
all the messages between the two communicating parties. This shared
secret is a mixture of initial quantities generated by each of them
[D-H]. If these initial quantities are random, then the shared
secret contains the combined randomness of them both, assuming they
D. Eastlake, J. Schiller, S. Crocker [Page 20]
INTERNET DRAFT Randomness Requirements for Security July 2000
are uncorrelated.
6.1.4 Using a Mixing Function to Stretch Random Bits
While it is not necessary for a mixing function to produce the same
or fewer bits than its inputs, mixing bits cannot "stretch" the
amount of random unpredictability present in the inputs. Thus four
inputs of 32 bits each where there is 12 bits worth of
unpredicatability (such as 4,096 equally probable values) in each
input cannot produce more than 48 bits worth of unpredictable output.
The output can be expanded to hundreds or thousands of bits by, for
example, mixing with successive integers, but the clever adversary's
search space is still 2^48 possibilities. Furthermore, mixing to
fewer bits than are input will tend to strengthen the randomness of
the output the way using Exclusive Or to produce one bit from two did
above.
The last table in Section 6.1.1 shows that mixing a random bit with a
constant bit with Exclusive Or will produce a random bit. While this
is true, it does not provide a way to "stretch" one random bit into
more than one. If, for example, a random bit is mixed with a 0 and
then with a 1, this produces a two bit sequence but it will always be
either 01 or 10. Since there are only two possible values, there is
still only the one bit of original randomness.
6.1.5 Other Factors in Choosing a Mixing Function
For local use, DES has the advantages that it has been widely tested
for flaws, is widely documented, and is widely implemented with
hardware and software implementations available all over the world
including source code available on the Internet. The SHA1 and MD*
family are younger algorithms which have been less tested but there
is no particular reason to believe they are flawed. Both MD5 and SHS
were derived from the earlier MD4 algorithm. They all have source
code available [SHS, MD4, MD5].
DES and SHA1 have been vouched for the the US National Security
Agency (NSA) on the basis of criteria that primarily remain secret.
While this is the cause of much speculation and doubt, investigation
of DES over the years has indicated that NSA involvement in
modifications to its design, which originated with IBM, was primarily
to strengthen it. No concealed or special weakness has been found in
DES. It is almost certain that the NSA modification to MD4 to
produce the SHA1 similarly strengthened the algorithm, possibly
against threats not yet known in the public cryptographic community.
D. Eastlake, J. Schiller, S. Crocker [Page 21]
INTERNET DRAFT Randomness Requirements for Security July 2000
DES, SHA1, MD4, and MD5 are royalty free for all purposes. Continued
advances in crypography and computing power have cast some doubts on
MD4 and MD5 so their use is not recommended.
Another advantage of the MD* or similar hashing algorithms over
encryption algorithms is that they are not subject to the same
regulations imposed by the US Government prohibiting the unlicensed
export or import of encryption/decryption software and hardware. The
same should be true of DES rigged to produce an irreversible hash
code but most DES packages are oriented to reversible encryption.
6.2 Non-Hardware Sources of Randomness
The best source of input for mixing would be a hardware randomness
such as disk drive timing effected by air turbulence, audio input
with thermal noise, or radioactive decay. However, if that is not
available there are other possibilities. These include system
clocks, system or input/output buffers, user/system/hardware/network
serial numbers and/or addresses and timing, and user input.
Unfortunately, any of these sources can produce limited or
predicatable values under some circumstances.
Some of the sources listed above would be quite strong on multi-user
systems where, in essence, each user of the system is a source of
randomness. However, on a small single user system, it might be
possible for an adversary to assemble a similar configuration. This
could give the adversary inputs to the mixing process that were
sufficiently correlated to those used originally as to make
exhaustive search practical.
The use of multiple random inputs with a strong mixing function is
recommended and can overcome weakness in any particular input. For
example, the timing and content of requested "random" user keystrokes
can yield hundreds of random bits but conservative assumptions need
to be made. For example, assuming a few bits of randomness if the
inter-keystroke interval is unique in the sequence up to that point
and a similar assumption if the key hit is unique but assuming that
no bits of randomness are present in the initial key value or if the
timing or key value duplicate previous values. The results of mixing
these timings and characters typed could be further combined with
clock values and other inputs.
This strategy may make practical portable code to produce good random
numbers for security even if some of the inputs are very weak on some
of the target systems. However, it may still fail against a high
grade attack on small single user systems, especially if the
adversary has ever been able to observe the generation process in the
past. A hardware based random source is still preferable.
D. Eastlake, J. Schiller, S. Crocker [Page 22]
INTERNET DRAFT Randomness Requirements for Security July 2000
6.3 Cryptographically Strong Sequences
In cases where a series of random quantities must be generated, an
adversary may learn some values in the sequence. In general, they
should not be able to predict other values from the ones that they
know.
The correct technique is to start with a strong random seed, take
cryptographically strong steps from that seed [CRYPTO2, CRYPTO3], and
do not reveal the complete state of the generator in the sequence
elements. If each value in the sequence can be calculated in a fixed
way from the previous value, then when any value is compromised, all
future values can be determined. This would be the case, for
example, if each value were a constant function of the previously
used values, even if the function were a very strong, non-invertible
message digest function.
It should be noted that if your technique for generating a sequence
of key values is fast enough, it can trivially be used as the basis
for a confidentiality system. If two parties use the same sequence
generating technique and start with the same seed material, they will
generate identical sequences. These could, for example, be xor'ed at
one end with data being send, encrypting it, and xor'ed with this
data as received, decrypting it due to the reversible properties of
the xor operation.
6.3.1 Traditional Strong Sequences
A traditional way to achieve a strong sequence has been to have the
values be produced by hashing the quantities produced by
concatenating the seed with successive integers or the like and then
mask the values obtained so as to limit the amount of generator state
available to the adversary.
It may also be possible to use an "encryption" algorithm with a
random key and seed value to encrypt and feedback some or all of the
output encrypted value into the value to be encrypted for the next
iteration. Appropriate feedback techniques will usually be
recommended with the encryption algorithm. An example is shown below
where shifting and masking are used to combine the cypher output
feedback. This type of feedback is recommended by the US Government
in connection with DES [DES MODES].
D. Eastlake, J. Schiller, S. Crocker [Page 23]
INTERNET DRAFT Randomness Requirements for Security July 2000
+---------------+
| V |
| | n |
+--+------------+
| | +---------+
| +---------> | | +-----+
+--+ | Encrypt | <--- | Key |
| +-------- | | +-----+
| | +---------+
V V
+------------+--+
| V | |
| n+1 |
+---------------+
Note that if a shift of one is used, this is the same as the shift
register technique described in Section 3 above but with the all
important difference that the feedback is determined by a complex
non-linear function of all bits rather than a simple linear or
polynomial combination of output from a few bit position taps.
It has been shown by Donald W. Davies that this sort of shifted
partial output feedback significantly weakens an algorithm compared
will feeding all of the