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