As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers.
Alternatively you can here view or download the uninterpreted source code file.

1 2 3 4 5 6 7 Network Working Group D. Eastlake, 3rd 8 Request for Comments: 1750 DEC 9 Category: Informational S. Crocker 10 Cybercash 11 J. Schiller 12 MIT 13 December 1994 14 15 16 Randomness Recommendations for Security 17 18 Status of this Memo 19 20 This memo provides information for the Internet community. This memo 21 does not specify an Internet standard of any kind. Distribution of 22 this memo is unlimited. 23 24 Abstract 25 26 Security systems today are built on increasingly strong cryptographic 27 algorithms that foil pattern analysis attempts. However, the security 28 of these systems is dependent on generating secret quantities for 29 passwords, cryptographic keys, and similar quantities. The use of 30 pseudo-random processes to generate secret quantities can result in 31 pseudo-security. The sophisticated attacker of these security 32 systems may find it easier to reproduce the environment that produced 33 the secret quantities, searching the resulting small set of 34 possibilities, than to locate the quantities in the whole of the 35 number space. 36 37 Choosing random quantities to foil a resourceful and motivated 38 adversary is surprisingly difficult. This paper points out many 39 pitfalls in using traditional pseudo-random number generation 40 techniques for choosing such quantities. It recommends the use of 41 truly random hardware techniques and shows that the existing hardware 42 on many systems can be used for this purpose. It provides 43 suggestions to ameliorate the problem when a hardware solution is not 44 available. And it gives examples of how large such quantities need 45 to be for some particular applications. 46 47 48 49 50 51 52 53 54 55 56 57 58 Eastlake, Crocker & Schiller [Page 1] 59 60 RFC 1750 Randomness Recommendations for Security December 1994 61 62 63 Acknowledgements 64 65 Comments on this document that have been incorporated were received 66 from (in alphabetic order) the following: 67 68 David M. Balenson (TIS) 69 Don Coppersmith (IBM) 70 Don T. Davis (consultant) 71 Carl Ellison (Stratus) 72 Marc Horowitz (MIT) 73 Christian Huitema (INRIA) 74 Charlie Kaufman (IRIS) 75 Steve Kent (BBN) 76 Hal Murray (DEC) 77 Neil Haller (Bellcore) 78 Richard Pitkin (DEC) 79 Tim Redmond (TIS) 80 Doug Tygar (CMU) 81 82 Table of Contents 83 84 1. Introduction........................................... 3 85 2. Requirements........................................... 4 86 3. Traditional Pseudo-Random Sequences.................... 5 87 4. Unpredictability....................................... 7 88 4.1 Problems with Clocks and Serial Numbers............... 7 89 4.2 Timing and Content of External Events................ 8 90 4.3 The Fallacy of Complex Manipulation.................. 8 91 4.4 The Fallacy of Selection from a Large Database....... 9 92 5. Hardware for Randomness............................... 10 93 5.1 Volume Required...................................... 10 94 5.2 Sensitivity to Skew.................................. 10 95 5.2.1 Using Stream Parity to De-Skew..................... 11 96 5.2.2 Using Transition Mappings to De-Skew............... 12 97 5.2.3 Using FFT to De-Skew............................... 13 98 5.2.4 Using Compression to De-Skew....................... 13 99 5.3 Existing Hardware Can Be Used For Randomness......... 14 100 5.3.1 Using Existing Sound/Video Input................... 14 101 5.3.2 Using Existing Disk Drives......................... 14 102 6. Recommended Non-Hardware Strategy..................... 14 103 6.1 Mixing Functions..................................... 15 104 6.1.1 A Trivial Mixing Function.......................... 15 105 6.1.2 Stronger Mixing Functions.......................... 16 106 6.1.3 Diff-Hellman as a Mixing Function.................. 17 107 6.1.4 Using a Mixing Function to Stretch Random Bits..... 17 108 6.1.5 Other Factors in Choosing a Mixing Function........ 18 109 6.2 Non-Hardware Sources of Randomness................... 19 110 6.3 Cryptographically Strong Sequences................... 19 111 112 113 114 Eastlake, Crocker & Schiller [Page 2] 115 116 RFC 1750 Randomness Recommendations for Security December 1994 117 118 119 6.3.1 Traditional Strong Sequences....................... 20 120 6.3.2 The Blum Blum Shub Sequence Generator.............. 21 121 7. Key Generation Standards.............................. 22 122 7.1 US DoD Recommendations for Password Generation....... 23 123 7.2 X9.17 Key Generation................................. 23 124 8. Examples of Randomness Required....................... 24 125 8.1 Password Generation................................. 24 126 8.2 A Very High Security Cryptographic Key............... 25 127 8.2.1 Effort per Key Trial............................... 25 128 8.2.2 Meet in the Middle Attacks......................... 26 129 8.2.3 Other Considerations............................... 26 130 9. Conclusion............................................ 27 131 10. Security Considerations.............................. 27 132 References............................................... 28 133 Authors' Addresses....................................... 30 134 135 1. Introduction 136 137 Software cryptography is coming into wider use. Systems like 138 Kerberos, PEM, PGP, etc. are maturing and becoming a part of the 139 network landscape [PEM]. These systems provide substantial 140 protection against snooping and spoofing. However, there is a 141 potential flaw. At the heart of all cryptographic systems is the 142 generation of secret, unguessable (i.e., random) numbers. 143 144 For the present, the lack of generally available facilities for 145 generating such unpredictable numbers is an open wound in the design 146 of cryptographic software. For the software developer who wants to 147 build a key or password generation procedure that runs on a wide 148 range of hardware, the only safe strategy so far has been to force 149 the local installation to supply a suitable routine to generate 150 random numbers. To say the least, this is an awkward, error-prone 151 and unpalatable solution. 152 153 It is important to keep in mind that the requirement is for data that 154 an adversary has a very low probability of guessing or determining. 155 This will fail if pseudo-random data is used which only meets 156 traditional statistical tests for randomness or which is based on 157 limited range sources, such as clocks. Frequently such random 158 quantities are determinable by an adversary searching through an 159 embarrassingly small space of possibilities. 160 161 This informational document suggests techniques for producing random 162 quantities that will be resistant to such attack. It recommends that 163 future systems include hardware random number generation or provide 164 access to existing hardware that can be used for this purpose. It 165 suggests methods for use if such hardware is not available. And it 166 gives some estimates of the number of random bits required for sample 167 168 169 170 Eastlake, Crocker & Schiller [Page 3] 171 172 RFC 1750 Randomness Recommendations for Security December 1994 173 174 175 applications. 176 177 2. Requirements 178 179 Probably the most commonly encountered randomness requirement today 180 is the user password. This is usually a simple character string. 181 Obviously, if a password can be guessed, it does not provide 182 security. (For re-usable passwords, it is desirable that users be 183 able to remember the password. This may make it advisable to use 184 pronounceable character strings or phrases composed on ordinary 185 words. But this only affects the format of the password information, 186 not the requirement that the password be very hard to guess.) 187 188 Many other requirements come from the cryptographic arena. 189 Cryptographic techniques can be used to provide a variety of services 190 including confidentiality and authentication. Such services are 191 based on quantities, traditionally called "keys", that are unknown to 192 and unguessable by an adversary. 193 194 In some cases, such as the use of symmetric encryption with the one 195 time pads [CRYPTO*] or the US Data Encryption Standard [DES], the 196 parties who wish to communicate confidentially and/or with 197 authentication must all know the same secret key. In other cases, 198 using what are called asymmetric or "public key" cryptographic 199 techniques, keys come in pairs. One key of the pair is private and 200 must be kept secret by one party, the other is public and can be 201 published to the world. It is computationally infeasible to 202 determine the private key from the public key [ASYMMETRIC, CRYPTO*]. 203 204 The frequency and volume of the requirement for random quantities 205 differs greatly for different cryptographic systems. Using pure RSA 206 [CRYPTO*], random quantities are required when the key pair is 207 generated, but thereafter any number of messages can be signed 208 without any further need for randomness. The public key Digital 209 Signature Algorithm that has been proposed by the US National 210 Institute of Standards and Technology (NIST) requires good random 211 numbers for each signature. And encrypting with a one time pad, in 212 principle the strongest possible encryption technique, requires a 213 volume of randomness equal to all the messages to be processed. 214 215 In most of these cases, an adversary can try to determine the 216 "secret" key by trial and error. (This is possible as long as the 217 key is enough smaller than the message that the correct key can be 218 uniquely identified.) The probability of an adversary succeeding at 219 this must be made acceptably low, depending on the particular 220 application. The size of the space the adversary must search is 221 related to the amount of key "information" present in the information 222 theoretic sense [SHANNON]. This depends on the number of different 223 224 225 226 Eastlake, Crocker & Schiller [Page 4] 227 228 RFC 1750 Randomness Recommendations for Security December 1994 229 230 231 secret values possible and the probability of each value as follows: 232 233 ----- 234 \ 235 Bits-of-info = \ - p * log ( p ) 236 / i 2 i 237 / 238 ----- 239 240 where i varies from 1 to the number of possible secret values and p 241 sub i is the probability of the value numbered i. (Since p sub i is 242 less than one, the log will be negative so each term in the sum will 243 be non-negative.) 244 245 If there are 2^n different values of equal probability, then n bits 246 of information are present and an adversary would, on the average, 247 have to try half of the values, or 2^(n-1) , before guessing the 248 secret quantity. If the probability of different values is unequal, 249 then there is less information present and fewer guesses will, on 250 average, be required by an adversary. In particular, any values that 251 the adversary can know are impossible, or are of low probability, can 252 be initially ignored by an adversary, who will search through the 253 more probable values first. 254 255 For example, consider a cryptographic system that uses 56 bit keys. 256 If these 56 bit keys are derived by using a fixed pseudo-random 257 number generator that is seeded with an 8 bit seed, then an adversary 258 needs to search through only 256 keys (by running the pseudo-random 259 number generator with every possible seed), not the 2^56 keys that 260 may at first appear to be the case. Only 8 bits of "information" are 261 in these 56 bit keys. 262 263 3. Traditional Pseudo-Random Sequences 264 265 Most traditional sources of random numbers use deterministic sources 266 of "pseudo-random" numbers. These typically start with a "seed" 267 quantity and use numeric or logical operations to produce a sequence 268 of values. 269 270 [KNUTH] has a classic exposition on pseudo-random numbers. 271 Applications he mentions are simulation of natural phenomena, 272 sampling, numerical analysis, testing computer programs, decision 273 making, and games. None of these have the same characteristics as 274 the sort of security uses we are talking about. Only in the last two 275 could there be an adversary trying to find the random quantity. 276 However, in these cases, the adversary normally has only a single 277 chance to use a guessed value. In guessing passwords or attempting 278 to break an encryption scheme, the adversary normally has many, 279 280 281 282 Eastlake, Crocker & Schiller [Page 5] 283 284 RFC 1750 Randomness Recommendations for Security December 1994 285 286 287 perhaps unlimited, chances at guessing the correct value and should 288 be assumed to be aided by a computer. 289 290 For testing the "randomness" of numbers, Knuth suggests a variety of 291 measures including statistical and spectral. These tests check 292 things like autocorrelation between different parts of a "random" 293 sequence or distribution of its values. They could be met by a 294 constant stored random sequence, such as the "random" sequence 295 printed in the CRC Standard Mathematical Tables [CRC]. 296 297 A typical pseudo-random number generation technique, known as a 298 linear congruence pseudo-random number generator, is modular 299 arithmetic where the N+1th value is calculated from the Nth value by 300 301 V = ( V * a + b )(Mod c) 302 N+1 N 303 304 The above technique has a strong relationship to linear shift 305 register pseudo-random number generators, which are well understood 306 cryptographically [SHIFT*]. In such generators bits are introduced 307 at one end of a shift register as the Exclusive Or (binary sum 308 without carry) of bits from selected fixed taps into the register. 309 310 For example: 311 312 +----+ +----+ +----+ +----+ 313 | B | <-- | B | <-- | B | <-- . . . . . . <-- | B | <-+ 314 | 0 | | 1 | | 2 | | n | | 315 +----+ +----+ +----+ +----+ | 316 | | | | 317 | | V +-----+ 318 | V +----------------> | | 319 V +-----------------------------> | XOR | 320 +---------------------------------------------------> | | 321 +-----+ 322 323 324 V = ( ( V * 2 ) + B .xor. B ... )(Mod 2^n) 325 N+1 N 0 2 326 327 The goodness of traditional pseudo-random number generator algorithms 328 is measured by statistical tests on such sequences. Carefully chosen 329 values of the initial V and a, b, and c or the placement of shift 330 register tap in the above simple processes can produce excellent 331 statistics. 332 333 334 335 336 337 338 Eastlake, Crocker & Schiller [Page 6] 339 340 RFC 1750 Randomness Recommendations for Security December 1994 341 342 343 These sequences may be adequate in simulations (Monte Carlo 344 experiments) as long as the sequence is orthogonal to the structure 345 of the space being explored. Even there, subtle patterns may cause 346 problems. However, such sequences are clearly bad for use in 347 security applications. They are fully predictable if the initial 348 state is known. Depending on the form of the pseudo-random number 349 generator, the sequence may be determinable from observation of a 350 short portion of the sequence [CRYPTO*, STERN]. For example, with 351 the generators above, one can determine V(n+1) given knowledge of 352 V(n). In fact, it has been shown that with these techniques, even if 353 only one bit of the pseudo-random values is released, the seed can be 354 determined from short sequences. 355 356 Not only have linear congruent generators been broken, but techniques 357 are now known for breaking all polynomial congruent generators 358 [KRAWCZYK]. 359 360 4. Unpredictability 361 362 Randomness in the traditional sense described in section 3 is NOT the 363 same as the unpredictability required for security use. 364 365 For example, use of a widely available constant sequence, such as 366 that from the CRC tables, is very weak against an adversary. Once 367 they learn of or guess it, they can easily break all security, future 368 and past, based on the sequence [CRC]. Yet the statistical 369 properties of these tables are good. 370 371 The following sections describe the limitations of some randomness 372 generation techniques and sources. 373 374 4.1 Problems with Clocks and Serial Numbers 375 376 Computer clocks, or similar operating system or hardware values, 377 provide significantly fewer real bits of unpredictability than might 378 appear from their specifications. 379 380 Tests have been done on clocks on numerous systems and it was found 381 that their behavior can vary widely and in unexpected ways. One 382 version of an operating system running on one set of hardware may 383 actually provide, say, microsecond resolution in a clock while a 384 different configuration of the "same" system may always provide the 385 same lower bits and only count in the upper bits at much lower 386 resolution. This means that successive reads on the clock may 387 produce identical values even if enough time has passed that the 388 value "should" change based on the nominal clock resolution. There 389 are also cases where frequently reading a clock can produce 390 artificial sequential values because of extra code that checks for 391 392 393 394 Eastlake, Crocker & Schiller [Page 7] 395 396 RFC 1750 Randomness Recommendations for Security December 1994 397 398 399 the clock being unchanged between two reads and increases it by one! 400 Designing portable application code to generate unpredictable numbers 401 based on such system clocks is particularly challenging because the 402 system designer does not always know the properties of the system 403 clocks that the code will execute on. 404 405 Use of a hardware serial number such as an Ethernet address may also 406 provide fewer bits of uniqueness than one would guess. Such 407 quantities are usually heavily structured and subfields may have only 408 a limited range of possible values or values easily guessable based 409 on approximate date of manufacture or other data. For example, it is 410 likely that most of the Ethernet cards installed on Digital Equipment 411 Corporation (DEC) hardware within DEC were manufactured by DEC 412 itself, which significantly limits the range of built in addresses. 413 414 Problems such as those described above related to clocks and serial 415 numbers make code to produce unpredictable quantities difficult if 416 the code is to be ported across a variety of computer platforms and 417 systems. 418 419 4.2 Timing and Content of External Events 420 421 It is possible to measure the timing and content of mouse movement, 422 key strokes, and similar user events. This is a reasonable source of 423 unguessable data with some qualifications. On some machines, inputs 424 such as key strokes are buffered. Even though the user's inter- 425 keystroke timing may have sufficient variation and unpredictability, 426 there might not be an easy way to access that variation. Another 427 problem is that no standard method exists to sample timing details. 428 This makes it hard to build standard software intended for 429 distribution to a large range of machines based on this technique. 430 431 The amount of mouse movement or the keys actually hit are usually 432 easier to access than timings but may yield less unpredictability as 433 the user may provide highly repetitive input. 434 435 Other external events, such as network packet arrival times, can also 436 be used with care. In particular, the possibility of manipulation of 437 such times by an adversary must be considered. 438 439 4.3 The Fallacy of Complex Manipulation 440 441 One strategy which may give a misleading appearance of 442 unpredictability is to take a very complex algorithm (or an excellent 443 traditional pseudo-random number generator with good statistical 444 properties) and calculate a cryptographic key by starting with the 445 current value of a computer system clock as the seed. An adversary 446 who knew roughly when the generator was started would have a 447 448 449 450 Eastlake, Crocker & Schiller [Page 8] 451 452 RFC 1750 Randomness Recommendations for Security December 1994 453 454 455 relatively small number of seed values to test as they would know 456 likely values of the system clock. Large numbers of pseudo-random 457 bits could be generated but the search space an adversary would need 458 to check could be quite small. 459 460 Thus very strong and/or complex manipulation of data will not help if 461 the adversary can learn what the manipulation is and there is not 462 enough unpredictability in the starting seed value. Even if they can 463 not learn what the manipulation is, they may be able to use the 464 limited number of results stemming from a limited number of seed 465 values to defeat security. 466 467 Another serious strategy error is to assume that a very complex 468 pseudo-random number generation algorithm will produce strong random 469 numbers when there has been no theory behind or analysis of the 470 algorithm. There is a excellent example of this fallacy right near 471 the beginning of chapter 3 in [KNUTH] where the author describes a 472 complex algorithm. It was intended that the machine language program 473 corresponding to the algorithm would be so complicated that a person 474 trying to read the code without comments wouldn't know what the 475 program was doing. Unfortunately, actual use of this algorithm 476 showed that it almost immediately converged to a single repeated 477 value in one case and a small cycle of values in another case. 478 479 Not only does complex manipulation not help you if you have a limited 480 range of seeds but blindly chosen complex manipulation can destroy 481 the randomness in a good seed! 482 483 4.4 The Fallacy of Selection from a Large Database 484 485 Another strategy that can give a misleading appearance of 486 unpredictability is selection of a quantity randomly from a database 487 and assume that its strength is related to the total number of bits 488 in the database. For example, typical USENET servers as of this date 489 process over 35 megabytes of information per day. Assume a random 490 quantity was selected by fetching 32 bytes of data from a random 491 starting point in this data. This does not yield 32*8 = 256 bits 492 worth of unguessability. Even after allowing that much of the data 493 is human language and probably has more like 2 or 3 bits of 494 information per byte, it doesn't yield 32*2.5 = 80 bits of 495 unguessability. For an adversary with access to the same 35 496 megabytes the unguessability rests only on the starting point of the 497 selection. That is, at best, about 25 bits of unguessability in this 498 case. 499 500 The same argument applies to selecting sequences from the data on a 501 CD ROM or Audio CD recording or any other large public database. If 502 the adversary has access to the same database, this "selection from a 503 504 505 506 Eastlake, Crocker & Schiller [Page 9] 507 508 RFC 1750 Randomness Recommendations for Security December 1994 509 510 511 large volume of data" step buys very little. However, if a selection 512 can be made from data to which the adversary has no access, such as 513 system buffers on an active multi-user system, it may be of some 514 help. 515 516 5. Hardware for Randomness 517 518 Is there any hope for strong portable randomness in the future? 519 There might be. All that's needed is a physical source of 520 unpredictable numbers. 521 522 A thermal noise or radioactive decay source and a fast, free-running 523 oscillator would do the trick directly [GIFFORD]. This is a trivial 524 amount of hardware, and could easily be included as a standard part 525 of a computer system's architecture. Furthermore, any system with a 526 spinning disk or the like has an adequate source of randomness 527 [DAVIS]. All that's needed is the common perception among computer 528 vendors that this small additional hardware and the software to 529 access it is necessary and useful. 530 531 5.1 Volume Required 532 533 How much unpredictability is needed? Is it possible to quantify the 534 requirement in, say, number of random bits per second? 535 536 The answer is not very much is needed. For DES, the key is 56 bits 537 and, as we show in an example in Section 8, even the highest security 538 system is unlikely to require a keying material of over 200 bits. If 539 a series of keys are needed, it can be generated from a strong random 540 seed using a cryptographically strong sequence as explained in 541 Section 6.3. A few hundred random bits generated once a day would be 542 enough using such techniques. Even if the random bits are generated 543 as slowly as one per second and it is not possible to overlap the 544 generation process, it should be tolerable in high security 545 applications to wait 200 seconds occasionally. 546 547 These numbers are trivial to achieve. It could be done by a person 548 repeatedly tossing a coin. Almost any hardware process is likely to 549 be much faster. 550 551 5.2 Sensitivity to Skew 552 553 Is there any specific requirement on the shape of the distribution of 554 the random numbers? The good news is the distribution need not be 555 uniform. All that is needed is a conservative estimate of how non- 556 uniform it is to bound performance. Two simple techniques to de-skew 557 the bit stream are given below and stronger techniques are mentioned 558 in Section 6.1.2 below. 559 560 561 562 Eastlake, Crocker & Schiller [Page 10] 563 564 RFC 1750 Randomness Recommendations for Security December 1994 565 566 567 5.2.1 Using Stream Parity to De-Skew 568 569 Consider taking a sufficiently long string of bits and map the string 570 to "zero" or "one". The mapping will not yield a perfectly uniform 571 distribution, but it can be as close as desired. One mapping that 572 serves the purpose is to take the parity of the string. This has the 573 advantages that it is robust across all degrees of skew up to the 574 estimated maximum skew and is absolutely trivial to implement in 575 hardware. 576 577 The following analysis gives the number of bits that must be sampled: 578 579 Suppose the ratio of ones to zeros is 0.5 + e : 0.5 - e, where e is 580 between 0 and 0.5 and is a measure of the "eccentricity" of the 581 distribution. Consider the distribution of the parity function of N 582 bit samples. The probabilities that the parity will be one or zero 583 will be the sum of the odd or even terms in the binomial expansion of 584 (p + q)^N, where p = 0.5 + e, the probability of a one, and q = 0.5 - 585 e, the probability of a zero. 586 587 These sums can be computed easily as 588 589 N N 590 1/2 * ( ( p + q ) + ( p - q ) ) 591 and 592 N N 593 1/2 * ( ( p + q ) - ( p - q ) ). 594 595 (Which one corresponds to the probability the parity will be 1 596 depends on whether N is odd or even.) 597 598 Since p + q = 1 and p - q = 2e, these expressions reduce to 599 600 N 601 1/2 * [1 + (2e) ] 602 and 603 N 604 1/2 * [1 - (2e) ]. 605 606 Neither of these will ever be exactly 0.5 unless e is zero, but we 607 can bring them arbitrarily close to 0.5. If we want the 608 probabilities to be within some delta d of 0.5, i.e. then 609 610 N 611 ( 0.5 + ( 0.5 * (2e) ) ) < 0.5 + d. 612 613 614 615 616 617 618 Eastlake, Crocker & Schiller [Page 11] 619 620 RFC 1750 Randomness Recommendations for Security December 1994 621 622 623 Solving for N yields N > log(2d)/log(2e). (Note that 2e is less than 624 1, so its log is negative. Division by a negative number reverses 625 the sense of an inequality.) 626 627 The following table gives the length of the string which must be 628 sampled for various degrees of skew in order to come within 0.001 of 629 a 50/50 distribution. 630 631 +---------+--------+-------+ 632 | Prob(1) | e | N | 633 +---------+--------+-------+ 634 | 0.5 | 0.00 | 1 | 635 | 0.6 | 0.10 | 4 | 636 | 0.7 | 0.20 | 7 | 637 | 0.8 | 0.30 | 13 | 638 | 0.9 | 0.40 | 28 | 639 | 0.95 | 0.45 | 59 | 640 | 0.99 | 0.49 | 308 | 641 +---------+--------+-------+ 642 643 The last entry shows that even if the distribution is skewed 99% in 644 favor of ones, the parity of a string of 308 samples will be within 645 0.001 of a 50/50 distribution. 646 647 5.2.2 Using Transition Mappings to De-Skew 648 649 Another technique, originally due to von Neumann [VON NEUMANN], is to 650 examine a bit stream as a sequence of non-overlapping pairs. You 651 could then discard any 00 or 11 pairs found, interpret 01 as a 0 and 652 10 as a 1. Assume the probability of a 1 is 0.5+e and the 653 probability of a 0 is 0.5-e where e is the eccentricity of the source 654 and described in the previous section. Then the probability of each 655 pair is as follows: 656 657 +------+-----------------------------------------+ 658 | pair | probability | 659 +------+-----------------------------------------+ 660 | 00 | (0.5 - e)^2 = 0.25 - e + e^2 | 661 | 01 | (0.5 - e)*(0.5 + e) = 0.25 - e^2 | 662 | 10 | (0.5 + e)*(0.5 - e) = 0.25 - e^2 | 663 | 11 | (0.5 + e)^2 = 0.25 + e + e^2 | 664 +------+-----------------------------------------+ 665 666 This technique will completely eliminate any bias but at the expense 667 of taking an indeterminate number of input bits for any particular 668 desired number of output bits. The probability of any particular 669 pair being discarded is 0.5 + 2e^2 so the expected number of input 670 bits to produce X output bits is X/(0.25 - e^2). 671 672 673 674 Eastlake, Crocker & Schiller [Page 12] 675 676 RFC 1750 Randomness Recommendations for Security December 1994 677 678 679 This technique assumes that the bits are from a stream where each bit 680 has the same probability of being a 0 or 1 as any other bit in the 681 stream and that bits are not correlated, i.e., that the bits are 682 identical independent distributions. If alternate bits were from two 683 correlated sources, for example, the above analysis breaks down. 684 685 The above technique also provides another illustration of how a 686 simple statistical analysis can mislead if one is not always on the 687 lookout for patterns that could be exploited by an adversary. If the 688 algorithm were mis-read slightly so that overlapping successive bits 689 pairs were used instead of non-overlapping pairs, the statistical 690 analysis given is the same; however, instead of provided an unbiased 691 uncorrelated series of random 1's and 0's, it instead produces a 692 totally predictable sequence of exactly alternating 1's and 0's. 693 694 5.2.3 Using FFT to De-Skew 695 696 When real world data consists of strongly biased or correlated bits, 697 it may still contain useful amounts of randomness. This randomness 698 can be extracted through use of the discrete Fourier transform or its 699 optimized variant, the FFT. 700 701 Using the Fourier transform of the data, strong correlations can be 702 discarded. If adequate data is processed and remaining correlations 703 decay, spectral lines approaching statistical independence and 704 normally distributed randomness can be produced [BRILLINGER]. 705 706 5.2.4 Using Compression to De-Skew 707 708 Reversible compression techniques also provide a crude method of de- 709 skewing a skewed bit stream. This follows directly from the 710 definition of reversible compression and the formula in Section 2 711 above for the amount of information in a sequence. Since the 712 compression is reversible, the same amount of information must be 713 present in the shorter output than was present in the longer input. 714 By the Shannon information equation, this is only possible if, on 715 average, the probabilities of the different shorter sequences are 716 more uniformly distributed than were the probabilities of the longer 717 sequences. Thus the shorter sequences are de-skewed relative to the 718 input. 719 720 However, many compression techniques add a somewhat predicatable 721 preface to their output stream and may insert such a sequence again 722 periodically in their output or otherwise introduce subtle patterns 723 of their own. They should be considered only a rough technique 724 compared with those described above or in Section 6.1.2. At a 725 minimum, the beginning of the compressed sequence should be skipped 726 and only later bits used for applications requiring random bits. 727 728 729 730 Eastlake, Crocker & Schiller [Page 13] 731 732 RFC 1750 Randomness Recommendations for Security December 1994 733 734 735 5.3 Existing Hardware Can Be Used For Randomness 736 737 As described below, many computers come with hardware that can, with 738 care, be used to generate truly random quantities. 739 740 5.3.1 Using Existing Sound/Video Input 741 742 Increasingly computers are being built with inputs that digitize some 743 real world analog source, such as sound from a microphone or video 744 input from a camera. Under appropriate circumstances, such input can 745 provide reasonably high quality random bits. The "input" from a 746 sound digitizer with no source plugged in or a camera with the lens 747 cap on, if the system has enough gain to detect anything, is 748 essentially thermal noise. 749 750 For example, on a SPARCstation, one can read from the /dev/audio 751 device with nothing plugged into the microphone jack. Such data is 752 essentially random noise although it should not be trusted without 753 some checking in case of hardware failure. It will, in any case, 754 need to be de-skewed as described elsewhere. 755 756 Combining this with compression to de-skew one can, in UNIXese, 757 generate a huge amount of medium quality random data by doing 758 759 cat /dev/audio | compress - >random-bits-file 760 761 5.3.2 Using Existing Disk Drives 762 763 Disk drives have small random fluctuations in their rotational speed 764 due to chaotic air turbulence [DAVIS]. By adding low level disk seek 765 time instrumentation to a system, a series of measurements can be 766 obtained that include this randomness. Such data is usually highly 767 correlated so that significant processing is needed, including FFT 768 (see section 5.2.3). Nevertheless experimentation has shown that, 769 with such processing, disk drives easily produce 100 bits a minute or 770 more of excellent random data. 771 772 Partly offsetting this need for processing is the fact that disk 773 drive failure will normally be rapidly noticed. Thus, problems with 774 this method of random number generation due to hardware failure are 775 very unlikely. 776 777 6. Recommended Non-Hardware Strategy 778 779 What is the best overall strategy for meeting the requirement for 780 unguessable random numbers in the absence of a reliable hardware 781 source? It is to obtain random input from a large number of 782 uncorrelated sources and to mix them with a strong mixing function. 783 784 785 786 Eastlake, Crocker & Schiller [Page 14] 787 788 RFC 1750 Randomness Recommendations for Security December 1994 789 790 791 Such a function will preserve the randomness present in any of the 792 sources even if other quantities being combined are fixed or easily 793 guessable. This may be advisable even with a good hardware source as 794 hardware can also fail, though this should be weighed against any 795 increase in the chance of overall failure due to added software 796 complexity. 797 798 6.1 Mixing Functions 799 800 A strong mixing function is one which combines two or more inputs and 801 produces an output where each output bit is a different complex non- 802 linear function of all the input bits. On average, changing any 803 input bit will change about half the output bits. But because the 804 relationship is complex and non-linear, no particular output bit is 805 guaranteed to change when any particular input bit is changed. 806 807 Consider the problem of converting a stream of bits that is skewed 808 towards 0 or 1 to a shorter stream which is more random, as discussed 809 in Section 5.2 above. This is simply another case where a strong 810 mixing function is desired, mixing the input bits to produce a 811 smaller number of output bits. The technique given in Section 5.2.1 812 of using the parity of a number of bits is simply the result of 813 successively Exclusive Or'ing them which is examined as a trivial 814 mixing function immediately below. Use of stronger mixing functions 815 to extract more of the randomness in a stream of skewed bits is 816 examined in Section 6.1.2. 817 818 6.1.1 A Trivial Mixing Function 819 820 A trivial example for single bit inputs is the Exclusive Or function, 821 which is equivalent to addition without carry, as show in the table 822 below. This is a degenerate case in which the one output bit always 823 changes for a change in either input bit. But, despite its 824 simplicity, it will still provide a useful illustration. 825 826 +-----------+-----------+----------+ 827 | input 1 | input 2 | output | 828 +-----------+-----------+----------+ 829 | 0 | 0 | 0 | 830 | 0 | 1 | 1 | 831 | 1 | 0 | 1 | 832 | 1 | 1 | 0 | 833 +-----------+-----------+----------+ 834 835 If inputs 1 and 2 are uncorrelated and combined in this fashion then 836 the output will be an even better (less skewed) random bit than the 837 inputs. If we assume an "eccentricity" e as defined in Section 5.2 838 above, then the output eccentricity relates to the input eccentricity 839 840 841 842 Eastlake, Crocker & Schiller [Page 15] 843 844 RFC 1750 Randomness Recommendations for Security December 1994 845 846 847 as follows: 848 849 e = 2 * e * e 850 output input 1 input 2 851 852 Since e is never greater than 1/2, the eccentricity is always 853 improved except in the case where at least one input is a totally 854 skewed constant. This is illustrated in the following table where 855 the top and left side values are the two input eccentricities and the 856 entries are the output eccentricity: 857 858 +--------+--------+--------+--------+--------+--------+--------+ 859 | e | 0.00 | 0.10 | 0.20 | 0.30 | 0.40 | 0.50 | 860 +--------+--------+--------+--------+--------+--------+--------+ 861 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | 862 | 0.10 | 0.00 | 0.02 | 0.04 | 0.06 | 0.08 | 0.10 | 863 | 0.20 | 0.00 | 0.04 | 0.08 | 0.12 | 0.16 | 0.20 | 864 | 0.30 | 0.00 | 0.06 | 0.12 | 0.18 | 0.24 | 0.30 | 865 | 0.40 | 0.00 | 0.08 | 0.16 | 0.24 | 0.32 | 0.40 | 866 | 0.50 | 0.00 | 0.10 | 0.20 | 0.30 | 0.40 | 0.50 | 867 +--------+--------+--------+--------+--------+--------+--------+ 868 869 However, keep in mind that the above calculations assume that the 870 inputs are not correlated. If the inputs were, say, the parity of 871 the number of minutes from midnight on two clocks accurate to a few 872 seconds, then each might appear random if sampled at random intervals 873 much longer than a minute. Yet if they were both sampled and 874 combined with xor, the result would be zero most of the time. 875 876 6.1.2 Stronger Mixing Functions 877 878 The US Government Data Encryption Standard [DES] is an example of a 879 strong mixing function for multiple bit quantities. It takes up to 880 120 bits of input (64 bits of "data" and 56 bits of "key") and 881 produces 64 bits of output each of which is dependent on a complex 882 non-linear function of all input bits. Other strong encryption 883 functions with this characteristic can also be used by considering 884 them to mix all of their key and data input bits. 885 886 Another good family of mixing functions are the "message digest" or 887 hashing functions such as The US Government Secure Hash Standard 888 [SHS] and the MD2, MD4, MD5 [MD2, MD4, MD5] series. These functions 889 all take an arbitrary amount of input and produce an output mixing 890 all the input bits. The MD* series produce 128 bits of output and SHS 891 produces 160 bits. 892 893 894 895 896 897 898 Eastlake, Crocker & Schiller [Page 16] 899 900 RFC 1750 Randomness Recommendations for Security December 1994 901 902 903 Although the message digest functions are designed for variable 904 amounts of input, DES and other encryption functions can also be used 905 to combine any number of inputs. If 64 bits of output is adequate, 906 the inputs can be packed into a 64 bit data quantity and successive 907 56 bit keys, padding with zeros if needed, which are then used to 908 successively encrypt using DES in Electronic Codebook Mode [DES 909 MODES]. If more than 64 bits of output are needed, use more complex 910 mixing. For example, if inputs are packed into three quantities, A, 911 B, and C, use DES to encrypt A with B as a key and then with C as a 912 key to produce the 1st part of the output, then encrypt B with C and 913 then A for more output and, if necessary, encrypt C with A and then B 914 for yet more output. Still more output can be produced by reversing 915 the order of the keys given above to stretch things. The same can be 916 done with the hash functions by hashing various subsets of the input 917 data to produce multiple outputs. But keep in mind that it is 918 impossible to get more bits of "randomness" out than are put in. 919 920 An example of using a strong mixing function would be to reconsider 921 the case of a string of 308 bits each of which is biased 99% towards 922 zero. The parity technique given in Section 5.2.1 above reduced this 923 to one bit with only a 1/1000 deviance from being equally likely a 924 zero or one. But, applying the equation for information given in 925 Section 2, this 308 bit sequence has 5 bits of information in it. 926 Thus hashing it with SHS or MD5 and taking the bottom 5 bits of the 927 result would yield 5 unbiased random bits as opposed to the single 928 bit given by calculating the parity of the string. 929 930 6.1.3 Diffie-Hellman as a Mixing Function 931 932 Diffie-Hellman exponential key exchange is a technique that yields a 933 shared secret between two parties that can be made computationally 934 infeasible for a third party to determine even if they can observe 935 all the messages between the two communicating parties. This shared 936 secret is a mixture of initial quantities generated by each of them 937 [D-H]. If these initial quantities are random, then the shared 938 secret contains the combined randomness of them both, assuming they 939 are uncorrelated. 940 941 6.1.4 Using a Mixing Function to Stretch Random Bits 942 943 While it is not necessary for a mixing function to produce the same 944 or fewer bits than its inputs, mixing bits cannot "stretch" the 945 amount of random unpredictability present in the inputs. Thus four 946 inputs of 32 bits each where there is 12 bits worth of 947 unpredicatability (such as 4,096 equally probable values) in each 948 input cannot produce more than 48 bits worth of unpredictable output. 949 The output can be expanded to hundreds or thousands of bits by, for 950 example, mixing with successive integers, but the clever adversary's 951 952 953 954 Eastlake, Crocker & Schiller [Page 17] 955 956 RFC 1750 Randomness Recommendations for Security December 1994 957 958 959 search space is still 2^48 possibilities. Furthermore, mixing to 960 fewer bits than are input will tend to strengthen the randomness of 961 the output the way using Exclusive Or to produce one bit from two did 962 above. 963 964 The last table in Section 6.1.1 shows that mixing a random bit with a 965 constant bit with Exclusive Or will produce a random bit. While this 966 is true, it does not provide a way to "stretch" one random bit into 967 more than one. If, for example, a random bit is mixed with a 0 and 968 then with a 1, this produces a two bit sequence but it will always be 969 either 01 or 10. Since there are only two possible values, there is 970 still only the one bit of original randomness. 971 972 6.1.5 Other Factors in Choosing a Mixing Function 973 974 For local use, DES has the advantages that it has been widely tested 975 for flaws, is widely documented, and is widely implemented with 976 hardware and software implementations available all over the world 977 including source code available by anonymous FTP. The SHS and MD* 978 family are younger algorithms which have been less tested but there 979 is no particular reason to believe they are flawed. Both MD5 and SHS 980 were derived from the earlier MD4 algorithm. They all have source 981 code available by anonymous FTP [SHS, MD2, MD4, MD5]. 982 983 DES and SHS have been vouched for the the US National Security Agency 984 (NSA) on the basis of criteria that primarily remain secret. While 985 this is the cause of much speculation and doubt, investigation of DES 986 over the years has indicated that NSA involvement in modifications to 987 its design, which originated with IBM, was primarily to strengthen 988 it. No concealed or special weakness has been found in DES. It is 989 almost certain that the NSA modification to MD4 to produce the SHS 990 similarly strengthened the algorithm, possibly against threats not 991 yet known in the public cryptographic community. 992 993 DES, SHS, MD4, and MD5 are royalty free for all purposes. MD2 has 994 been freely licensed only for non-profit use in connection with 995 Privacy Enhanced Mail [PEM]. Between the MD* algorithms, some people 996 believe that, as with "Goldilocks and the Three Bears", MD2 is strong 997 but too slow, MD4 is fast but too weak, and MD5 is just right. 998 999 Another advantage of the MD* or similar hashing algorithms over 1000 encryption algorithms is that they are not subject to the same 1001 regulations imposed by the US Government prohibiting the unlicensed 1002 export or import of encryption/decryption software and hardware. The 1003 same should be true of DES rigged to produce an irreversible hash 1004 code but most DES packages are oriented to reversible encryption. 1005 1006 1007 1008 1009 1010 Eastlake, Crocker & Schiller [Page 18] 1011 1012 RFC 1750 Randomness Recommendations for Security December 1994 1013 1014 1015 6.2 Non-Hardware Sources of Randomness 1016 1017 The best source of input for mixing would be a hardware randomness 1018 such as disk drive timing affected by air turbulence, audio input 1019 with thermal noise, or radioactive decay. However, if that is not 1020 available there are other possibilities. These include system 1021 clocks, system or input/output buffers, user/system/hardware/network 1022 serial numbers and/or addresses and timing, and user input. 1023 Unfortunately, any of these sources can produce limited or 1024 predicatable values under some circumstances. 1025 1026 Some of the sources listed above would be quite strong on multi-user 1027 systems where, in essence, each user of the system is a source of 1028 randomness. However, on a small single user system, such as a 1029 typical IBM PC or Apple Macintosh, it might be possible for an 1030 adversary to assemble a similar configuration. This could give the 1031 adversary inputs to the mixing process that were sufficiently 1032 correlated to those used originally as to make exhaustive search 1033 practical. 1034 1035 The use of multiple random inputs with a strong mixing function is 1036 recommended and can overcome weakness in any particular input. For 1037 example, the timing and content of requested "random" user keystrokes 1038 can yield hundreds of random bits but conservative assumptions need 1039 to be made. For example, assuming a few bits of randomness if the 1040 inter-keystroke interval is unique in the sequence up to that point 1041 and a similar assumption if the key hit is unique but assuming that 1042 no bits of randomness are present in the initial key value or if the 1043 timing or key value duplicate previous values. The results of mixing 1044 these timings and characters typed could be further combined with 1045 clock values and other inputs. 1046 1047 This strategy may make practical portable code to produce good random 1048 numbers for security even if some of the inputs are very weak on some 1049 of the target systems. However, it may still fail against a high 1050 grade attack on small single user systems, especially if the 1051 adversary has ever been able to observe the generation process in the 1052 past. A hardware based random source is still preferable. 1053 1054 6.3 Cryptographically Strong Sequences 1055 1056 In cases where a series of random quantities must be generated, an 1057 adversary may learn some values in the sequence. In general, they 1058 should not be able to predict other values from the ones that they 1059 know. 1060 1061 1062 1063 1064 1065 1066 Eastlake, Crocker & Schiller [Page 19] 1067 1068 RFC 1750 Randomness Recommendations for Security December 1994 1069 1070 1071 The correct technique is to start with a strong random seed, take 1072 cryptographically strong steps from that seed [CRYPTO2, CRYPTO3], and 1073 do not reveal the complete state of the generator in the sequence 1074 elements. If each value in the sequence can be calculated in a fixed 1075 way from the previous value, then when any value is compromised, all 1076 future values can be determined. This would be the case, for 1077 example, if each value were a constant function of the previously 1078 used values, even if the function were a very strong, non-invertible 1079 message digest function. 1080 1081 It should be noted that if your technique for generating a sequence 1082 of key values is fast enough, it can trivially be used as the basis 1083 for a confidentiality system. If two parties use the same sequence 1084 generating technique and start with the same seed material, they will 1085 generate identical sequences. These could, for example, be xor'ed at 1086 one end with data being send, encrypting it, and xor'ed with this 1087 data as received, decrypting it due to the reversible properties of 1088 the xor operation. 1089 1090 6.3.1 Traditional Strong Sequences 1091 1092 A traditional way to achieve a strong sequence has been to have the 1093 values be produced by hashing the quantities produced by 1094 concatenating the seed with successive integers or the like and then 1095 mask the values obtained so as to limit the amount of generator state 1096 available to the adversary. 1097 1098 It may also be possible to use an "encryption" algorithm with a 1099 random key and seed value to encrypt and feedback some or all of the 1100 output encrypted value into the value to be encrypted for the next 1101 iteration. Appropriate feedback techniques will usually be 1102 recommended with the encryption algorithm. An example is shown below 1103 where shifting and masking are used to combine the cypher output 1104 feedback. This type of feedback is recommended by the US Government 1105 in connection with DES [DES MODES]. 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 Eastlake, Crocker & Schiller [Page 20] 1123 1124 RFC 1750 Randomness Recommendations for Security December 1994 1125 1126 1127 +---------------+ 1128 | V | 1129 | | n | 1130 +--+------------+ 1131 | | +---------+ 1132 | +---------> | | +-----+ 1133 +--+ | Encrypt | <--- | Key | 1134 | +-------- | | +-----+ 1135 | | +---------+ 1136 V V 1137 +------------+--+ 1138 | V | | 1139 | n+1 | 1140 +---------------+ 1141 1142 Note that if a shift of one is used, this is the same as the shift 1143 register technique described in Section 3 above but with the all 1144 important difference that the feedback is determined by a complex 1145 non-linear function of all bits rather than a simple linear or 1146 polynomial combination of output from a few bit position taps. 1147 1148 It has been shown by Donald W. Davies that this sort of shifted 1149 partial output feedback significantly weakens an algorithm compared 1150 will feeding all of the output bits back as input. In particular, 1151 for DES, repeated encrypting a full 64 bit quantity will give an 1152 expected repeat in about 2^63 iterations. Feeding back anything less 1153 than 64 (and more than 0) bits will give an expected repeat in 1154 between 2**31 and 2**32 iterations! 1155 1156 To predict values of a sequence from others when the sequence was 1157 generated by these techniques is equivalent to breaking the 1158 cryptosystem or inverting the "non-invertible" hashing involved with 1159 only partial information available. The less information revealed 1160 each iteration, the harder it will be for an adversary to predict the 1161 sequence. Thus it is best to use only one bit from each value. It 1162 has been shown that in some cases this makes it impossible to break a 1163 system even when the cryptographic system is invertible and can be 1164 broken if all of each generated value was revealed. 1165 1166 6.3.2 The Blum Blum Shub Sequence Generator 1167 1168 Currently the generator which has the strongest public proof of 1169 strength is called the Blum Blum Shub generator after its inventors 1170 [BBS]. It is also very simple and is based on quadratic residues. 1171 It's only disadvantage is that is is computationally intensive 1172 compared with the traditional techniques give in 6.3.1 above. This 1173 is not a serious draw back if it is used for moderately infrequent 1174 purposes, such as generating session keys. 1175 1176 1177 1178 Eastlake, Crocker & Schiller [Page 21] 1179 1180 RFC 1750 Randomness Recommendations for Security December 1994 1181 1182 1183 Simply choose two large prime numbers, say p and q, which both have 1184 the property that you get a remainder of 3 if you divide them by 4. 1185 Let n = p * q. Then you choose a random number x relatively prime to 1186 n. The initial seed for the generator and the method for calculating 1187 subsequent values are then 1188 1189 2 1190 s = ( x )(Mod n) 1191 0 1192 1193 2 1194 s = ( s )(Mod n) 1195 i+1 i 1196 1197 You must be careful to use only a few bits from the bottom of each s. 1198 It is always safe to use only the lowest order bit. If you use no 1199 more than the 1200 1201 log ( log ( s ) ) 1202 2 2 i 1203 1204 low order bits, then predicting any additional bits from a sequence 1205 generated in this manner is provable as hard as factoring n. As long 1206 as the initial x is secret, you can even make n public if you want. 1207 1208 An intersting characteristic of this generator is that you can 1209 directly calculate any of the s values. In particular 1210 1211 i 1212 ( ( 2 )(Mod (( p - 1 ) * ( q - 1 )) ) ) 1213 s = ( s )(Mod n) 1214 i 0 1215 1216 This means that in applications where many keys are generated in this 1217 fashion, it is not necessary to save them all. Each key can be 1218 effectively indexed and recovered from that small index and the 1219 initial s and n. 1220 1221 7. Key Generation Standards 1222 1223 Several public standards are now in place for the generation of keys. 1224 Two of these are described below. Both use DES but any equally 1225 strong or stronger mixing function could be substituted. 1226 1227 1228 1229 1230 1231 1232 1233 1234 Eastlake, Crocker & Schiller [Page 22] 1235 1236 RFC 1750 Randomness Recommendations for Security December 1994 1237 1238 1239 7.1 US DoD Recommendations for Password Generation 1240 1241 The United States Department of Defense has specific recommendations 1242 for password generation [DoD]. They suggest using the US Data 1243 Encryption Standard [DES] in Output Feedback Mode [DES MODES] as 1244 follows: 1245 1246 use an initialization vector determined from 1247 the system clock, 1248 system ID, 1249 user ID, and 1250 date and time; 1251 use a key determined from 1252 system interrupt registers, 1253 system status registers, and 1254 system counters; and, 1255 as plain text, use an external randomly generated 64 bit 1256 quantity such as 8 characters typed in by a system 1257 administrator. 1258 1259 The password can then be calculated from the 64 bit "cipher text" 1260 generated in 64-bit Output Feedback Mode. As many bits as are needed 1261 can be taken from these 64 bits and expanded into a pronounceable 1262 word, phrase, or other format if a human being needs to remember the 1263 password. 1264 1265 7.2 X9.17 Key Generation 1266 1267 The American National Standards Institute has specified a method for 1268 generating a sequence of keys as follows: 1269 1270 s is the initial 64 bit seed 1271 0 1272 1273 g is the sequence of generated 64 bit key quantities 1274 n 1275 1276 k is a random key reserved for generating this key sequence 1277 1278 t is the time at which a key is generated to as fine a resolution 1279 as is available (up to 64 bits). 1280 1281 DES ( K, Q ) is the DES encryption of quantity Q with key K 1282 1283 1284 1285 1286 1287 1288 1289 1290 Eastlake, Crocker & Schiller [Page 23] 1291 1292 RFC 1750 Randomness Recommendations for Security December 1994 1293 1294 1295 g = DES ( k, DES ( k, t ) .xor. s ) 1296 n n 1297 1298 s = DES ( k, DES ( k, t ) .xor. g ) 1299 n+1 n 1300 1301 If g sub n is to be used as a DES key, then every eighth bit should 1302 be adjusted for parity for that use but the entire 64 bit unmodified 1303 g should be used in calculating the next s. 1304 1305 8. Examples of Randomness Required 1306 1307 Below are two examples showing rough calculations of needed 1308 randomness for security. The first is for moderate security 1309 passwords while the second assumes a need for a very high security 1310 cryptographic key. 1311 1312 8.1 Password Generation 1313 1314 Assume that user passwords change once a year and it is desired that 1315 the probability that an adversary could guess the password for a 1316 particular account be less than one in a thousand. Further assume 1317 that sending a password to the system is the only way to try a 1318 password. Then the crucial question is how often an adversary can 1319 try possibilities. Assume that delays have been introduced into a 1320 system so that, at most, an adversary can make one password try every 1321 six seconds. That's 600 per hour or about 15,000 per day or about 1322 5,000,000 tries in a year. Assuming any sort of monitoring, it is 1323 unlikely someone could actually try continuously for a year. In 1324 fact, even if log files are only checked monthly, 500,000 tries is 1325 more plausible before the attack is noticed and steps taken to change 1326 passwords and make it harder to try more passwords. 1327 1328 To have a one in a thousand chance of guessing the password in 1329 500,000 tries implies a universe of at least 500,000,000 passwords or 1330 about 2^29. Thus 29 bits of randomness are needed. This can probably 1331 be achieved using the US DoD recommended inputs for password 1332 generation as it has 8 inputs which probably average over 5 bits of 1333 randomness each (see section 7.1). Using a list of 1000 words, the 1334 password could be expressed as a three word phrase (1,000,000,000 1335 possibilities) or, using case insensitive letters and digits, six 1336 would suffice ((26+10)^6 = 2,176,782,336 possibilities). 1337 1338 For a higher security password, the number of bits required goes up. 1339 To decrease the probability by 1,000 requires increasing the universe 1340 of passwords by the same factor which adds about 10 bits. Thus to 1341 have only a one in a million chance of a password being guessed under 1342 the above scenario would require 39 bits of randomness and a password 1343 1344 1345 1346 Eastlake, Crocker & Schiller [Page 24] 1347 1348 RFC 1750 Randomness Recommendations for Security December 1994 1349 1350 1351 that was a four word phrase from a 1000 word list or eight 1352 letters/digits. To go to a one in 10^9 chance, 49 bits of randomness 1353 are needed implying a five word phrase or ten letter/digit password. 1354 1355 In a real system, of course, there are also other factors. For 1356 example, the larger and harder to remember passwords are, the more 1357 likely users are to write them down resulting in an additional risk 1358 of compromise. 1359 1360 8.2 A Very High Security Cryptographic Key 1361 1362 Assume that a very high security key is needed for symmetric 1363 encryption / decryption between two parties. Assume an adversary can 1364 observe communications and knows the algorithm being used. Within 1365 the field of random possibilities, the adversary can try key values 1366 in hopes of finding the one in use. Assume further that brute force 1367 trial of keys is the best the adversary can do. 1368 1369 8.2.1 Effort per Key Trial 1370 1371 How much effort will it take to try each key? For very high security 1372 applications it is best to assume a low value of effort. Even if it 1373 would clearly take tens of thousands of computer cycles or more to 1374 try a single key, there may be some pattern that enables huge blocks 1375 of key values to be tested with much less effort per key. Thus it is 1376 probably best to assume no more than a couple hundred cycles per key. 1377 (There is no clear lower bound on this as computers operate in 1378 parallel on a number of bits and a poor encryption algorithm could 1379 allow many keys or even groups of keys to be tested in parallel. 1380 However, we need to assume some value and can hope that a reasonably 1381 strong algorithm has been chosen for our hypothetical high security 1382 task.) 1383 1384 If the adversary can command a highly parallel processor or a large 1385 network of work stations, 2*10^10 cycles per second is probably a 1386 minimum assumption for availability today. Looking forward just a 1387 couple years, there should be at least an order of magnitude 1388 improvement. Thus assuming 10^9 keys could be checked per second or 1389 3.6*10^11 per hour or 6*10^13 per week or 2.4*10^14 per month is 1390 reasonable. This implies a need for a minimum of 51 bits of 1391 randomness in keys to be sure they cannot be found in a month. Even 1392 then it is possible that, a few years from now, a highly determined 1393 and resourceful adversary could break the key in 2 weeks (on average 1394 they need try only half the keys). 1395 1396 1397 1398 1399 1400 1401 1402 Eastlake, Crocker & Schiller [Page 25] 1403 1404 RFC 1750 Randomness Recommendations for Security December 1994 1405 1406 1407 8.2.2 Meet in the Middle Attacks 1408 1409 If chosen or known plain text and the resulting encrypted text are 1410 available, a "meet in the middle" attack is possible if the structure 1411 of the encryption algorithm allows it. (In a known plain text 1412 attack, the adversary knows all or part of the messages being 1413 encrypted, possibly some standard header or trailer fields. In a 1414 chosen plain text attack, the adversary can force some chosen plain 1415 text to be encrypted, possibly by "leaking" an exciting text that 1416 would then be sent by the adversary over an encrypted channel.) 1417 1418 An oversimplified explanation of the meet in the middle attack is as 1419 follows: the adversary can half-encrypt the known or chosen plain 1420 text with all possible first half-keys, sort the output, then half- 1421 decrypt the encoded text with all the second half-keys. If a match 1422 is found, the full key can be assembled from the halves and used to 1423 decrypt other parts of the message or other messages. At its best, 1424 this type of attack can halve the exponent of the work required by 1425 the adversary while adding a large but roughly constant factor of 1426 effort. To be assured of safety against this, a doubling of the 1427 amount of randomness in the key to a minimum of 102 bits is required. 1428 1429 The meet in the middle attack assumes that the cryptographic 1430 algorithm can be decomposed in this way but we can not rule that out 1431 without a deep knowledge of the algorithm. Even if a basic algorithm 1432 is not subject to a meet in the middle attack, an attempt to produce 1433 a stronger algorithm by applying the basic algorithm twice (or two 1434 different algorithms sequentially) with different keys may gain less 1435 added security than would be expected. Such a composite algorithm 1436 would be subject to a meet in the middle attack. 1437 1438 Enormous resources may be required to mount a meet in the middle 1439 attack but they are probably within the range of the national 1440 security services of a major nation. Essentially all nations spy on 1441 other nations government traffic and several nations are believed to 1442 spy on commercial traffic for economic advantage. 1443 1444 8.2.3 Other Considerations 1445 1446 Since we have not even considered the possibilities of special 1447 purpose code breaking hardware or just how much of a safety margin we 1448 want beyond our assumptions above, probably a good minimum for a very 1449 high security cryptographic key is 128 bits of randomness which 1450 implies a minimum key length of 128 bits. If the two parties agree 1451 on a key by Diffie-Hellman exchange [D-H], then in principle only 1452 half of this randomness would have to be supplied by each party. 1453 However, there is probably some correlation between their random 1454 inputs so it is probably best to assume that each party needs to 1455 1456 1457 1458 Eastlake, Crocker & Schiller [Page 26] 1459 1460 RFC 1750 Randomness Recommendations for Security December 1994 1461 1462 1463 provide at least 96 bits worth of randomness for very high security 1464 if Diffie-Hellman is used. 1465 1466 This amount of randomness is beyond the limit of that in the inputs 1467 recommended by the US DoD for password generation and could require 1468 user typing timing, hardware random number generation, or other 1469 sources. 1470 1471 It should be noted that key length calculations such at those above 1472 are controversial and depend on various assumptions about the 1473 cryptographic algorithms in use. In some cases, a professional with 1474 a deep knowledge of code breaking techniques and of the strength of 1475 the algorithm in use could be satisfied with less than half of the 1476 key size derived above. 1477 1478 9. Conclusion 1479 1480 Generation of unguessable "random" secret quantities for security use 1481 is an essential but difficult task. 1482 1483 We have shown that hardware techniques to produce such randomness 1484 would be relatively simple. In particular, the volume and quality 1485 would not need to be high and existing computer hardware, such as 1486 disk drives, can be used. Computational techniques are available to 1487 process low quality random quantities from multiple sources or a 1488 larger quantity of such low quality input from one source and produce 1489 a smaller quantity of higher quality, less predictable key material. 1490 In the absence of hardware sources of randomness, a variety of user 1491 and software sources can frequently be used instead with care; 1492 however, most modern systems already have hardware, such as disk 1493 drives or audio input, that could be used to produce high quality 1494 randomness. 1495 1496 Once a sufficient quantity of high quality seed key material (a few 1497 hundred bits) is available, strong computational techniques are 1498 available to produce cryptographically strong sequences of 1499 unpredicatable quantities from this seed material. 1500 1501 10. Security Considerations 1502 1503 The entirety of this document concerns techniques and recommendations 1504 for generating unguessable "random" quantities for use as passwords, 1505 cryptographic keys, and similar security uses. 1506 1507 1508 1509 1510 1511 1512 1513 1514 Eastlake, Crocker & Schiller [Page 27] 1515 1516 RFC 1750 Randomness Recommendations for Security December 1994 1517 1518 1519 References 1520 1521 [ASYMMETRIC] - Secure Communications and Asymmetric Cryptosystems, 1522 edited by Gustavus J. Simmons, AAAS Selected Symposium 69, Westview 1523 Press, Inc. 1524 1525 [BBS] - A Simple Unpredictable Pseudo-Random Number Generator, SIAM 1526 Journal on Computing, v. 15, n. 2, 1986, L. Blum, M. Blum, & M. Shub. 1527 1528 [BRILLINGER] - Time Series: Data Analysis and Theory, Holden-Day, 1529 1981, David Brillinger. 1530 1531 [CRC] - C.R.C. Standard Mathematical Tables, Chemical Rubber 1532 Publishing Company. 1533 1534 [CRYPTO1] - Cryptography: A Primer, A Wiley-Interscience Publication, 1535 John Wiley & Sons, 1981, Alan G. Konheim. 1536 1537 [CRYPTO2] - Cryptography: A New Dimension in Computer Data Security, 1538 A Wiley-Interscience Publication, John Wiley & Sons, 1982, Carl H. 1539 Meyer & Stephen M. Matyas. 1540 1541 [CRYPTO3] - Applied Cryptography: Protocols, Algorithms, and Source 1542 Code in C, John Wiley & Sons, 1994, Bruce Schneier. 1543 1544 [DAVIS] - Cryptographic Randomness from Air Turbulence in Disk 1545 Drives, Advances in Cryptology - Crypto '94, Springer-Verlag Lecture 1546 Notes in Computer Science #839, 1984, Don Davis, Ross Ihaka, and 1547 Philip Fenstermacher. 1548 1549 [DES] - Data Encryption Standard, United States of America, 1550 Department of Commerce, National Institute of Standards and 1551 Technology, Federal Information Processing Standard (FIPS) 46-1. 1552 - Data Encryption Algorithm, American National Standards Institute, 1553 ANSI X3.92-1981. 1554 (See also FIPS 112, Password Usage, which includes FORTRAN code for 1555 performing DES.) 1556 1557 [DES MODES] - DES Modes of Operation, United States of America, 1558 Department of Commerce, National Institute of Standards and 1559 Technology, Federal Information Processing Standard (FIPS) 81. 1560 - Data Encryption Algorithm - Modes of Operation, American National 1561 Standards Institute, ANSI X3.106-1983. 1562 1563 [D-H] - New Directions in Cryptography, IEEE Transactions on 1564 Information Technology, November, 1976, Whitfield Diffie and Martin 1565 E. Hellman. 1566 1567 1568 1569 1570 Eastlake, Crocker & Schiller [Page 28] 1571 1572 RFC 1750 Randomness Recommendations for Security December 1994 1573 1574 1575 [DoD] - Password Management Guideline, United States of America, 1576 Department of Defense, Computer Security Center, CSC-STD-002-85. 1577 (See also FIPS 112, Password Usage, which incorporates CSC-STD-002-85 1578 as one of its appendices.) 1579 1580 [GIFFORD] - Natural Random Number, MIT/LCS/TM-371, September 1988, 1581 David K. Gifford 1582 1583 [KNUTH] - The Art of Computer Programming, Volume 2: Seminumerical 1584 Algorithms, Chapter 3: Random Numbers. Addison Wesley Publishing 1585 Company, Second Edition 1982, Donald E. Knuth. 1586 1587 [KRAWCZYK] - How to Predict Congruential Generators, Journal of 1588 Algorithms, V. 13, N. 4, December 1992, H. Krawczyk 1589 1590 [MD2] - The MD2 Message-Digest Algorithm, RFC1319, April 1992, B. 1591 Kaliski 1592 [MD4] - The MD4 Message-Digest Algorithm, RFC1320, April 1992, R. 1593 Rivest 1594 [MD5] - The MD5 Message-Digest Algorithm, RFC1321, April 1992, R. 1595 Rivest 1596 1597 [PEM] - RFCs 1421 through 1424: 1598 - RFC 1424, Privacy Enhancement for Internet Electronic Mail: Part 1599 IV: Key Certification and Related Services, 02/10/1993, B. Kaliski 1600 - RFC 1423, Privacy Enhancement for Internet Electronic Mail: Part 1601 III: Algorithms, Modes, and Identifiers, 02/10/1993, D. Balenson 1602 - RFC 1422, Privacy Enhancement for Internet Electronic Mail: Part 1603 II: Certificate-Based Key Management, 02/10/1993, S. Kent 1604 - RFC 1421, Privacy Enhancement for Internet Electronic Mail: Part I: 1605 Message Encryption and Authentication Procedures, 02/10/1993, J. Linn 1606 1607 [SHANNON] - The Mathematical Theory of Communication, University of 1608 Illinois Press, 1963, Claude E. Shannon. (originally from: Bell 1609 System Technical Journal, July and October 1948) 1610 1611 [SHIFT1] - Shift Register Sequences, Aegean Park Press, Revised 1612 Edition 1982, Solomon W. Golomb. 1613 1614 [SHIFT2] - Cryptanalysis of Shift-Register Generated Stream Cypher 1615 Systems, Aegean Park Press, 1984, Wayne G. Barker. 1616 1617 [SHS] - Secure Hash Standard, United States of American, National 1618 Institute of Science and Technology, Federal Information Processing 1619 Standard (FIPS) 180, April 1993. 1620 1621 [STERN] - Secret Linear Congruential Generators are not 1622 Cryptograhically Secure, Proceedings of IEEE STOC, 1987, J. Stern. 1623 1624 1625 1626 Eastlake, Crocker & Schiller [Page 29] 1627 1628 RFC 1750 Randomness Recommendations for Security December 1994 1629 1630 1631 [VON NEUMANN] - Various techniques used in connection with random 1632 digits, von Neumann's Collected Works, Vol. 5, Pergamon Press, 1963, 1633 J. von Neumann. 1634 1635 Authors' Addresses 1636 1637 Donald E. Eastlake 3rd 1638 Digital Equipment Corporation 1639 550 King Street, LKG2-1/BB3 1640 Littleton, MA 01460 1641 1642 Phone: +1 508 486 6577(w) +1 508 287 4877(h) 1643 EMail: dee@lkg.dec.com 1644 1645 1646 Stephen D. Crocker 1647 CyberCash Inc. 1648 2086 Hunters Crest Way 1649 Vienna, VA 22181 1650 1651 Phone: +1 703-620-1222(w) +1 703-391-2651 (fax) 1652 EMail: crocker@cybercash.com 1653 1654 1655 Jeffrey I. Schiller 1656 Massachusetts Institute of Technology 1657 77 Massachusetts Avenue 1658 Cambridge, MA 02139 1659 1660 Phone: +1 617 253 0161(w) 1661 EMail: jis@mit.edu 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 Eastlake, Crocker & Schiller [Page 30] 1683