pseudo random numbers and stream
play

Pseudo-Random Numbers and Stream PRNG+Block Ciphers Stream Ciphers - PowerPoint PPT Presentation

CSS441 Random Numbers Principles PRNGs Pseudo-Random Numbers and Stream PRNG+Block Ciphers Stream Ciphers RC4 CSS441: Security and Cryptography Sirindhorn International Institute of Technology Thammasat University Prepared by Steven


  1. CSS441 Random Numbers Principles PRNGs Pseudo-Random Numbers and Stream PRNG+Block Ciphers Stream Ciphers RC4 CSS441: Security and Cryptography Sirindhorn International Institute of Technology Thammasat University Prepared by Steven Gordon on 20 December 2015 css441y15s2l05, Steve/Courses/2015/s2/css441/lectures/pseudo-random-numbers-and-stream-ciphers.tex, r4295 1/24

  2. CSS441 Contents Random Numbers Principles Principles of Pseudo-Random Number Generation PRNGs PRNG+Block Stream Ciphers RC4 Pseudo-Random Number Generators PRNGs using Block Ciphers Stream Ciphers RC4 2/24

  3. CSS441 Random Numbers Random Numbers Use of Random Numbers Principles PRNGs ◮ Key distribution and authentication schemes PRNG+Block ◮ Generation of session keys or keys for RSA Stream Ciphers ◮ Generation of bit stream for stream ciphers RC4 Randomness ◮ Uniform distribution: frequency of occurrence of 1’s and 0’s approximately equal ◮ Independence: no sub-sequence can be inferred from others Unpredictability ◮ Hard to predict next value in sequence 3/24

  4. CSS441 TRNG, PRNG and PRF Random Numbers True Random Number Generator Principles PRNGs ◮ Non-deterministic source, physical environment PRNG+Block ◮ Detect ionizing radiation events, leaky capacitors, Stream Ciphers thermal noise from resistors or audio inputs RC4 ◮ Mouse/keyboard activity, I/O operations, interrupts ◮ Inconvenient, small number of values Pseudo Random Number Generator ◮ Deterministic algorithms to calculate numbers in “relatively random” sequence ◮ Seed is algorithm input ◮ Produces continuous stream of random bits Pseudo Random Function ◮ Same as PRNG but produces string of bits of some 4/24 fixed length

  5. CSS441 Random and Pseudo-Random Number Random Numbers Generators Principles PRNGs PRNG+Block Stream Ciphers RC4 5/24

  6. CSS441 Requirements of PRNG Random Numbers Hard to determine pseudo-random stream if don’t know seed Principles (but know algorithm) PRNGs ◮ Randomness PRNG+Block ◮ Test for uniformity, scalability, consistency Stream Ciphers ◮ Examples: Frequency, runs, compressability RC4 ◮ Unpredictability ◮ Forward and backward unpredictability ◮ Seed must be secure ◮ Use TRNG to generate seed 6/24

  7. CSS441 Generation of Seed Input to PRNG Random Numbers Principles PRNGs PRNG+Block Stream Ciphers RC4 7/24

  8. CSS441 Contents Random Numbers Principles Principles of Pseudo-Random Number Generation PRNGs PRNG+Block Stream Ciphers RC4 Pseudo-Random Number Generators PRNGs using Block Ciphers Stream Ciphers RC4 8/24

  9. CSS441 Linear Congruential Generator Random Numbers Parameters: Principles ◮ m , the modulus, m > 0 PRNGs PRNG+Block ◮ a , the multiplier, 0 < a < m Stream Ciphers ◮ c , the increment, 0 ≤ c < m RC4 ◮ X 0 , the seed, 0 ≤ X 0 < m Generate sequence of pseudo-random numbers, { X n } : X n +1 = ( aX n + c ) mod m Choice of a , c and m is important: ◮ m should be large, prime, e.g. 2 31 − 1 ◮ If c =0, few good values of a , e.g. 7 5 = 16807 If attacker knows parameters and one number, can easily determine subsequent numbers 9/24

  10. CSS441 Blum Blum Shub Generator Random Numbers Parameters: Principles ◮ p , q : large prime numbers such that p ≡ q ≡ 3 (mod 4) PRNGs PRNG+Block ◮ n = p × q Stream Ciphers ◮ s , random number relatively prime to n RC4 Generate sequence of bits, B i : s 2 mod n X 0 = for i = 1 → ∞ ( X i − 1 ) 2 mod n X i = B i = X i mod 2 Cryptographically secure pseudo-random bit generator 10/24

  11. CSS441 Example Operation of BBS Generator Random Numbers n = 192649 = 383 × 503, s = 101355 Principles PRNGs PRNG+Block i X i B i i X i B i Stream Ciphers 0 20749 11 137922 0 RC4 1 143135 1 12 123175 1 2 177671 1 13 8630 0 3 97048 0 14 114386 0 4 89992 0 15 14863 1 5 174051 1 16 133015 1 6 80649 1 17 106065 1 7 45663 1 18 45870 0 8 69442 0 19 137171 1 9 186894 0 20 48060 0 10 177046 0 11/24

  12. CSS441 Contents Random Numbers Principles Principles of Pseudo-Random Number Generation PRNGs PRNG+Block Stream Ciphers RC4 Pseudo-Random Number Generators PRNGs using Block Ciphers Stream Ciphers RC4 12/24

  13. CSS441 PRNG Mechanisms Based on Block Ciphers Random Numbers Use symmetric block ciphers (e.g. AES, DES) to produce Principles pseudo-random bits PRNGs ◮ Seed is encryption key, K , and value V (which is PRNG+Block updated) Stream Ciphers RC4 OFB Mode Counter Mode 13/24

  14. CSS441 ANSI X9.17 PRNG Random Numbers Cryptographically secure PRNG using Triple DES Principles Parameters: PRNGs ◮ 64-bit date/time representation, DT i PRNG+Block Stream Ciphers ◮ 64-bit seed value, V i RC4 ◮ Pair of 56-bit DES keys, K 1 and K 2 Operation: ◮ Uses Triple DES three times ◮ (see next slide) Output: ◮ 64-bit pseudo-random number, R i ◮ 64-bit seed value, V i +1 14/24

  15. CSS441 ANSI X9.17 PRNG Random Numbers Principles PRNGs PRNG+Block Stream Ciphers RC4 15/24

  16. CSS441 Contents Random Numbers Principles Principles of Pseudo-Random Number Generation PRNGs PRNG+Block Stream Ciphers RC4 Pseudo-Random Number Generators PRNGs using Block Ciphers Stream Ciphers RC4 16/24

  17. CSS441 Stream Ciphers Random Numbers Encrypt one byte at a time by XOR with pseudo-random byte Principles PRNGs PRNG+Block Stream Ciphers RC4 Output of generator is called keystream 17/24

  18. CSS441 Design Criteria for Stream Ciphers Random Numbers Important Considerations Principles PRNGs ◮ Encryption sequence should have large period PRNG+Block ◮ Keystream should approximate true random number Stream Ciphers stream RC4 ◮ Key must withstand brute force attacks Comparison to Block Ciphers ◮ Stream ciphers often simpler to implement, faster ◮ Block ciphers can re-use keys 18/24

  19. CSS441 Contents Random Numbers Principles Principles of Pseudo-Random Number Generation PRNGs PRNG+Block Stream Ciphers RC4 Pseudo-Random Number Generators PRNGs using Block Ciphers Stream Ciphers RC4 19/24

  20. CSS441 RC4 Random Numbers ◮ Designed by Ron Rivest in 1987 Principles ◮ Used in secure web browsing and wireless LANs PRNGs ◮ Very simple and efficient implementation PRNG+Block Stream Ciphers ◮ Can use variable size key: 8 to 2048 bits RC4 ◮ Several theoretical limitations of RC4 ◮ No known attacks if use 128-bit key and discard initial values of stream ◮ RC4 is used in WEP (shown to be weak security for wireless LANs)—problem with how keys are used, not RC4 algorithm 20/24

  21. CSS441 RC4 Algorithm Random Numbers Parameters and Variables Principles PRNGs ◮ Variable length key, K , from 1 to 256 Bytes PRNG+Block ◮ State vector, S , 256 Bytes Stream Ciphers ◮ Temporary vector, T , 256 Bytes RC4 ◮ A byte from keystream, k , generated from S Steps 1. Initialise S to values 0 to 255; initialise T with repeating values of key, K 2. Use T to create initial permutation of S 3. Permutate S and generate keystream, k from S 4. Encrypt a byte of plaintext, p , by XOR with k 21/24

  22. CSS441 Initial State of S and T Random Numbers for i = 0 to 255 do Principles S[i] = i; PRNGs T[i] = K[i mod keylen]; PRNG+Block Stream Ciphers RC4 22/24

  23. CSS441 Initial Permutation of S Random Numbers j = 0; Principles for i = 0 to 255 do PRNGs j = (j + S[i] + T[i]) mod 256; PRNG+Block Swap (S[i], S[j]); Stream Ciphers RC4 23/24

  24. CSS441 Stream Generation Random Numbers i, j = 0; Principles while (true) PRNGs i = (i + 1) mod 256; PRNG+Block j = (J + S[i]) mod 256; Stream Ciphers Swap (S[i], S[j]); RC4 t = (S[i] + S[j]) mod 256; k = S[t]; To encrypt: C = p XOR k To decrypt: p = C XOR k 24/24

Recommend


More recommend