idnits 2.16.02
/tmp/draft-eastlake-randomness2-10.txt:
Checking boilerplate required by RFC 5378 and the IETF Trust (see
https://trustee.ietf.org/license-info):
----------------------------------------------------------------------------
** It looks like you're using RFC 3978 boilerplate. You should update this
to the boilerplate described in the IETF Trust License Policy document
(see https://trustee.ietf.org/license-info), which is required now.
-- Found old boilerplate from RFC 3667, Section 5.1 on line 16.
-- Found old boilerplate from RFC 3978, Section 5.5 on line 1816.
** Found boilerplate matching RFC 3978, Section 5.4, paragraph 1 (on line
1808), which is fine, but *also* found old RFC 2026, Section 10.4C,
paragraph 1 text on line 37.
** The document seems to lack an RFC 3978 Section 5.1 IPR Disclosure
Acknowledgement -- however, there's a paragraph with a matching
beginning. Boilerplate error?
** This document has an original RFC 3978 Section 5.4 Copyright Line,
instead of the newer IETF Trust Copyright according to RFC 4748.
** The document seems to lack an RFC 3978 Section 5.4 Reference to BCP 78
-- however, there's a paragraph with a matching beginning. Boilerplate
error?
** This document has an original RFC 3978 Section 5.5 Disclaimer, instead
of the newer disclaimer which includes the IETF Trust according to RFC
4748.
** The document seems to lack an RFC 3979 Section 5, para. 1 IPR Disclosure
Acknowledgement.
** The document seems to lack an RFC 3979 Section 5, para. 2 IPR Disclosure
Acknowledgement.
** The document seems to lack an RFC 3979 Section 5, para. 3 IPR Disclosure
Invitation.
** The document uses RFC 3667 boilerplate or RFC 3978-like boilerplate
instead of verbatim RFC 3978 boilerplate. After 6 May 2005, submission
of drafts without verbatim RFC 3978 boilerplate is not accepted.
The following non-3978 patterns matched text found in the document.
That text should be removed or replaced:
By submitting this Internet-Draft, I certify that any applicable patent
or other IPR claims of which I am aware have been disclosed, or
will be disclosed, and any of which I become aware will be
disclosed, in accordance with RFC 3668.
Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt:
----------------------------------------------------------------------------
** Missing document type: Expected "INTERNET-DRAFT" in the upper left hand
corner of the first page
** The document seems to lack a 1id_guidelines paragraph about 6 months
document validity -- however, there's a paragraph with a matching
beginning. Boilerplate error?
== No 'Intended status' indicated for this document; assuming Proposed
Standard
Checking nits according to https://www.ietf.org/id-info/checklist :
----------------------------------------------------------------------------
** The document seems to lack an IANA Considerations section. (See Section
2.2 of https://www.ietf.org/id-info/checklist for how to handle the case
when there are no actions for IANA.)
** There is 1 instance of too long lines in the document, the longest one
being 1 character in excess of 72.
Miscellaneous warnings:
----------------------------------------------------------------------------
== The copyright year in the RFC 3978 Section 5.4 Copyright Line does not
match the current year
== Line 797 has weird spacing: '...ity, it provi...'
== Couldn't figure out when the document was first submitted -- there may
comments or warnings related to the use of a disclaimer for pre-RFC5378
work that could not be issued because of this. Please check the Legal
Provisions document at https://trustee.ietf.org/license-info to determine
if you need the pre-RFC5378 disclaimer.
-- The document date (January 2005) is 5274 days in the past. Is this
intentional?
Checking references for intended status: Proposed Standard
----------------------------------------------------------------------------
(See RFCs 3967 and 4897 for information about using normative references
to lower-maturity documents in RFCs)
== Missing Reference: 'HMAC' is mentioned on line 1476, but not defined
== Unused Reference: 'DNSSEC' is defined on line 1890, but no explicit
reference was found in the text
== Unused Reference: 'IPSEC' is defined on line 1918, but no explicit
reference was found in the text
== Unused Reference: 'MAIL PGP' is defined on line 1960, but no explicit
reference was found in the text
== Unused Reference: 'SBOX1' is defined on line 2013, but no explicit
reference was found in the text
== Unused Reference: 'SBOX2' is defined on line 2016, but no explicit
reference was found in the text
== Unused Reference: 'SHIFT1' is defined on line 2026, but no explicit
reference was found in the text
== Unused Reference: 'SHIFT2' is defined on line 2029, but no explicit
reference was found in the text
== Unused Reference: 'SHA' is defined on line 2032, but no explicit
reference was found in the text
== Unused Reference: 'SHA RFC' is defined on line 2035, but no explicit
reference was found in the text
== Unused Reference: 'SSH' is defined on line 2038, but no explicit
reference was found in the text
== Unused Reference: 'TLS' is defined on line 2043, but no explicit
reference was found in the text
-- Obsolete informational reference (is this intentional?): RFC 2535 (ref.
'DNSSEC') (Obsoleted by RFC 4033, RFC 4034, RFC 4035)
-- Obsolete informational reference (is this intentional?): RFC 2401 (ref.
'IPSEC') (Obsoleted by RFC 4301)
-- Obsolete informational reference (is this intentional?): RFC 1320 (ref.
'MD4') (Obsoleted by RFC 6150)
-- Obsolete informational reference (is this intentional?): RFC 1750
(Obsoleted by RFC 4086)
-- Obsolete informational reference (is this intentional?): RFC 1948
(Obsoleted by RFC 6528)
-- No information found for draft-ietf-secsh- - is the name correct?
-- Obsolete informational reference (is this intentional?): RFC 2246 (ref.
'TLS') (Obsoleted by RFC 4346)
Summary: 14 errors (**), 0 flaws (~~), 16 warnings (==), 10 comments
(--).
Run idnits with the --verbose option for more detailed information about
the items above.
--------------------------------------------------------------------------------
2 Network Working Group Donald E. Eastlake, 3rd
3 OBSOLETES RFC 1750 Jeffrey I. Schiller
4 Steve Crocker
5 Expires July 2005 January 2005
7 Randomness Requirements for Security
8 ---------- ------------ --- --------
9
11 Status of This Document
13 By submitting this Internet-Draft, I certify that any applicable
14 patent or other IPR claims of which I am aware have been disclosed,
15 or will be disclosed, and any of which I become aware will be
16 disclosed, in accordance with RFC 3668.
18 This document is intended to become a Best Current Practice.
19 Comments should be sent to the authors. Distribution is unlimited.
21 Internet-Drafts are working documents of the Internet Engineering
22 Task Force (IETF), its areas, and its working groups. Note that
23 other groups may also distribute working documents as Internet-
24 Drafts.
26 Internet-Drafts are draft documents valid for a maximum of six months
27 and may be updated, replaced, or obsoleted by other documents at any
28 time. It is inappropriate to use Internet-Drafts as reference
29 material or to cite them other than a "work in progress."
31 The list of current Internet-Drafts can be accessed at
32 http://www.ietf.org/1id-abstracts.html
34 The list of Internet-Draft Shadow Directories can be accessed at
35 http://www.ietf.org/shadow.html
37 Copyright (C) The Internet Society 2005. All Rights Reserved.
39 Abstract
41 Security systems are built on strong cryptographic algorithms that
42 foil pattern analysis attempts. However, the security of these
43 systems is dependent on generating secret quantities for passwords,
44 cryptographic keys, and similar quantities. The use of pseudo-random
45 processes to generate secret quantities can result in pseudo-
46 security. The sophisticated attacker of these security systems may
47 find it easier to reproduce the environment that produced the secret
48 quantities, searching the resulting small set of possibilities, than
49 to locate the quantities in the whole of the potential number space.
51 Choosing random quantities to foil a resourceful and motivated
52 adversary is surprisingly difficult. This document points out many
53 pitfalls in using poor entropy sources or traditional pseudo-random
54 number generation techniques for generating such quantities. It
55 recommends the use of truly random hardware techniques and shows that
56 the existing hardware on many systems can be used for this purpose.
57 It provides suggestions to ameliorate the problem when a hardware
58 solution is not available. And it gives examples of how large such
59 quantities need to be for some applications.
61 Acknowledgements
63 Special thanks to Paul Hoffman and John Kelsey for their extensive
64 comments and to Peter Gutmann, who has permitted the incorporation of
65 material from his paper "Software Generation of Practically Strong
66 Random Numbers".
68 The following other persons (in alphabetic order) have also
69 contributed substantially to this document:
71 Steve Bellovin, Daniel Brown, Don Davis, Peter Gutmann, Tony
72 Hansen, Sandy Harris, Paul Hoffman, Scott Hollenback, Russ
73 Housley, Christian Huitema, John Kelsey, Mats Naslund, and Damir
74 Rajnovic.
76 The following persons (in alphabetic order) contributed to RFC 1750,
77 the predecessor of this document:
79 David M. Balenson, Don T. Davis, Carl Ellison, Marc Horowitz,
80 Christian Huitema, Charlie Kaufman, Steve Kent, Hal Murray, Neil
81 Haller, Richard Pitkin, Tim Redmond, and Doug Tygar.
83 Table of Contents
85 Status of This Document....................................1
86 Abstract...................................................1
87 Acknowledgements...........................................2
89 Table of Contents..........................................3
91 1. Introduction and Overview...............................5
93 2. General Requirements....................................6
95 3. Entropy Sources.........................................9
96 3.1 Volume Required........................................9
97 3.2 Existing Hardware Can Be Used For Randomness..........10
98 3.2.1 Using Existing Sound/Video Input....................10
99 3.2.2 Using Existing Disk Drives..........................10
100 3.3 Ring Oscillator Sources...............................11
101 3.4 Problems with Clocks and Serial Numbers...............12
102 3.5 Timing and Value of External Events...................13
103 3.6 Non-Hardware Sources of Randomness....................14
105 4. De-skewing.............................................15
106 4.1 Using Stream Parity to De-Skew........................15
107 4.2 Using Transition Mappings to De-Skew..................16
108 4.3 Using FFT to De-Skew..................................17
109 4.4 Using Compression to De-Skew..........................18
111 5. Mixing.................................................19
112 5.1 A Trivial Mixing Function.............................19
113 5.2 Stronger Mixing Functions.............................20
114 5.3 Using S-Boxes for Mixing..............................22
115 5.4 Diffie-Hellman as a Mixing Function...................22
116 5.5 Using a Mixing Function to Stretch Random Bits........23
117 5.6 Other Factors in Choosing a Mixing Function...........23
119 6. Pseudo Random Number Generators........................25
120 6.1 Some Bad Ideas........................................25
121 6.1.1 The Fallacy of Complex Manipulation.................25
122 6.1.2 The Fallacy of Selection from a Large Database......26
123 6.1.3. Traditional Pseudo-Random Sequences................26
124 6.2 Cryptographically Strong Sequences....................28
125 6.2.1 OFB and CTR Sequences...............................29
126 6.2.2 The Blum Blum Shub Sequence Generator...............30
127 6.3 Entropy Pool Techniques...............................31
129 7. Randomness Generation Examples and Standards...........33
130 7.1 Complete Randomness Generators........................33
131 7.1.1 US DoD Recommendations for Password Generation......33
132 7.1.2 The /dev/random Device..............................34
133 7.1.3 Windows CryptGenRandom..............................35
134 7.2 Generators Assuming a Source of Entropy...............36
135 7.2.1 X9.82 Pseudo-Random Number Generation...............36
136 7,2.1.1 Notation..........................................36
137 7.1.2.2 Initializing the Generator........................37
138 7.1.2.5 Generating Random Bits............................37
139 7.2.2 X9.17 Key Generation................................37
140 7.2.3 DSS Pseudo-Random Number Generation.................38
142 8. Examples of Randomness Required........................40
143 8.1 Password Generation..................................40
144 8.2 A Very High Security Cryptographic Key................41
145 8.2.1 Effort per Key Trial................................41
146 8.2.2 Meet in the Middle Attacks..........................42
147 8.2.3 Other Considerations................................43
149 9. Conclusion.............................................44
151 10. Security Considerations...............................45
152 11. Copyright and Disclaimer..............................45
154 12. Appendix A: Changes from RFC 1750.....................46
156 13. Informative References................................47
158 Author's Addresses........................................52
159 File Name and Expiration..................................52
161 1. Introduction and Overview
163 Software cryptography is coming into wider use and is continuing to
164 spread, although there is a long way to go until it becomes
165 pervasive.
167 Systems like SSH, IPSEC, TLS, S/MIME, PGP, DNSSEC, Kerberos, etc. are
168 maturing and becoming a part of the network landscape [SSH, IPSEC,
169 MAIL*, TLS, DNSSEC]. By comparison, when the previous version of this
170 document [RFC 1750] was issued in 1994, about the only Internet
171 cryptographic security specification in the IETF was the Privacy
172 Enhanced Mail protocol [MAIL PEM *].
174 These systems provide substantial protection against snooping and
175 spoofing. However, there is a potential flaw. At the heart of all
176 cryptographic systems is the generation of secret, unguessable (i.e.,
177 random) numbers.
179 The lack of generally available facilities for generating such random
180 numbers, that is the lack of general availability of truly
181 unpredictable sources, forms an open wound in the design of
182 cryptographic software. For the software developer who wants to build
183 a key or password generation procedure that runs on a wide range of
184 hardware, this is a very real problem.
186 It is important to keep in mind that the requirement is for data that
187 an adversary has a very low probability of guessing or determining.
188 This can easily fail if pseudo-random data is used which only meets
189 traditional statistical tests for randomness or which is based on
190 limited range sources, such as clocks. Sometimes such pseudo-random
191 quantities are determinable by an adversary searching through an
192 embarrassingly small space of possibilities.
194 This Best Current Practice describes techniques for producing random
195 quantities that will be resistant to such attack. It recommends that
196 future systems include hardware random number generation or provide
197 access to existing hardware that can be used for this purpose. It
198 suggests methods for use if such hardware is not available. And it
199 gives some estimates of the number of random bits required for sample
200 applications.
202 2. General Requirements
204 A commonly encountered randomness requirement today is the user
205 password. This is usually a simple character string. Obviously, if a
206 password can be guessed, it does not provide security. (For re-usable
207 passwords, it is desirable that users be able to remember the
208 password. This may make it advisable to use pronounceable character
209 strings or phrases composed on ordinary words. But this only affects
210 the format of the password information, not the requirement that the
211 password be very hard to guess.)
213 Many other requirements come from the cryptographic arena.
214 Cryptographic techniques can be used to provide a variety of services
215 including confidentiality and authentication. Such services are based
216 on quantities, traditionally called "keys", that are unknown to and
217 unguessable by an adversary.
219 There are even TCP/IP protocol uses for randomness in picking initial
220 sequence numbers [RFC 1948].
222 Generally speaking, the above examples also illustrate two different
223 types of random quantities that may be wanted. In the case of human
224 usable passwords, the only important characteristic is that it be
225 unguessable; it is not important that they may be composed of ASCII
226 characters, for example, so the top bit of every byte is zero. On the
227 other hand, for fixed length keys and the like, you normally want
228 quantities that are indistinguishable from truly random, that is, all
229 bits will pass statistical randomness tests.
231 In some cases, such as the use of symmetric encryption with the one
232 time pads or an algorithm like the US Advanced Encryption Standard
233 [AES], the parties who wish to communicate confidentially and/or with
234 authentication must all know the same secret key. In other cases,
235 using what are called asymmetric or "public key" cryptographic
236 techniques, keys come in pairs. One key of the pair is private and
237 must be kept secret by one party, the other is public and can be
238 published to the world. It is computationally infeasible to determine
239 the private key from the public key and knowledge of the public is of
240 no help to an adversary [ASYMMETRIC]. [SCHNEIER, FERGUSON, KAUFMAN]
242 The frequency and volume of the requirement for random quantities
243 differs greatly for different cryptographic systems. Using pure RSA,
244 random quantities are required only when a new key pair is generated;
245 thereafter any number of messages can be signed without a further
246 need for randomness. The public key Digital Signature Algorithm
247 devised by the US National Institute of Standards and Technology
248 (NIST) requires good random numbers for each signature [DSS]. And
249 encrypting with a one time pad, in principle the strongest possible
250 encryption technique, requires a volume of randomness equal to all
251 the messages to be processed. [SCHNEIER, FERGUSON, KAUFMAN]
252 In most of these cases, an adversary can try to determine the
253 "secret" key by trial and error. (This is possible as long as the key
254 is enough smaller than the message that the correct key can be
255 uniquely identified.) The probability of an adversary succeeding at
256 this must be made acceptably low, depending on the particular
257 application. The size of the space the adversary must search is
258 related to the amount of key "information" present in an information
259 theoretic sense [SHANNON]. This depends on the number of different
260 secret values possible and the probability of each value as follows:
262 -----
263 \
264 Bits-of-information = \ - p * log ( p )
265 / i 2 i
266 /
267 -----
269 where i counts from 1 to the number of possible secret values and p
270 sub i is the probability of the value numbered i. (Since p sub i is
271 less than one, the log will be negative so each term in the sum will
272 be non-negative.)
274 If there are 2^n different values of equal probability, then n bits
275 of information are present and an adversary would, on the average,
276 have to try half of the values, or 2^(n-1) , before guessing the
277 secret quantity. If the probability of different values is unequal,
278 then there is less information present and fewer guesses will, on
279 average, be required by an adversary. In particular, any values that
280 the adversary can know are impossible, or are of low probability, can
281 be initially ignored by an adversary, who will search through the
282 more probable values first.
284 For example, consider a cryptographic system that uses 128 bit keys.
285 If these 128 bit keys are derived by using a fixed pseudo-random
286 number generator that is seeded with an 8 bit seed, then an adversary
287 needs to search through only 256 keys (by running the pseudo-random
288 number generator with every possible seed), not the 2^128 keys that
289 may at first appear to be the case. Only 8 bits of "information" are
290 in these 128 bit keys.
292 While the above analysis is correct on average, it can be misleading
293 in some cases for cryptographic analysis where what is really
294 important is the work factor for an adversary. For example, assume
295 that there was a pseudo-random number generator generating 128 bit
296 keys, as in the previous paragraph, but that it generated 0 half of
297 the time and a random selection from the remaining 2**128 - 1 values
298 the rest of the time. The Shannon equation above says that there are
299 64 bits of information in one of these key values but an adversary,
300 by simply trying the values 0, can break the security of half of the
301 uses, albeit a random half. Thus for cryptographic purposes, it is
302 also useful to look at other measures, such as min-entropy, defined
303 as
305 Min-entropy = - log ( maximum ( p ) )
306 i
308 where i is as above. Using this equation, we get 1 bit of min-
309 entropy for our new hypothetical distribution as opposed to 64 bits
310 of classical Shannon entropy.
312 A continuous spectrum of entropies, sometimes called Renyi entropy,
313 have been defined, specified by a parameter r. When r = 1, it is
314 Shannon entropy, and with r = infinity, it is min-entropy. When r =
315 0, it is just log (n) where n is the number of non-zero
316 probabilities. Renyi entropy is a non-increasing function of r, so
317 min-entropy is always the most conservative measure of entropy and
318 usually the best to use for cryptographic evaluation. [LUBY]
320 Statistically tested randomness in the traditional sense is NOT the
321 same as the unpredictability required for security use.
323 For example, use of a widely available constant sequence, such as
324 that from the CRC tables, is very weak against an adversary. Once
325 they learn of or guess it, they can easily break all security, future
326 and past, based on the sequence. [CRC] As another example, using AES
327 to encrypt successive integers such as 1, 2, 3 ... will also produce
328 output that has excellent statistical randomness properties but is
329 also predictable. On the other hand, taking successive rolls of a
330 six-sided die and encoding the resulting values in ASCII would
331 produce statistically poor output with a substantial unpredictable
332 component. So you should keep in mind that passing or failing
333 statistical tests doesn't tell you that something is unpredictable
334 or predictable.
336 3. Entropy Sources
338 Entropy sources tend to be very implementation dependent. Once one
339 has gathered sufficient entropy it can be used as the seed to produce
340 the required amount of cryptographically strong pseudo-randomness, as
341 described in Sections 6 and 7, after being de-skewed and/or mixed if
342 necessary as described in Sections 4 and 5.
344 Is there any hope for true strong portable randomness in the future?
345 There might be. All that's needed is a physical source of
346 unpredictable numbers.
348 A thermal noise (sometimes called Johnson noise in integrated
349 circuits) or radioactive decay source and a fast, free-running
350 oscillator would do the trick directly [GIFFORD]. This is a trivial
351 amount of hardware, and could easily be included as a standard part
352 of a computer system's architecture. Most audio (or video) input
353 devices are useable [TURBID]. Furthermore, any system with a
354 spinning disk or ring oscillator and a stable (crystal) time source
355 or the like has an adequate source of randomness ([DAVIS] and Section
356 3.3). All that's needed is the common perception among computer
357 vendors that this small additional hardware and the software to
358 access it is necessary and useful.
360 ANSI X9 is currently developing a standard which includes a part
361 devoted to entropy sources. See [X9.82 - Part 2].
363 3.1 Volume Required
365 How much unpredictability is needed? Is it possible to quantify the
366 requirement in, say, number of random bits per second?
368 The answer is not very much is needed. For AES, the key can be 128
369 bits and, as we show in an example in Section 8, even the highest
370 security system is unlikely to require strong keying material of much
371 over 200 bits. If a series of keys are needed, they can be generated
372 from a strong random seed (starting value) using a cryptographically
373 strong sequence as explained in Section 6.2. A few hundred random
374 bits generated at start up or once a day would be enough using such
375 techniques. Even if the random bits are generated as slowly as one
376 per second and it is not possible to overlap the generation process,
377 it should be tolerable in most high security applications to wait 200
378 seconds occasionally.
380 These numbers are trivial to achieve. It could be done by a person
381 repeatedly tossing a coin. Almost any hardware based process is
382 likely to be much faster.
384 3.2 Existing Hardware Can Be Used For Randomness
386 As described below, many computers come with hardware that can, with
387 care, be used to generate truly random quantities.
389 3.2.1 Using Existing Sound/Video Input
391 Many computers are built with inputs that digitize some real world
392 analog source, such as sound from a microphone or video input from a
393 camera. Under appropriate circumstances, such input can provide
394 reasonably high quality random bits. The "input" from a sound
395 digitizer with no source plugged in or a camera with the lens cap on,
396 if the system has enough gain to detect anything, is essentially
397 thermal noise. This method is extremely hardware and implementation
398 dependent.
400 For example, on some UNIX based systems, one can read from the
401 /dev/audio device with nothing plugged into the microphone jack or
402 the microphone receiving only low level background noise. Such data
403 is essentially random noise although it should not be trusted without
404 some checking in case of hardware failure. It will, in any case,
405 need to be de-skewed as described elsewhere.
407 Combining this with compression to de-skew (see Section 4) one can,
408 in UNIXese, generate a huge amount of medium quality random data by
409 doing
411 cat /dev/audio | compress - >random-bits-file
413 A detailed examination of this type of randomness source appears in
414 [TURBID].
416 3.2.2 Using Existing Disk Drives
418 Disk drives have small random fluctuations in their rotational speed
419 due to chaotic air turbulence [DAVIS, Jakobsson]. By adding low
420 level disk seek time instrumentation to a system, a series of
421 measurements can be obtained that include this randomness. Such data
422 is usually highly correlated so that significant processing is
423 needed, such as described in 5.2 below. Nevertheless experimentation
424 a decade ago showed that, with such processing, even slow disk drives
425 on the slower computers of that day could easily produce 100 bits a
426 minute or more of excellent random data.
428 Every increase in processor speed, which increases the resolution
429 with which disk motion can be timed, or increase in the rate of disk
430 seeks, increases the rate of random bit generation possible with this
431 technique. At the time of this paper and using modern hardware, a
432 more typical rate of random bit production would be in excess of
433 10,000 bits a second. This technique is used in many operating system
434 library random number generators.
436 Note: the inclusion of cache memories in disk controllers has little
437 effect on this technique if very short seek times, which represent
438 cache hits, are simply ignored.
440 3.3 Ring Oscillator Sources
442 If an integrated circuit is being designed or field programmed, an
443 odd number of gates can be connected in series to produce a free-
444 running ring oscillator. By sampling a point in the ring at a fixed
445 frequency, say one determined by a stable crystal oscillator, some
446 amount of entropy can be extracted due to variations in the free-
447 running oscillator timing. It is possible to increase the rate of
448 entropy by xor'ing sampled values from a few ring oscillators with
449 relatively prime lengths. It is sometimes recommended that an odd
450 number of rings be used so that, even if the rings somehow become
451 synchronously locked to each other, there will still be sampled bit
452 transitions. Another possibility source to sample is the output of a
453 noisy diode.
455 Sampled bits from such sources will have to be heavily de-skewed, as
456 disk rotation timings must be (see Section 4). An engineering study
457 would be needed to determine the amount of entropy being produced
458 depending on the particular design. In any case, these can be good
459 sources whose cost is a trivial amount of hardware by modern
460 standards.
462 As an example, IEEE 802.11i suggests that the circuit below be
463 considered, with due attention in the design to isolation of the
464 rings from each other and from clocked circuits to avoid undesired
465 synchronization, etc., and extensive post processing. [IEEE 802.11i]
466 |\ |\ |\
467 +-->| >0-->| >0-- 19 total --| >0--+-------+
468 | |/ |/ |/ | |
469 | | |
470 +----------------------------------+ V
471 +-----+
472 |\ |\ |\ | | output
473 +-->| >0-->| >0-- 23 total --| >0--+--->| XOR |------>
474 | |/ |/ |/ | | |
475 | | +-----+
476 +----------------------------------+ ^ ^
477 | |
478 |\ |\ |\ | |
479 +-->| >0-->| >0-- 29 total --| >0--+------+ |
480 | |/ |/ |/ | |
481 | | |
482 +----------------------------------+ |
483 |
484 other randomness if available--------------+
486 3.4 Problems with Clocks and Serial Numbers
488 Computer clocks, or similar operating system or hardware values,
489 provide significantly fewer real bits of unpredictability than might
490 appear from their specifications.
492 Tests have been done on clocks on numerous systems and it was found
493 that their behavior can vary widely and in unexpected ways. One
494 version of an operating system running on one set of hardware may
495 actually provide, say, microsecond resolution in a clock while a
496 different configuration of the "same" system may always provide the
497 same lower bits and only count in the upper bits at much lower
498 resolution. This means that successive reads on the clock may produce
499 identical values even if enough time has passed that the value
500 "should" change based on the nominal clock resolution. There are also
501 cases where frequently reading a clock can produce artificial
502 sequential values because of extra code that checks for the clock
503 being unchanged between two reads and increases it by one! Designing
504 portable application code to generate unpredictable numbers based on
505 such system clocks is particularly challenging because the system
506 designer does not always know the properties of the system clocks
507 that the code will execute on.
509 Use of hardware serial numbers such as an Ethernet MAC addresses may
510 also provide fewer bits of uniqueness than one would guess. Such
511 quantities are usually heavily structured and subfields may have only
512 a limited range of possible values or values easily guessable based
513 on approximate date of manufacture or other data. For example, it is
514 likely that a company that manufactures both computers and Ethernet
515 adapters will, at least internally, use its own adapters, which
516 significantly limits the range of built-in addresses.
518 Problems such as those described above related to clocks and serial
519 numbers make code to produce unpredictable quantities difficult if
520 the code is to be ported across a variety of computer platforms and
521 systems.
523 3.5 Timing and Value of External Events
525 It is possible to measure the timing and content of mouse movement,
526 key strokes, and similar user events. This is a reasonable source of
527 unguessable data with some qualifications. On some machines, inputs
528 such as key strokes are buffered. Even though the user's inter-
529 keystroke timing may have sufficient variation and unpredictability,
530 there might not be an easy way to access that variation. Another
531 problem is that no standard method exists to sample timing details.
532 This makes it hard to build standard software intended for
533 distribution to a large range of machines based on this technique.
535 The amount of mouse movement or the keys actually hit are usually
536 easier to access than timings but may yield less unpredictability as
537 the user may provide highly repetitive input.
539 Other external events, such as network packet arrival times and
540 lengths, can also be used, but only with great care. In particular,
541 the possibility of manipulation of such network traffic measurements
542 by an adversary and the lack of history at system start up must be
543 carefully considered. If this input is subject to manipulation, it
544 must not be trusted as a source of entropy.
546 Indeed, almost any external sensor, such as raw radio reception or
547 temperature sensing in appropriately equipped computers, can be used
548 in principle. But in each case careful consideration must be given to
549 how much such data is subject to adversarial manipulation and to how
550 much entropy it can actually provide.
552 The above techniques are quite powerful against any attackers having
553 no access to the quantities being measured. For example, they would
554 be powerful against offline attackers who had no access to your
555 environment and were trying to crack your random seed after the fact.
556 In all cases, the more accurately you can measure the timing or value
557 of an external sensor, the more rapidly you can generate bits.
559 3.6 Non-Hardware Sources of Randomness
561 The best source of input entropy would be a hardware randomness such
562 as ring oscillators, disk drive timing, thermal noise, or radioactive
563 decay. However, if that is not available, there are other
564 possibilities. These include system clocks, system or input/output
565 buffers, user/system/hardware/network serial numbers and/or addresses
566 and timing, and user input. Unfortunately, each of these sources can
567 produce very limited or predictable values under some circumstances.
569 Some of the sources listed above would be quite strong on multi-user
570 systems where, in essence, each user of the system is a source of
571 randomness. However, on a small single user or embedded system,
572 especially at start up, it might be possible for an adversary to
573 assemble a similar configuration. This could give the adversary
574 inputs to the mixing process that were sufficiently correlated to
575 those used originally as to make exhaustive search practical.
577 The use of multiple random inputs with a strong mixing function is
578 recommended and can overcome weakness in any particular input. The
579 timing and content of requested "random" user keystrokes can yield
580 hundreds of random bits but conservative assumptions need to be made.
581 For example, assuming at most a few bits of randomness if the inter-
582 keystroke interval is unique in the sequence up to that point and a
583 similar assumption if the key hit is unique but assuming that no bits
584 of randomness are present in the initial key value or if the timing
585 or key value duplicate previous values. The results of mixing these
586 timings and characters typed could be further combined with clock
587 values and other inputs.
589 This strategy may make practical portable code to produce good random
590 numbers for security even if some of the inputs are very weak on some
591 of the target systems. However, it may still fail against a high
592 grade attack on small, single user or embedded systems, especially if
593 the adversary has ever been able to observe the generation process in
594 the past. A hardware based random source is still preferable.
596 4. De-skewing
598 Is there any specific requirement on the shape of the distribution of
599 quantities gathered for the entropy to produce the random numbers?
600 The good news is the distribution need not be uniform. All that is
601 needed is a conservative estimate of how non-uniform it is to bound
602 performance. Simple techniques to de-skew a bit stream are given
603 below and stronger cryptographic techniques are described in Section
604 5.2 below.
606 4.1 Using Stream Parity to De-Skew
608 As a simple but not particularly practical example, consider taking a
609 sufficiently long string of bits and map the string to "zero" or
610 "one". The mapping will not yield a perfectly uniform distribution,
611 but it can be as close as desired. One mapping that serves the
612 purpose is to take the parity of the string. This has the advantages
613 that it is robust across all degrees of skew up to the estimated
614 maximum skew and is absolutely trivial to implement in hardware.
616 The following analysis gives the number of bits that must be sampled:
618 Suppose the ratio of ones to zeros is ( 0.5 + E ) to ( 0.5 - E ),
619 where E is between 0 and 0.5 and is a measure of the "eccentricity"
620 of the distribution. Consider the distribution of the parity function
621 of N bit samples. The probabilities that the parity will be one or
622 zero will be the sum of the odd or even terms in the binomial
623 expansion of (p + q)^N, where p = 0.5 + E, the probability of a one,
624 and q = 0.5 - E, the probability of a zero.
626 These sums can be computed easily as
628 N N
629 1/2 * ( ( p + q ) + ( p - q ) )
630 and
631 N N
632 1/2 * ( ( p + q ) - ( p - q ) ).
634 (Which one corresponds to the probability the parity will be 1
635 depends on whether N is odd or even.)
637 Since p + q = 1 and p - q = 2e, these expressions reduce to
639 N
640 1/2 * [1 + (2E) ]
641 and
642 N
643 1/2 * [1 - (2E) ].
645 Neither of these will ever be exactly 0.5 unless E is zero, but we
646 can bring them arbitrarily close to 0.5. If we want the probabilities
647 to be within some delta d of 0.5, i.e. then
649 N
650 ( 0.5 + ( 0.5 * (2E) ) ) < 0.5 + d.
652 Solving for N yields N > log(2d)/log(2E). (Note that 2E is less than
653 1, so its log is negative. Division by a negative number reverses the
654 sense of an inequality.)
656 The following table gives the length of the string which must be
657 sampled for various degrees of skew in order to come within 0.001 of
658 a 50/50 distribution.
660 +---------+--------+-------+
661 | Prob(1) | E | N |
662 +---------+--------+-------+
663 | 0.5 | 0.00 | 1 |
664 | 0.6 | 0.10 | 4 |
665 | 0.7 | 0.20 | 7 |
666 | 0.8 | 0.30 | 13 |
667 | 0.9 | 0.40 | 28 |
668 | 0.95 | 0.45 | 59 |
669 | 0.99 | 0.49 | 308 |
670 +---------+--------+-------+
672 The last entry shows that even if the distribution is skewed 99% in
673 favor of ones, the parity of a string of 308 samples will be within
674 0.001 of a 50/50 distribution. But, as we shall see in section 6.1.2,
675 there are much stronger techniques that extract more of the available
676 entropy.
678 4.2 Using Transition Mappings to De-Skew
680 Another technique, originally due to von Neumann [VON NEUMANN], is to
681 examine a bit stream as a sequence of non-overlapping pairs. You
682 could then discard any 00 or 11 pairs found, interpret 01 as a 0 and
683 10 as a 1. Assume the probability of a 1 is 0.5+E and the probability
684 of a 0 is 0.5-E where E is the eccentricity of the source and
685 described in the previous section. Then the probability of each pair
686 is as follows:
688 +------+-----------------------------------------+
689 | pair | probability |
690 +------+-----------------------------------------+
691 | 00 | (0.5 - E)^2 = 0.25 - E + E^2 |
692 | 01 | (0.5 - E)*(0.5 + E) = 0.25 - E^2 |
693 | 10 | (0.5 + E)*(0.5 - E) = 0.25 - E^2 |
694 | 11 | (0.5 + E)^2 = 0.25 + E + E^2 |
695 +------+-----------------------------------------+
697 This technique will completely eliminate any bias but at the expense
698 of taking an indeterminate number of input bits for any particular
699 desired number of output bits. The probability of any particular pair
700 being discarded is 0.5 + 2E^2 so the expected number of input bits to
701 produce X output bits is X/(0.25 - E^2).
703 This technique assumes that the bits are from a stream where each bit
704 has the same probability of being a 0 or 1 as any other bit in the
705 stream and that bits are not correlated, i.e., that the bits are
706 identical independent distributions. If alternate bits were from two
707 correlated sources, for example, the above analysis breaks down.
709 The above technique also provides another illustration of how a
710 simple statistical analysis can mislead if one is not always on the
711 lookout for patterns that could be exploited by an adversary. If the
712 algorithm were mis-read slightly so that overlapping successive bits
713 pairs were used instead of non-overlapping pairs, the statistical
714 analysis given is the same; however, instead of providing an unbiased
715 uncorrelated series of random 1s and 0s, it instead produces a
716 totally predictable sequence of exactly alternating 1s and 0s.
718 4.3 Using FFT to De-Skew
720 When real world data consists of strongly correlated bits, it may
721 still contain useful amounts of entropy. This entropy can be
722 extracted through use of various transforms, the most powerful of
723 which are described in section 5.2 below.
725 Using the Fourier transform of the data or its optimized variant, the
726 FFT, is an technique interesting primarily for theoretical reasons.
727 It can be show that this will discard strong correlations. If
728 adequate data is processed and remaining correlations decay, spectral
729 lines approaching statistical independence and normally distributed
730 randomness can be produced [BRILLINGER].
732 4.4 Using Compression to De-Skew
734 Reversible compression techniques also provide a crude method of de-
735 skewing a skewed bit stream. This follows directly from the
736 definition of reversible compression and the formula in Section 2
737 above for the amount of information in a sequence. Since the
738 compression is reversible, the same amount of information must be
739 present in the shorter output than was present in the longer input.
740 By the Shannon information equation, this is only possible if, on
741 average, the probabilities of the different shorter sequences are
742 more uniformly distributed than were the probabilities of the longer
743 sequences. Therefore the shorter sequences must be de-skewed relative
744 to the input.
746 However, many compression techniques add a somewhat predictable
747 preface to their output stream and may insert such a sequence again
748 periodically in their output or otherwise introduce subtle patterns
749 of their own. They should be considered only a rough technique
750 compared with those described in Section 5.2. At a minimum, the
751 beginning of the compressed sequence should be skipped and only later
752 bits used for applications requiring roughly random bits.
754 5. Mixing
756 What is the best overall strategy for meeting the requirement for
757 unguessable random numbers in the absence of a strong reliable
758 hardware entropy source? It is to obtain input from a number of
759 uncorrelated sources and to mix them with a strong mixing function.
760 Such a function will preserve the entropy present in any of the
761 sources even if other quantities being combined happen to be fixed or
762 easily guessable (low entropy). This may be advisable even with a
763 good hardware source, as hardware can also fail, though this should
764 be weighed against any increase in the chance of overall failure due
765 to added software complexity.
767 Once you have used good sources, such as some of those listed in
768 Section 3, and mixed them as described in this section, you have a
769 strong seed. This can then be used to produce large quantities of
770 cryptographically strong material as described in Sections 6 and 7.
772 A strong mixing function is one which combines inputs and produces an
773 output where each output bit is a different complex non-linear
774 function of all the input bits. On average, changing any input bit
775 will change about half the output bits. But because the relationship
776 is complex and non-linear, no particular output bit is guaranteed to
777 change when any particular input bit is changed.
779 Consider the problem of converting a stream of bits that is skewed
780 towards 0 or 1 or which has a somewhat predictable pattern to a
781 shorter stream which is more random, as discussed in Section 4 above.
782 This is simply another case where a strong mixing function is
783 desired, mixing the input bits to produce a smaller number of output
784 bits. The technique given in Section 4.1 of using the parity of a
785 number of bits is simply the result of successively Exclusive Or'ing
786 them which is examined as a trivial mixing function immediately
787 below. Use of stronger mixing functions to extract more of the
788 randomness in a stream of skewed bits is examined in Section 5.2. See
789 also [NASLUND].
791 5.1 A Trivial Mixing Function
793 A trivial example for single bit inputs described only for expository
794 purposes is the Exclusive Or function, which is equivalent to
795 addition without carry, as show in the table below. This is a
796 degenerate case in which the one output bit always changes for a
797 change in either input bit. But, despite its simplicity, it provides
798 a useful illustration.
800 +-----------+-----------+----------+
801 | input 1 | input 2 | output |
802 +-----------+-----------+----------+
803 | 0 | 0 | 0 |
804 | 0 | 1 | 1 |
805 | 1 | 0 | 1 |
806 | 1 | 1 | 0 |
807 +-----------+-----------+----------+
809 If inputs 1 and 2 are uncorrelated and combined in this fashion then
810 the output will be an even better (less skewed) random bit than the
811 inputs. If we assume an "eccentricity" E as defined in Section 5.2
812 above, then the output eccentricity relates to the input eccentricity
813 as follows:
815 E = 2 * E * E
816 output input 1 input 2
818 Since E is never greater than 1/2, the eccentricity is always
819 improved except in the case where at least one input is a totally
820 skewed constant. This is illustrated in the following table where the
821 top and left side values are the two input eccentricities and the
822 entries are the output eccentricity:
824 +--------+--------+--------+--------+--------+--------+--------+
825 | E | 0.00 | 0.10 | 0.20 | 0.30 | 0.40 | 0.50 |
826 +--------+--------+--------+--------+--------+--------+--------+
827 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
828 | 0.10 | 0.00 | 0.02 | 0.04 | 0.06 | 0.08 | 0.10 |
829 | 0.20 | 0.00 | 0.04 | 0.08 | 0.12 | 0.16 | 0.20 |
830 | 0.30 | 0.00 | 0.06 | 0.12 | 0.18 | 0.24 | 0.30 |
831 | 0.40 | 0.00 | 0.08 | 0.16 | 0.24 | 0.32 | 0.40 |
832 | 0.50 | 0.00 | 0.10 | 0.20 | 0.30 | 0.40 | 0.50 |
833 +--------+--------+--------+--------+--------+--------+--------+
835 However, keep in mind that the above calculations assume that the
836 inputs are not correlated. If the inputs were, say, the parity of the
837 number of minutes from midnight on two clocks accurate to a few
838 seconds, then each might appear random if sampled at random intervals
839 much longer than a minute. Yet if they were both sampled and combined
840 with xor, the result would be zero most of the time.
842 5.2 Stronger Mixing Functions
844 The US Government Advanced Encryption Standard [AES] is an example of
845 a strong mixing function for multiple bit quantities. It takes up to
846 384 bits of input (128 bits of "data" and 256 bits of "key") and
847 produces 128 bits of output each of which is dependent on a complex
848 non-linear function of all input bits. Other encryption functions
849 with this characteristic, such as [DES], can also be used by
850 considering them to mix all of their key and data input bits.
852 Another good family of mixing functions are the "message digest" or
853 hashing functions such as The US Government Secure Hash Standards
854 [SHA*] and the MD4, MD5 [MD4, MD5] series. These functions all take a
855 practically unlimited amount of input and produce a relatively short
856 fixed length output mixing all the input bits. The MD* series produce
857 128 bits of output, SHA-1 produces 160 bits, and other SHA functions
858 produce up to 512 bits.
860 Although the message digest functions are designed for variable
861 amounts of input, AES and other encryption functions can also be used
862 to combine any number of inputs. If 128 bits of output is adequate,
863 the inputs can be packed into a 128-bit data quantity and successive
864 AES keys, padding with zeros if needed, which are then used to
865 successively encrypt using AES in Electronic Codebook Mode. Or the
866 input could be packed into one 128-bit key and multiple data blocks
867 and a CBC-MAC calculated [MODES].
869 If more than 128 bits of output are needed and you want to employ
870 AES, use more complex mixing. But keep in mind that it is absolutely
871 impossible to get more bits of "randomness" out than are put in. For
872 example, if inputs are packed into three quantities, A, B, and C, use
873 AES to encrypt A with B as a key and then with C as a key to produce
874 the 1st part of the output, then encrypt B with C and then A for more
875 output and, if necessary, encrypt C with A and then B for yet more
876 output. Still more output can be produced by reversing the order of
877 the keys given above to stretch things. The same can be done with the
878 hash functions by hashing various subsets of the input data or
879 different copies of the input data with different prefixes and/or
880 suffixes to produce multiple outputs.
882 An example of using a strong mixing function would be to reconsider
883 the case of a string of 308 bits each of which is biased 99% towards
884 zero. The parity technique given in Section 4.1 above reduced this to
885 one bit with only a 1/1000 deviance from being equally likely a zero
886 or one. But, applying the equation for information given in Section
887 2, this 308 bit skewed sequence has over 5 bits of information in it.
888 Thus hashing it with SHA-1 and taking the bottom 5 bits of the result
889 would yield 5 unbiased random bits as opposed to the single bit given
890 by calculating the parity of the string. Alternatively, for some
891 applications, you could use the entire hash output to retain almost
892 all of the 5+ bits of entropy in a 160 bit quantity.
894 5.3 Using S-Boxes for Mixing
896 Many modern block encryption functions, including DES and AES,
897 incorporate modules known as S-Boxes (substitution boxes). These
898 produce a smaller number of outputs from a larger number of inputs
899 through a complex non-linear mixing function which would have the
900 effect of concentrating limited entropy in the inputs into the
901 output.
903 S-Boxes sometimes incorporate bent Boolean functions (functions of an
904 even number of bits producing one output bit with maximum non-
905 linearity). Looking at the output for all input pairs differing in
906 any particular bit position, exactly half the outputs are different.
907 An S-Box in which each output bit is produced by a bent function such
908 that any linear combination of these functions is also a bent
909 function is called a "perfect S-Box".
911 S-boxes and various repeated application or cascades of such boxes
912 can be used for mixing. [SBOX*]
914 5.4 Diffie-Hellman as a Mixing Function
916 Diffie-Hellman exponential key exchange is a technique that yields a
917 shared secret between two parties that can be made computationally
918 infeasible for a third party to determine even if they can observe
919 all the messages between the two communicating parties. This shared
920 secret is a mixture of initial quantities generated by each of the
921 parties [D-H].
923 If these initial quantities are random and uncorrelated, then the
924 shared secret combines their entropy, but, of course, can not produce
925 more randomness than the size of the shared secret generated.
927 While this is true if the Diffie-Hellman computation is performed
928 privately, an adversary that can observe either of the public keys
929 and knows the modulus being used need only search through the space
930 of the other secret key in order to be able to calculate the shared
931 secret [D-H]. So, conservatively, it would be best to consider public
932 Diffie-Hellman to produce a quantity whose guessability corresponds
933 to the worst of the two inputs. Because of this and the fact that
934 Diffie-Hellman is computationally intensive, its use as a mixing
935 function is not recommended.
937 5.5 Using a Mixing Function to Stretch Random Bits
939 While it is not necessary for a mixing function to produce the same
940 or fewer bits than its inputs, mixing bits cannot "stretch" the
941 amount of random unpredictability present in the inputs. Thus four
942 inputs of 32 bits each where there is 12 bits worth of
943 unpredictability (such as 4,096 equally probable values) in each
944 input cannot produce more than 48 bits worth of unpredictable output.
945 The output can be expanded to hundreds or thousands of bits by, for
946 example, mixing with successive integers, but the clever adversary's
947 search space is still 2^48 possibilities. Furthermore, mixing to
948 fewer bits than are input will tend to strengthen the randomness of
949 the output.
951 The last table in Section 5.1 shows that mixing a random bit with a
952 constant bit with Exclusive Or will produce a random bit. While this
953 is true, it does not provide a way to "stretch" one random bit into
954 more than one. If, for example, a random bit is mixed with a 0 and
955 then with a 1, this produces a two bit sequence but it will always be
956 either 01 or 10. Since there are only two possible values, there is
957 still only the one bit of original randomness.
959 5.6 Other Factors in Choosing a Mixing Function
961 For local use, AES has the advantages that it has been widely tested
962 for flaws, is reasonably efficient in software, and is widely
963 documented and implemented with hardware and software implementations
964 available all over the world including open source code. The SHA*
965 family have had a little less study and tend to require more CPU
966 cycles than AES but there is no reason to believe they are flawed.
967 Both SHA* and MD5 were derived from the earlier MD4 algorithm. They
968 all have source code available [SHA*, MD*]. Some signs of weakness
969 have been found in MD4 and MD5. In particular, MD4 has only three
970 rounds and there are several independent breaks of the first two or
971 last two rounds. And some collisions have been found in MD5 output.
973 AES was selected by a robust, public, and international process. It
974 and SHA* have been vouched for by the US National Security Agency
975 (NSA) on the basis of criteria that mostly remain secret, as was DES.
976 While this has been the cause of much speculation and doubt,
977 investigation of DES over the years has indicated that NSA
978 involvement in modifications to its design, which originated with
979 IBM, was primarily to strengthen it. There has been no announcement
980 of a concealed or special weakness being found in DES. It is likely
981 that the NSA modifications to MD4 to produce the SHA algorithms
982 similarly strengthened these algorithms, possibly against threats not
983 yet known in the public cryptographic community.
985 Where input lengths are unpredictable, hash algorithms are more
986 convenient to use than block encryption algorithms since they are
987 generally designed to accept variable length inputs. Block encryption
988 algorithms generally require an additional padding algorithm to
989 accommodate inputs that are not an even multiple of the block size.
991 As of the time of this document, the authors know of no patent claims
992 to the basic AES, DES, SHA*, MD4, and MD5 algorithms other than
993 patents for which an irrevocable royalty free license has been
994 granted to the world. There may, of course, be essential patents of
995 which the authors are unaware or patents on implementations or uses
996 or other relevant patents issued or to be issued.
998 6. Pseudo Random Number Generators
1000 When you have a seed with sufficient entropy, from input as described
1001 in Section 3 possibly de-skewed and mixed as described in Sections 4
1002 and 5, you can algorithmically extend that seed to produce a large
1003 quantity of cryptographically strong random quantities. Such
1004 algorithms are platform independent and can operate in the same
1005 fashion on any computer. To be secure their input and internal
1006 workings must be protected from adversarial observation.
1008 The design of such pseudo random number generation algorithms, like
1009 the design of symmetric encryption algorithms, is not a task for
1010 amateurs. Section 6.1 below lists a number of bad ideas which failed
1011 algorithms have used. If you are interested in what works, you can
1012 skip 6.1 and just read the remainder of this section and Section 7
1013 below which describes and gives references for some standard pseudo
1014 random number generation algorithms. See Section 7 and [X9.82 - Part
1015 3].
1017 6.1 Some Bad Ideas
1019 The subsections below describe a number of idea which might seem
1020 reasonable but which lead to insecure pseudo random number
1021 generation.
1023 6.1.1 The Fallacy of Complex Manipulation
1025 One strategy which may give a misleading appearance of
1026 unpredictability is to take a very complex algorithm (or an excellent
1027 traditional pseudo-random number generator with good statistical
1028 properties) and calculate a cryptographic key by starting with
1029 limited data such as the computer system clock value as the seed. An
1030 adversary who knew roughly when the generator was started would have
1031 a relatively small number of seed values to test as they would know
1032 likely values of the system clock. Large numbers of pseudo-random
1033 bits could be generated but the search space an adversary would need
1034 to check could be quite small.
1036 Thus very strong and/or complex manipulation of data will not help if
1037 the adversary can learn what the manipulation is and there is not
1038 enough entropy in the starting seed value. They can usually use the
1039 limited number of results stemming from a limited number of seed
1040 values to defeat security.
1042 Another serious strategy error is to assume that a very complex
1043 pseudo-random number generation algorithm will produce strong random
1044 numbers when there has been no theory behind or analysis of the
1045 algorithm. There is a excellent example of this fallacy right near
1046 the beginning of Chapter 3 in [KNUTH] where the author describes a
1047 complex algorithm. It was intended that the machine language program
1048 corresponding to the algorithm would be so complicated that a person
1049 trying to read the code without comments wouldn't know what the
1050 program was doing. Unfortunately, actual use of this algorithm showed
1051 that it almost immediately converged to a single repeated value in
1052 one case and a small cycle of values in another case.
1054 Not only does complex manipulation not help you if you have a limited
1055 range of seeds but blindly chosen complex manipulation can destroy
1056 the entropy in a good seed!
1058 6.1.2 The Fallacy of Selection from a Large Database
1060 Another strategy that can give a misleading appearance of
1061 unpredictability is selection of a quantity randomly from a database
1062 and assume that its strength is related to the total number of bits
1063 in the database. For example, typical USENET servers process many
1064 megabytes of information per day [USENET]. Assume a random quantity
1065 was selected by fetching 32 bytes of data from a random starting
1066 point in this data. This does not yield 32*8 = 256 bits worth of
1067 unguessability. Even after allowing that much of the data is human
1068 language and probably has no more than 2 or 3 bits of information per
1069 byte, it doesn't yield 32*2 = 64 bits of unguessability. For an
1070 adversary with access to the same Usenet database the unguessability
1071 rests only on the starting point of the selection. That is perhaps a
1072 little over a couple of dozen bits of unguessability.
1074 The same argument applies to selecting sequences from the data on a
1075 publicly available CD/DVD recording or any other large public
1076 database. If the adversary has access to the same database, this
1077 "selection from a large volume of data" step buys little. However,
1078 if a selection can be made from data to which the adversary has no
1079 access, such as system buffers on an active multi-user system, it may
1080 be of help.
1082 6.1.3. Traditional Pseudo-Random Sequences
1084 This section talks about traditional sources of deterministic of
1085 "pseudo-random" numbers. These typically start with a "seed" quantity
1086 and use simple numeric or logical operations to produce a sequence of
1087 values. Note that none of the techniques discussed in this section is
1088 suitable for cryptographic use. They are presented for general
1089 information.
1091 [KNUTH] has a classic exposition on pseudo-random numbers.
1092 Applications he mentions are simulation of natural phenomena,
1093 sampling, numerical analysis, testing computer programs, decision
1094 making, and games. None of these have the same characteristics as the
1095 sort of security uses we are talking about. Only in the last two
1096 could there be an adversary trying to find the random quantity.
1097 However, in these cases, the adversary normally has only a single
1098 chance to use a guessed value. In guessing passwords or attempting to
1099 break an encryption scheme, the adversary normally has many, perhaps
1100 unlimited, chances at guessing the correct value. Sometimes they can
1101 store the message they are trying to break and repeatedly attack it.
1102 They are also be assumed to be aided by a computer.
1104 For testing the "randomness" of numbers, Knuth suggests a variety of
1105 measures including statistical and spectral. These tests check things
1106 like autocorrelation between different parts of a "random" sequence
1107 or distribution of its values. But they could be met by a constant
1108 stored random sequence, such as the "random" sequence printed in the
1109 CRC Standard Mathematical Tables [CRC]. Despite meeting all the tests
1110 suggested by Knuth, that sequence is unsuitable for cryptographic use
1111 as adversaries must be assumed to have copies of all common published
1112 "random" sequences and will able to spot the source and predict
1113 future values.
1115 A typical pseudo-random number generation technique, known as a
1116 linear congruence pseudo-random number generator, is modular
1117 arithmetic where the value numbered N+1 is calculated from the value
1118 numbered N by
1120 V = ( V * a + b )(Mod c)
1121 N+1 N
1123 The above technique has a strong relationship to linear shift
1124 register pseudo-random number generators, which are well understood
1125 cryptographically [SHIFT*]. In such generators bits are introduced at
1126 one end of a shift register as the Exclusive Or (binary sum without
1127 carry) of bits from selected fixed taps into the register. For
1128 example:
1130 +----+ +----+ +----+ +----+
1131 | B | <-- | B | <-- | B | <-- . . . . . . <-- | B | <-+
1132 | 0 | | 1 | | 2 | | n | |
1133 +----+ +----+ +----+ +----+ |
1134 | | | |
1135 | | V +-----+
1136 | V +----------------> | |
1137 V +-----------------------------> | XOR |
1138 +---------------------------------------------------> | |
1139 +-----+
1141 V = ( ( V * 2 ) + B .xor. B ... )(Mod 2^n)
1142 N+1 N 0 2
1144 The goodness of traditional pseudo-random number generator algorithms
1145 is measured by statistical tests on such sequences. Carefully chosen
1146 values a, b, c, and initial V or the placement of shift register tap
1147 in the above simple processes can produce excellent statistics.
1149 These sequences may be adequate in simulations (Monte Carlo
1150 experiments) as long as the sequence is orthogonal to the structure
1151 of the space being explored. Even there, subtle patterns may cause
1152 problems. However, such sequences are clearly bad for use in security
1153 applications. They are fully predictable if the initial state is
1154 known. Depending on the form of the pseudo-random number generator,
1155 the sequence may be determinable from observation of a short portion
1156 of the sequence [SCHNEIER, STERN]. For example, with the generators
1157 above, one can determine V(n+1) given knowledge of V(n). In fact, it
1158 has been shown that with these techniques, even if only one bit of
1159 the pseudo-random values are released, the seed can be determined
1160 from short sequences.
1162 Not only have linear congruent generators been broken, but techniques
1163 are now known for breaking all polynomial congruent generators.
1164 [KRAWCZYK]
1166 6.2 Cryptographically Strong Sequences
1168 In cases where a series of random quantities must be generated, an
1169 adversary may learn some values in the sequence. In general, they
1170 should not be able to predict other values from the ones that they
1171 know.
1173 The correct technique is to start with a strong random seed, take
1174 cryptographically strong steps from that seed [FERGUSON, SCHNEIER],
1175 and do not reveal the complete state of the generator in the sequence
1176 elements. If each value in the sequence can be calculated in a fixed
1177 way from the previous value, then when any value is compromised, all
1178 future values can be determined. This would be the case, for example,
1179 if each value were a constant function of the previously used values,
1180 even if the function were a very strong, non-invertible message
1181 digest function.
1183 (It should be noted that if your technique for generating a sequence
1184 of key values is fast enough, it can trivially be used as the basis
1185 for a confidentiality system. If two parties use the same sequence
1186 generating technique and start with the same seed material, they will
1187 generate identical sequences. These could, for example, be xor'ed at
1188 one end with data being send, encrypting it, and xor'ed with this
1189 data as received, decrypting it due to the reversible properties of
1190 the xor operation. This is commonly referred to as a simple stream
1191 cipher.)
1193 6.2.1 OFB and CTR Sequences
1195 One way to achieve a strong sequence is to have the values be
1196 produced by taking a seed value and hashing the quantities produced
1197 by concatenating the seed with successive integers or the like and
1198 then mask the values obtained so as to limit the amount of generator
1199 state available to the adversary.
1201 It may also be possible to use an "encryption" algorithm with a
1202 random key and seed value to encrypt successive integers as in
1203 counter (CTR) mode encryption. Alternatively, you can feedback all of
1204 the output value from encryption into the value to be encrypted for
1205 the next iteration. This is a particular example of output feedback
1206 mode (OFB). [MODES]
1208 An example is shown below where shifting and masking are used to
1209 combine part of the output feedback with part of the old input. This
1210 type of partial feedback should be avoided for reasons described
1211 below.
1213 +---------------+
1214 | V |
1215 | | n |--+
1216 +--+------------+ |
1217 | | +---------+
1218 shift| +---> | | +-----+
1219 +--+ | Encrypt | <--- | Key |
1220 | +-------- | | +-----+
1221 | | +---------+
1222 V V
1223 +------------+--+
1224 | V | |
1225 | n+1 |
1226 +---------------+
1228 Note that if a shift of one is used, this is the same as the shift
1229 register technique described in Section 3 above but with the all
1230 important difference that the feedback is determined by a complex
1231 non-linear function of all bits rather than a simple linear or
1232 polynomial combination of output from a few bit position taps.
1234 It has been shown by Donald W. Davies that this sort of shifted
1235 partial output feedback significantly weakens an algorithm compared
1236 with feeding all of the output bits back as input. In particular, for
1237 DES, repeated encrypting a full 64 bit quantity will give an expected
1238 repeat in about 2^63 iterations. Feeding back anything less than 64
1239 (and more than 0) bits will give an expected repeat in between 2^31
1240 and 2^32 iterations!
1242 To predict values of a sequence from others when the sequence was
1243 generated by these techniques is equivalent to breaking the
1244 cryptosystem or inverting the "non-invertible" hashing involved with
1245 only partial information available. The less information revealed
1246 each iteration, the harder it will be for an adversary to predict the
1247 sequence. Thus it is best to use only one bit from each value. It has
1248 been shown that in some cases this makes it impossible to break a
1249 system even when the cryptographic system is invertible and can be
1250 broken if all of each generated value was revealed.
1252 6.2.2 The Blum Blum Shub Sequence Generator
1254 Currently the generator which has the strongest public proof of
1255 strength is called the Blum Blum Shub generator after its inventors
1256 [BBS]. It is also very simple and is based on quadratic residues.
1257 Its only disadvantage is that it is computationally intensive
1258 compared with the traditional techniques give in 6.1.3 above. This is
1259 not a major draw back if it is used for moderately infrequent
1260 purposes, such as generating session keys.
1262 Simply choose two large prime numbers, say p and q, which both have
1263 the property that you get a remainder of 3 if you divide them by 4.
1264 Let n = p * q. Then you choose a random number x relatively prime to
1265 n. The initial seed for the generator and the method for calculating
1266 subsequent values are then
1268 2
1269 s = ( x )(Mod n)
1270 0
1272 2
1273 s = ( s )(Mod n)
1274 i+1 i
1276 You must be careful to use only a few bits from the bottom of each s.
1277 It is always safe to use only the lowest order bit. If you use no
1278 more than the
1279 log ( log ( s ) )
1280 2 2 i
1281 low order bits, then predicting any additional bits from a sequence
1282 generated in this manner is provable as hard as factoring n. As long
1283 as the initial x is secret, you can even make n public if you want.
1285 An interesting characteristic of this generator is that you can
1286 directly calculate any of the s values. In particular
1288 i
1289 ( ( 2 )(Mod (( p - 1 ) * ( q - 1 )) ) )
1290 s = ( s )(Mod n)
1291 i 0
1293 This means that in applications where many keys are generated in this
1294 fashion, it is not necessary to save them all. Each key can be
1295 effectively indexed and recovered from that small index and the
1296 initial s and n.
1298 6.3 Entropy Pool Techniques
1300 Many modern pseudo-random number sources, such as those describe in
1301 Sections 7.1.2 and 7.1.3, utilize the technique of maintaining a
1302 "pool" of bits and providing operations for strongly mixing input
1303 with some randomness into the pool and extracting pseudo random bits
1304 from the pool. This is illustrated in the figure below.
1306 +--------+ +------+ +---------+
1307 --->| Mix In |--->| POOL |--->| Extract |--->
1308 | Bits | | | | Bits |
1309 +--------+ +------+ +---------+
1310 ^ V
1311 | |
1312 +-----------+
1314 Bits to be feed into the pool can be any of the various hardware,
1315 environmental, or user input sources discussed above. It is also
1316 common to save the state of the pool on system shut down and restore
1317 it on re-starting, if stable storage is available.
1319 Care must be taken that enough entropy has been added to the pool to
1320 support particular output uses desired. See [RSA BULL1] for similar
1321 suggestions.
1323 7. Randomness Generation Examples and Standards
1325 Several public standards and widely deployed examples are now in
1326 place for the generation of keys or other cryptographically random
1327 quantities. Some, in section 7.1 below, include an entropy source.
1328 Others, described in section 7.2, provide the pseudo-random number
1329 strong sequence generator but assume the input of a random seed or
1330 input from a source of entropy.
1332 7.1 Complete Randomness Generators
1334 Three standards are described below. The two older standards use
1335 DES, with its 64-bit block and key size limit, but any equally strong
1336 or stronger mixing function could be substituted [DES]. The third is
1337 a more modern and stronger standard based on SHA-1 [SHA*]. Lastly
1338 the widely deployed modern UNIX and Windows random number generators
1339 are described.
1341 7.1.1 US DoD Recommendations for Password Generation
1343 The United States Department of Defense has specific recommendations
1344 for password generation [DoD]. They suggest using the US Data
1345 Encryption Standard [DES] in Output Feedback Mode [MODES] as follows:
1347 use an initialization vector determined from
1348 the system clock,
1349 system ID,
1350 user ID, and
1351 date and time;
1352 use a key determined from
1353 system interrupt registers,
1354 system status registers, and
1355 system counters; and,
1356 as plain text, use an external randomly generated 64 bit
1357 quantity such as the ASCII bytes for 8 characters typed in by a
1358 system administrator.
1360 The password can then be calculated from the 64 bit "cipher text"
1361 generated by DES in 64-bit Output Feedback Mode. As many bits as are
1362 needed can be taken from these 64 bits and expanded into a
1363 pronounceable word, phrase, or other format if a human being needs to
1364 remember the password.
1366 7.1.2 The /dev/random Device
1368 Several versions of the UNIX operating system provide a kernel-
1369 resident random number generator. In some cases, these generators
1370 make use of events captured by the Kernel during normal system
1371 operation.
1373 For example, on some versions of Linux, the generator consists of a
1374 random pool of 512 bytes represented as 128 words of 4-bytes each.
1375 When an event occurs, such as a disk drive interrupt, the time of the
1376 event is XORed into the pool and the pool is stirred via a primitive
1377 polynomial of degree 128. The pool itself is treated as a ring
1378 buffer, with new data being XORed (after stirring with the
1379 polynomial) across the entire pool.
1381 Each call that adds entropy to the pool estimates the amount of
1382 likely true entropy the input contains. The pool itself contains a
1383 accumulator that estimates the total over all entropy of the pool.
1385 Input events come from several sources as listed below.
1386 Unfortunately, for server machines without human operators, the first
1387 and third are not available and entropy may be added slowly in that
1388 case.
1390 1. Keyboard interrupts. The time of the interrupt as well as the scan
1391 code are added to the pool. This in effect adds entropy from the
1392 human operator by measuring inter-keystroke arrival times.
1394 2. Disk completion and other interrupts. A system being used by a
1395 person will likely have a hard to predict pattern of disk
1396 accesses. (But not all disk drivers support capturing this timing
1397 information with sufficient accuracy to be useful.)
1399 3. Mouse motion. The timing as well as mouse position is added in.
1401 When random bytes are required, the pool is hashed with SHA-1 [SHA*]
1402 to yield the returned bytes of randomness. If more bytes are required
1403 than the output of SHA-1 (20 bytes), then the hashed output is
1404 stirred back into the pool and a new hash performed to obtain the
1405 next 20 bytes. As bytes are removed from the pool, the estimate of
1406 entropy is similarly decremented.
1408 To ensure a reasonable random pool upon system startup, the standard
1409 startup and shutdown scripts save the pool to a disk file at shutdown
1410 and read this file at system startup.
1412 There are two user exported interfaces. /dev/random returns bytes
1413 from the pool, but blocks when the estimated entropy drops to zero.
1414 As entropy is added to the pool from events, more data becomes
1415 available via /dev/random. Random data obtained from such a
1416 /dev/random device is suitable for key generation for long term keys,
1417 if enough random bits are in the pool or are added in a reasonable
1418 amount of time.
1420 /dev/urandom works like /dev/random, however it provides data even
1421 when the entropy estimate for the random pool drops to zero. This may
1422 be adequate for session keys or for other key generation tasks where
1423 blocking while waiting for more random bits is not acceptable. The
1424 risk of continuing to take data even when the pool's entropy
1425 estimate is small in that past output may be computable from current
1426 output provided an attacker can reverse SHA-1. Given that SHA-1 is
1427 designed to be non-invertible, this is a reasonable risk.
1429 To obtain random numbers under Linux, Solaris, or other UNIX systems
1430 equipped with code as described above, all an application needs to do
1431 is open either /dev/random or /dev/urandom and read the desired
1432 number of bytes.
1434 (The Linux Random device was written by Theodore Ts'o. It was based
1435 loosely on the random number generator in PGP 2.X and PGP 3.0 (aka
1436 PGP 5.0).)
1438 7.1.3 Windows CryptGenRandom
1440 Microsoft's recommendation to users of the widely deployed Windows
1441 operating system is generally to use the CryptGenRandom pseudo-random
1442 number generation call with the CryptAPI cryptographic service
1443 provider. This takes a handle to a cryptographic service provider
1444 library, a pointer to a buffer by which the caller can provide
1445 entropy and into which the generated pseudo-randomness is returned,
1446 and an indication of how many octets of randomness are desired.
1448 The Windows CryptAPI cryptographic service provider stores a seed
1449 state variable with every user. When CryptGenRandom is called, this
1450 is combined with any randomness provided in the call and various
1451 system and user data such as the process ID, thread ID, system clock,
1452 system time, system counter, memory status, free disk clusters, and
1453 hashed user environment block. This data is all feed to SHA-1 and the
1454 output used to seed an RC4 key stream. That key stream is used to
1455 produce the pseudo-random data requested and to update the user's
1456 seed state variable.
1458 Users of Windows ".NET" will probably find it easier to use the
1459 RNGCryptoServiceProvider.GetBytes method interface.
1461 For further information, see [WSC].
1463 7.2 Generators Assuming a Source of Entropy
1465 The pseudo-random number generators described in the following three
1466 sections all assume that a seed value with sufficient entropy is
1467 provided to them. They then generate a strong sequence (see Section
1468 6.2) from that seed.
1470 7.2.1 X9.82 Pseudo-Random Number Generation
1472 The ANSI X9F1 committee is in the final stages of creating a standard
1473 for random number generation covering both true randomness generators
1474 and pseudo-random number generators. It includes a number of pseudo-
1475 random number generators based on hash functions one of which will
1476 probably be based on HMAC SHA hash constructs [HMAC]. The draft
1477 version of this generated is as described below omitting a number of
1478 optional features [X9.82].
1480 In the description in the subsections below, the HMAC hash construct
1481 is simply referred to as HMAC but, of course, in an particular use, a
1482 particular standard SHA function must be selected. Generally
1483 speaking, if the strength of the pseudo-random values to be generated
1484 is to be N bits, the SHA function chosen must be one generating N or
1485 more bits of output and a source of at least N bits of input entropy
1486 will be required. The same hash function must be used throughout an
1487 instantiation of this generator.
1489 7,2.1.1 Notation
1491 In the following sections the notation give below is used:
1493 hash_length is the output size of the underlying hash function in
1494 use.
1496 input_entropy is the input bit string that provides entropy to the
1497 generator.
1499 K is a bit string of size hash_length that is part of the state of
1500 the generator and is updated at least once each time random
1501 bits are generated.
1503 V is a bit string of size hash_length and is part of the state of
1504 the generator which is updated each time hash_length bits of
1505 output are generated.
1507 | represents concatenation
1509 7.1.2.2 Initializing the Generator
1511 Set V to all zero bytes except that the low order bit of each byte is
1512 set to one.
1514 Set K to all zero bytes.
1516 K = HMAC ( K, V | 0x00 | input_entropy )
1518 V = HMAC ( K, V )
1520 K = HMAC ( K, V | 0x01 | input_entropy )
1522 V = HMAC ( K, V )
1524 Note: all SHA algorithms produce an integral number of bytes of the
1525 length of K and V will be an integral number of bytes.
1527 7.1.2.5 Generating Random Bits
1529 When output is called for simply set
1531 V = HMAC ( K, V )
1533 and use leading bits from V. If more bits are needed than the length
1534 of V, set "temp" to a null bit string and then repeatedly perform
1536 V = HMAC ( K, V )
1537 temp = temp | V
1539 stopping as soon a temp is equal to or longer than the number of
1540 random bits called for and use the called for number of leading bits
1541 from temp. The definition of the algorithm prohibits calling from
1542 more than 2**35 bits.
1544 7.2.2 X9.17 Key Generation
1546 The American National Standards Institute has specified a method for
1547 generating a sequence of keys as follows [X9.17]:
1549 s is the initial 64 bit seed
1550 0
1552 g is the sequence of generated 64 bit key quantities
1553 n
1555 k is a random key reserved for generating this key sequence
1557 t is the time at which a key is generated to as fine a resolution
1558 as is available (up to 64 bits).
1560 DES ( K, Q ) is the DES encryption of quantity Q with key K
1562 g = DES ( k, DES ( k, t ) .xor. s )
1563 n n
1565 s = DES ( k, DES ( k, t ) .xor. g )
1566 n+1 n
1568 If g sub n is to be used as a DES key, then every eighth bit should
1569 be adjusted for parity for that use but the entire 64 bit unmodified
1570 g should be used in calculating the next s.
1572 7.2.3 DSS Pseudo-Random Number Generation
1574 Appendix 3 of the NIST Digital Signature Standard [DSS] provides a
1575 method of producing a sequence of pseudo-random 160 bit quantities
1576 for use as private keys or the like. This has been modified by Change
1577 Notice 1 [DSS CN1] to produce the following algorithm for generating
1578 general purpose pseudorandom numbers:
1580 t = 0x 67452301 EFCDAB89 98BADCFE 10325476 C3D2E1F0
1582 XKEY = initial seed
1583 0
1585 For j = 0 to ...
1587 XVAL = ( XKEY + optional user input ) (Mod 2^512)
1588 j
1590 X = G( t, XVAL )
1591 j
1593 XKEY = ( 1 + XKEY + X ) (Mod 2^512)
1594 j+1 j j
1596 The quantities X thus produced are the pseudo-random sequence of 160
1597 bit values. Two functions can be used for "G" above. Each produces
1598 a 160-bit value and takes two arguments, the first argument a 160-bit
1599 value and the second a 512 bit value.
1601 The first is based on SHA-1 and works by setting the 5 linking
1602 variables, denoted H with subscripts in the SHA-1 specification, to
1603 the first argument divided into fifths. Then steps (a) through (e) of
1604 section 7 of the NIST SHA-1 specification are run over the second
1605 argument as if it were a 512-bit data block. The values of the
1606 linking variable after those steps are then concatenated to produce
1607 the output of G. [SHA*]
1609 As an alternative second method, NIST also defined an alternate G
1610 function based on multiple applications of the DES encryption
1611 function [DSS].
1613 8. Examples of Randomness Required
1615 Below are two examples showing rough calculations of needed
1616 randomness for security. The first is for moderate security passwords
1617 while the second assumes a need for a very high security
1618 cryptographic key.
1620 In addition [ORMAN] and [RSA BULL13] provide information on the
1621 public key lengths that should be used for exchanging symmetric keys.
1623 8.1 Password Generation
1625 Assume that user passwords change once a year and it is desired that
1626 the probability that an adversary could guess the password for a
1627 particular account be less than one in a thousand. Further assume
1628 that sending a password to the system is the only way to try a
1629 password. Then the crucial question is how often an adversary can try
1630 possibilities. Assume that delays have been introduced into a system
1631 so that, at most, an adversary can make one password try every six
1632 seconds. That's 600 per hour or about 15,000 per day or about
1633 5,000,000 tries in a year. Assuming any sort of monitoring, it is
1634 unlikely someone could actually try continuously for a year. In fact,
1635 even if log files are only checked monthly, 500,000 tries is more
1636 plausible before the attack is noticed and steps taken to change
1637 passwords and make it harder to try more passwords.
1639 To have a one in a thousand chance of guessing the password in
1640 500,000 tries implies a universe of at least 500,000,000 passwords or
1641 about 2^29. Thus 29 bits of randomness are needed. This can probably
1642 be achieved using the US DoD recommended inputs for password
1643 generation as it has 8 inputs which probably average over 5 bits of
1644 randomness each (see section 7.1). Using a list of 1000 words, the
1645 password could be expressed as a three word phrase (1,000,000,000
1646 possibilities) or, using case insensitive letters and digits, six
1647 would suffice ((26+10)^6 = 2,176,782,336 possibilities).
1649 For a higher security password, the number of bits required goes up.
1650 To decrease the probability by 1,000 requires increasing the universe
1651 of passwords by the same factor which adds about 10 bits. Thus to
1652 have only a one in a million chance of a password being guessed under
1653 the above scenario would require 39 bits of randomness and a password
1654 that was a four word phrase from a 1000 word list or eight
1655 letters/digits. To go to a one in 10^9 chance, 49 bits of randomness
1656 are needed implying a five word phrase or ten letter/digit password.
1658 In a real system, of course, there are also other factors. For
1659 example, the larger and harder to remember passwords are, the more
1660 likely users are to write them down resulting in an additional risk
1661 of compromise.
1663 8.2 A Very High Security Cryptographic Key
1665 Assume that a very high security key is needed for symmetric
1666 encryption / decryption between two parties. Assume an adversary can
1667 observe communications and knows the algorithm being used. Within the
1668 field of random possibilities, the adversary can try key values in
1669 hopes of finding the one in use. Assume further that brute force
1670 trial of keys is the best the adversary can do.
1672 8.2.1 Effort per Key Trial
1674 How much effort will it take to try each key? For very high security
1675 applications it is best to assume a low value of effort. Even if it
1676 would clearly take tens of thousands of computer cycles or more to
1677 try a single key, there may be some pattern that enables huge blocks
1678 of key values to be tested with much less effort per key. Thus it is
1679 probably best to assume no more than a couple hundred cycles per key.
1680 (There is no clear lower bound on this as computers operate in
1681 parallel on a number of bits and a poor encryption algorithm could
1682 allow many keys or even groups of keys to be tested in parallel.
1683 However, we need to assume some value and can hope that a reasonably
1684 strong algorithm has been chosen for our hypothetical high security
1685 task.)
1687 If the adversary can command a highly parallel processor or a large
1688 network of work stations, 10^11 cycles per second is probably a
1689 minimum assumption for availability today. Looking forward a few
1690 years, there should be at least an order of magnitude improvement.
1691 Thus assuming 10^10 keys could be checked per second or 3.6*10^12 per
1692 hour or 6*10^14 per week or 2.4*10^15 per month is reasonable. This
1693 implies a need for a minimum of 63 bits of randomness in keys to be
1694 sure they cannot be found in a month. Even then it is possible that,
1695 a few years from now, a highly determined and resourceful adversary
1696 could break the key in 2 weeks (on average they need try only half
1697 the keys).
1699 These questions are considered in detail in "Minimal Key Lengths for
1700 Symmetric Ciphers to Provide Adequate Commercial Security: A Report
1701 by an Ad Hoc Group of Cryptographers and Computer Scientists"
1702 [KeyStudy] which was sponsored by the Business Software Alliance. It
1703 concluded that a reasonable key length in 1995 for very high security
1704 is in the range of 75 to 90 bits and, since the cost of cryptography
1705 does not vary much with they key size, recommends 90 bits. To update
1706 these recommendations, just add 2/3 of a bit per year for Moore's
1707 law [MOORE]. Thus, in the year 2004, this translates to a
1708 determination that a reasonable key length is in the 81 to 96 bit
1709 range. In fact, today, it is increasingly common to use keys longer
1710 than 96 bits, such as 128-bit (or longer) keys with AES and keys with
1711 effective lengths of 112-bits using triple-DES.
1713 8.2.2 Meet in the Middle Attacks
1715 If chosen or known plain text and the resulting encrypted text are
1716 available, a "meet in the middle" attack is possible if the structure
1717 of the encryption algorithm allows it. (In a known plain text attack,
1718 the adversary knows all or part of the messages being encrypted,
1719 possibly some standard header or trailer fields. In a chosen plain
1720 text attack, the adversary can force some chosen plain text to be
1721 encrypted, possibly by "leaking" an exciting text that would then be
1722 sent by the adversary over an encrypted channel.)
1724 An oversimplified explanation of the meet in the middle attack is as
1725 follows: the adversary can half-encrypt the known or chosen plain
1726 text with all possible first half-keys, sort the output, then half-
1727 decrypt the encoded text with all the second half-keys. If a match is
1728 found, the full key can be assembled from the halves and used to
1729 decrypt other parts of the message or other messages. At its best,
1730 this type of attack can halve the exponent of the work required by
1731 the adversary while adding a very large but roughly constant factor
1732 of effort. Thus, if this attack can be mounted, a doubling of the
1733 amount of randomness in the very strong key to a minimum of 192 bits
1734 (96*2) is required for the year 2004 based on the [KeyStudy]
1735 analysis.
1737 This amount of randomness is well beyond the limit of that in the
1738 inputs recommended by the US DoD for password generation and could
1739 require user typing timing, hardware random number generation, or
1740 other sources.
1742 The meet in the middle attack assumes that the cryptographic
1743 algorithm can be decomposed in this way. Hopefully no modern
1744 algorithm has this weakness but there may be cases where we are not
1745 sure of that or even of what algorithm a key will be used with. Even
1746 if a basic algorithm is not subject to a meet in the middle attack,
1747 an attempt to produce a stronger algorithm by applying the basic
1748 algorithm twice (or two different algorithms sequentially) with
1749 different keys will gain less added security than would be expected.
1750 Such a composite algorithm would be subject to a meet in the middle
1751 attack.
1753 Enormous resources may be required to mount a meet in the middle
1754 attack but they are probably within the range of the national
1755 security services of a major nation. Essentially all nations spy on
1756 other nations traffic.
1758 8.2.3 Other Considerations
1760 [KeyStudy] also considers the possibilities of special purpose code
1761 breaking hardware and having an adequate safety margin.
1763 It should be noted that key length calculations such at those above
1764 are controversial and depend on various assumptions about the
1765 cryptographic algorithms in use. In some cases, a professional with a
1766 deep knowledge of code breaking techniques and of the strength of the
1767 algorithm in use could be satisfied with less than half of the 192
1768 bit key size derived above.
1770 For further examples of conservative design principles see
1771 [FERGUSON].
1773 9. Conclusion
1775 Generation of unguessable "random" secret quantities for security use
1776 is an essential but difficult task.
1778 Hardware techniques to produce the needed entropy would be relatively
1779 simple. In particular, the volume and quality would not need to be
1780 high and existing computer hardware, such as audio input or disk
1781 drives, can be used.
1783 Widely available computational techniques are available to process
1784 low quality random quantities from multiple sources or a larger
1785 quantity of such low quality input from one source and produce a
1786 smaller quantity of higher quality keying material. In the absence of
1787 hardware sources of randomness, a variety of user and software
1788 sources can frequently, with care, be used instead; however, most
1789 modern systems already have hardware, such as disk drives or audio
1790 input, that could be used to produce high quality randomness.
1792 Once a sufficient quantity of high quality seed key material (a
1793 couple of hundred bits) is available, computational techniques are
1794 available to produce cryptographically strong sequences of
1795 computationally unpredictable quantities from this seed material.
1797 10. Security Considerations
1799 The entirety of this document concerns techniques and recommendations
1800 for generating unguessable "random" quantities for use as passwords,
1801 cryptographic keys, initialization vectors, sequence numbers, and
1802 similar security uses.
1804 11. Copyright and Disclaimer
1806 Copyright (C) The Internet Society 2005. This document is subject to
1807 the rights, licenses and restrictions contained in BCP 78 and except
1808 as set forth therein, the authors retain all their rights.
1810 This document and the information contained herein are provided on an
1811 "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
1812 OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET
1813 ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED,
1814 INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
1815 INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
1816 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
1818 12. Appendix A: Changes from RFC 1750
1820 1. Additional acknowledgements have been added.
1822 2. Insertion of section 5.3 on mixing with S-boxes.
1824 3. Addition of section 3.3 on Ring Oscillator randomness sources.
1826 4. AES and the members of the SHA series producing more than 160
1827 bits have been added. Use of AES has been emphasized and the use
1828 of DES de-emphasized.
1830 5. Addition of section 6.3 on entropy pool techniques.
1832 6. Addition of section 7.2.3 on the pseudo-random number generation
1833 techniques given in FIPS 186-2 (with Change Notice 1), 7.2.1 on
1834 those given in X9.82, section 7.1.2 on the random number
1835 generation techniques of the /dev/random device in Linux and
1836 other UNIX systems, and section 7.1.3 on random number generation
1837 techniques in the Windows operating system.
1839 7. Addition of references to the "Minimal Key Lengths for Symmetric
1840 Ciphers to Provide Adequate Commercial Security" study published
1841 in January 1996 [KeyStudy] and to [RFC 1948].
1843 8. Added caveats to using Diffie-Hellman as a mixing function and,
1844 because of those caveats and its computationally intensive
1845 nature, recommend against its use.
1847 9. Addition of references to the X9.82 effort and the [TURBID] and
1848 [NASLUND] papers.
1850 10. Addition of discussion of min-entropy and Renyi entropy and
1851 references to the [LUBY] book.
1853 11. Major restructuring, minor wording changes, and a variety of
1854 reference updates.
1856 13. Informative References
1858 [AES] - "Specification of the Advanced Encryption Standard (AES)",
1859 United States of America, US National Institute of Standards and
1860 Technology, FIPS 197, November 2001.
1862 [ASYMMETRIC] - "Secure Communications and Asymmetric Cryptosystems",
1863 edited by Gustavus J. Simmons, AAAS Selected Symposium 69, Westview
1864 Press, Inc.
1866 [BBS] - "A Simple Unpredictable Pseudo-Random Number Generator", SIAM
1867 Journal on Computing, v. 15, n. 2, 1986, L. Blum, M. Blum, & M. Shub.
1869 [BRILLINGER] - "Time Series: Data Analysis and Theory", Holden-Day,
1870 1981, David Brillinger.
1872 [CRC] - "C.R.C. Standard Mathematical Tables", Chemical Rubber
1873 Publishing Company.
1875 [DAVIS] - "Cryptographic Randomness from Air Turbulence in Disk
1876 Drives", Advances in Cryptology - Crypto '94, Springer-Verlag
1877 Lecture Notes in Computer Science #839, 1984, Don Davis, Ross Ihaka,
1878 and Philip Fenstermacher.
1880 [DES] - "Data Encryption Standard", US National Institute of
1881 Standards and Technology, FIPS 46-3, October 1999.
1882 - "Data Encryption Algorithm", American National Standards
1883 Institute, ANSI X3.92-1981.
1884 (See also FIPS 112, Password Usage, which includes FORTRAN
1885 code for performing DES.)
1887 [D-H] - RFC 2631, "Diffie-Hellman Key Agreement Method", Eric
1888 Rescrola, June 1999.
1890 [DNSSEC] - RFC 2535, "Domain Name System Security Extensions", D.
1891 Eastlake, March 1999.
1893 [DoD] - "Password Management Guideline", United States of America,
1894 Department of Defense, Computer Security Center, CSC-STD-002-85.
1895 (See also FIPS 112, Password Usage, which incorporates CSC-STD-002-85
1896 as one of its appendices.)
1898 [DSS] - "Digital Signature Standard (DSS)", US National Institute of
1899 Standards and Technology, FIPS 186-2, January 2000.
1901 [DSS CN1] - "Digital Signature Standard Change Notice 1", US National
1902 Institute of Standards and Technology, FIPS 186-2 Change Notice 1, 5
1903 October 2001.
1905 [FERGUSON] - "Practical Cryptography", Niels Ferguson and Bruce
1906 Schneier, Wiley Publishing Inc., ISBN 047122894X, April 2003.
1908 [GIFFORD] - "Natural Random Number", MIT/LCS/TM-371, David K.
1909 Gifford, September 1988.
1911 [IEEE 802.11i] - "Amendment to Standard for Telecommunications and
1912 Information Exchange Between Systems - LAN/MAN Specific Requirements
1913 - Part 11: Wireless Medium Access Control (MAC) and physical layer
1914 (PHY) specifications: Medium Access Control (MAC) Security
1915 Enhancements", The Institute for Electrical and Electronics
1916 Engineers, January 2004.
1918 [IPSEC] - RFC 2401, "Security Architecture for the Internet
1919 Protocol", S. Kent, R. Atkinson, November 1998.
1921 [Jakobsson] - M. Jakobsson, E. Shriver, B. K. Hillyer, and A. Juels,
1922 "A practical secure random bit generator", Proceedings of the Fifth
1923 ACM Conference on Computer and Communications Security, 1998. See
1924 also http://citeseer.ist.psu.edu/article/jakobsson98practical.html.
1926 [KAUFMAN] - "Network Security: Private Communication in a Public
1927 World", Charlie Kaufman, Radia Perlman, and Mike Speciner, Prentis
1928 Hall PTR, ISBN 0-13-046019-2, 2nd Edition 2002.
1930 [KeyStudy] - "Minimal Key Lengths for Symmetric Ciphers to Provide
1931 Adequate Commercial Security: A Report by an Ad Hoc Group of
1932 Cryptographers and Computer Scientists", M. Blaze, W. Diffie, R.
1933 Rivest, B. Schneier, T. Shimomura, E. Thompson, and M. Weiner,
1934 January 1996, .
1936 [KNUTH] - "The Art of Computer Programming", Volume 2: Seminumerical
1937 Algorithms, Chapter 3: Random Numbers, Donald E. Knuth, Addison
1938 Wesley Publishing Company, 3rd Edition November 1997.
1940 [KRAWCZYK] - "How to Predict Congruential Generators", H. Krawczyk,
1941 Journal of Algorithms, V. 13, N. 4, December 1992.
1943 [LUBY] - "Pseudorandomness and Cryptographic Applications", Michael
1944 Luby, Princeton University Press, ISBN 0691025460, 8 January 1996.
1946 [MAIL PEM 1] - RFC 1421, "Privacy Enhancement for Internet Electronic
1947 Mail: Part I: Message Encryption and Authentication Procedures", J.
1948 Linn, 02/10/1993.
1949 [MAIL PEM 2] - RFC 1422, "Privacy Enhancement for Internet
1950 Electronic Mail: Part II: Certificate-Based Key Management", S. Kent,
1951 02/10/1993.
1952 [MAIL PEM 3] - RFC 1423, "Privacy Enhancement for Internet
1953 Electronic Mail: Part III: Algorithms, Modes, and Identifiers", D.
1954 Balenson, 02/10/1993.
1955 [MAIL PEM 4] - RFC 1424, "Privacy Enhancement for Internet
1957 Electronic Mail: Part IV: Key Certification and Related Services", B.
1958 Kaliski, 02/10/1993.
1960 [MAIL PGP]
1961 - RFC 2440, "OpenPGP Message Format", J. Callas, L.
1962 Donnerhacke, H. Finney, R. Thayer, November 1998.
1963 - RFC 3156, "MIME Security with OpenPGP" M. Elkins, D. Del
1964 Torto, R. Levien, T. Roessler, August 2001.
1966 [MAIL S/MIME] - RFCs 2632 through 2634:
1967 - RFC 2632, "S/MIME Version 3 Certificate Handling", B.
1968 Ramsdell, Ed., June 1999.
1969 - RFC 2633, "S/MIME Version 3 Message Specification", B.
1970 Ramsdell, Ed., June 1999.
1971 - RFC 2634, "Enhanced Security Services for S/MIME" P.
1972 Hoffman, Ed., June 1999.
1974 [MD4] - "The MD4 Message-Digest Algorithm", RFC1320, April 1992, R.
1975 Rivest
1977 [MD5] - "The MD5 Message-Digest Algorithm", RFC1321, April 1992, R.
1978 Rivest
1980 [MODES] - "DES Modes of Operation", US National Institute of
1981 Standards and Technology, FIPS 81, December 1980.
1982 - "Data Encryption Algorithm - Modes of Operation", American
1983 National Standards Institute, ANSI X3.106-1983.
1985 [MOORE] - Moore's Law: the exponential increase in the logic density
1986 of silicon circuits. Originally formulated by Gordon Moore in 1964 as
1987 a doubling every year starting in 1962, in the late 1970s the rate
1988 fell to a doubling every 18 months and has remained there through the
1989 date of this document. See "The New Hacker's Dictionary", Third
1990 Edition, MIT Press, ISBN 0-262-18178-9, Eric S. Raymond, 1996.
1992 [NASLUND] - "Extraction of Optimally Unbiased Bits from a Biased
1993 Source", M. Naslund and A. Russell, IEEE Transactions on Information
1994 Theory. 46(3), May 2000.
1995
1997 [ORMAN] - "Determining Strengths For Public Keys Used For Exchanging
1998 Symmetric Keys", RFC 3766, Hilarie Orman, Paul Hoffman, April 2004.
2000 [RFC 1750] - "Randomness Requirements for Security", D. Eastlake, S.
2001 Crocker, J. Schiller, December 1994.
2003 [RFC 1948] - "Defending Against Sequence Number Attacks", S.
2004 Bellovin, May 1986.
2006 [RSA BULL1] - "Suggestions for Random Number Generation in Software",
2007 RSA Laboratories Bulletin #1, January 1996.
2009 [RSA BULL13] - "A Cost-Based Security Analysis of Symmetric and
2010 Asymmetric Key Lengths", RSA Laboratories Bulletin #13, Robert
2011 Silverman, April 2000 (revised November 2001).
2013 [SBOX1] - "Practical s-box design", S. Mister, C. Adams, Selected
2014 Areas in Cryptography, 1996.
2016 [SBOX2] - "Perfect Non-linear S-boxes", K. Nyberg, Advances in
2017 Cryptography - Eurocrypt '91 Proceedings, Springer-Verland, 1991.
2019 [SCHNEIER] - "Applied Cryptography: Protocols, Algorithms, and Source
2020 Code in C", Bruce Schneier, 2nd Edition, John Wiley & Sons, 1996.
2022 [SHANNON] - "The Mathematical Theory of Communication", University of
2023 Illinois Press, 1963, Claude E. Shannon. (originally from: Bell
2024 System Technical Journal, July and October 1948)
2026 [SHIFT1] - "Shift Register Sequences", Solomon W. Golomb, Aegean Park
2027 Press, Revised Edition 1982.
2029 [SHIFT2] - "Cryptanalysis of Shift-Register Generated Stream Cypher
2030 Systems", Wayne G. Barker, Aegean Park Press, 1984.
2032 [SHA] - "Secure Hash Standard", US National Institute of Science and
2033 Technology, FIPS 180-2, 1 August 2002.
2035 [SHA RFC] - RFC 3174, "US Secure Hash Algorithm 1 (SHA1)", D.
2036 Eastlake, P. Jones, September 2001.
2038 [SSH] - draft-ietf-secsh-*, work in progress.
2040 [STERN] - "Secret Linear Congruential Generators are not
2041 Cryptographically Secure", J. Stern, Proceedings of IEEE STOC, 1987.
2043 [TLS] - RFC 2246, "The TLS Protocol Version 1.0", T. Dierks, C.
2044 Allen, January 1999.
2046 [TURBID] - "High Entropy Symbol Generator", John S. Denker,
2047 , 2003.
2049 [USENET] - RFC 977, "Network News Transfer Protocol", B. Kantor, P.
2050 Lapsley, February 1986.
2051 - RFC 2980, "Common NNTP Extensions", S. Barber, October
2052 2000.
2054 [VON NEUMANN] - "Various techniques used in connection with random
2055 digits", von Neumann's Collected Works, Vol. 5, Pergamon Press,
2056 1963, J. von Neumann.
2058 [WSC] - "Writing Secure Code, Second Edition", Michael Howard, David.
2059 C. LeBlanc, Microsoft Press, ISBN 0735617228, December 2002.
2061 [X9.17] - "American National Standard for Financial Institution Key
2062 Management (Wholesale)", American Bankers Association, 1985.
2064 [X9.82] - "Random Number Generation", American National Standards
2065 Institute, ANSI X9F1, work in progress.
2066 Part 1 - Overview and General Principles.
2067 Part 2 - Non-Deterministic Random Bit Generators
2068 Part 3 - Deterministic Random Bit Generators
2070 Author's Addresses
2072 Donald E. Eastlake 3rd
2073 Motorola Laboratories
2074 155 Beaver Street
2075 Milford, MA 01757 USA
2077 Telephone: +1 508-786-7554 (w)
2078 +1 508-634-2066 (h)
2079 EMail: Donald.Eastlake@motorola.com
2081 Jeffrey I. Schiller
2082 MIT, Room E40-311
2083 77 Massachusetts Avenue
2084 Cambridge, MA 02139-4307 USA
2086 Telephone: +1 617-253-0161
2087 E-mail: jis@mit.edu
2089 Steve Crocker
2091 EMail: steve@stevecrocker.com
2093 File Name and Expiration
2095 This is file draft-eastlake-randomness2-10.txt.
2097 It expires July 2005.