PRNGs and Diffie-Hellman Key Exchange
CS 161 Fall 2022 - Lecture 8
Computer Science 161
Fall 2022
Last Time: Hashes
2
Computer Science 161
Fall 2022
Last Time: MACs
3
Computer Science 161
Fall 2022
Last Time: Authenticated Encryption
4
Computer Science 161
Fall 2022
Today: PRNGs and Diffie-Hellman Key Exchange
5
Computer Science 161
Fall 2022
Pseudorandom Number Generators (PRNGs)
6
Textbook Chapter 9
Computer Science 161
Fall 2022
Cryptography Roadmap
7
| Symmetric-key | Asymmetric-key |
Confidentiality |
|
|
Integrity,�Authentication |
|
|
Computer Science 161
Fall 2022
Randomness
8
Computer Science 161
Fall 2022
Entropy
9
Computer Science 161
Fall 2022
Breaking Bitcoin Wallets
10
Computer Science 161
Fall 2022
True Randomness
11
Exotic entropy source: Cloudflare has a wall of lava lamps that are recorded by an HD video camera that views the lamps through a rotating prism
Computer Science 161
Fall 2022
Pseudorandom Number Generators (PRNGs)
12
Computer Science 161
Fall 2022
PRNG: Definition
13
Computer Science 161
Fall 2022
PRNG: Seeding and Reseeding
Computer Science 161
Fall 2022
PRNG: Security
15
Computer Science 161
Fall 2022
Insecure PRNGs: Breaking Slot Machines
16
Computer Science 161
Fall 2022
Insecure PRNGs: OpenSSL PRNG bug
17
Computer Science 161
Fall 2022
PRNG: Rollback Resistance
Computer Science 161
Fall 2022
HMAC-DRBG
19
Computer Science 161
Fall 2022
HMAC-DRBG
Seed(s):
K = 0
V = 0
K = HMAC(K, V || 0x00 || s)
V = HMAC(K, V)
K = HMAC(K, V || 0x01 || s)
V = HMAC(K, V)
Initialize internal state
Update internal state with provided entropy
Computer Science 161
Fall 2022
HMAC-DRBG
Reseed(s):
K = HMAC(K, V || 0x00 || s)
V = HMAC(K, V)
K = HMAC(K, V || 0x01 || s)
V = HMAC(K, V)
Update internal state with provided entropy
Computer Science 161
Fall 2022
HMAC-DRBG
Generate(n):
output = ''
while len(output) < n do
V = HMAC(K, V)
output = output || V
end while�
K = HMAC(K, V || 0x00)
V = HMAC(K, V)
return output[:n]
Call HMAC repeatedly to generate random-looking output
Update internal state with no extra entropy
Computer Science 161
Fall 2022
HMAC-DRBG: Security
Computer Science 161
Fall 2022
Insecure PRNGs: CVE-2019-16303
24
Computer Science 161
Fall 2022
Insecure PRNGs: Rust Rand_Core
25
Computer Science 161
Fall 2022
Application: Universally Unique Identifiers (UUIDs)
26
Computer Science 161
Fall 2022
PRNGs: Summary
27
Computer Science 161
Fall 2022
Stream Ciphers
28
Textbook Chapter 9.5
Computer Science 161
Fall 2022
Stream Ciphers
29
Computer Science 161
Fall 2022
Stream Ciphers
30
⊕
Generate(n)
Seed(k)
Seed(k)
Generate(n)
⊕
Plaintext
Ciphertext
Plaintext
Alice
Bob
Computer Science 161
Fall 2022
Stream Ciphers: Encrypting Multiple Messages
31
⊕
Generate(n)
Seed(k)
Alice
Bob
Seed(k)
Generate(n)
⊕
Plaintext
Ciphertext
Plaintext
Computer Science 161
Fall 2022
Stream Ciphers: Encrypting Multiple Messages
32
⊕
Generate(n)
Seed(k || IV)
Alice
Bob
Seed(k || IV)
Generate(n)
⊕
Plaintext
Ciphertext
Plaintext
IV
IV
Computer Science 161
Fall 2022
Stream Ciphers: AES-CTR
Computer Science 161
Fall 2022
Stream Ciphers: Security
34
Computer Science 161
Fall 2022
Stream Ciphers: Encryption Efficiency
35
Computer Science 161
Fall 2022
Stream Ciphers: Decryption Efficiency
36
Computer Science 161
Fall 2022
Next: Diffie-Hellman Key Exchange
37
Computer Science 161
Fall 2022
Diffie-Hellman Key Exchange
38
Textbook Chapter 10
Computer Science 161
Fall 2022
Cryptography Roadmap
39
| Symmetric-key | Asymmetric-key |
Confidentiality |
|
|
Integrity,�Authentication |
|
|
Computer Science 161
Fall 2022
Secure Color Sharing
Computer Science 161
Fall 2022
Secure Color Sharing
Computer Science 161
Fall 2022
Discrete Log Problem and Diffie-Hellman Problem
42
Computer Science 161
Fall 2022
Diffie-Hellman Key Exchange
43
Alice
Mallory
Bob
Generate a
Calculate ga mod p
Receive gb mod p
Calculate (gb)a mod p
Generate b
Calculate gb mod p
Receive ga mod p
Calculate (ga)b mod p
ga
gb
a, ga, gb ⇒ gab
b, ga, gb ⇒ gab
ga, gb ⇒ gab
Eve
Public: g, p
Shared symmetric key is gab
Secret key
Public key
Computer Science 161
Fall 2022
Ephemerality of Diffie-Hellman
44
Computer Science 161
Fall 2022
Diffie-Hellman: Security
45
Alice
Bob
Generate a
Calculate ga mod p
Receive gm mod p
Calculate (gm)a mod p
Generate b
Calculate gb mod p
Receive gm mod p
Calculate (gm)b mod p
a, ga, gm ⇒ gam
b, gb, gm ⇒ gbm
m, gm, ga ⇒ gam
Mallory
Public: g, p
Generate m
Calculate gm mod p
Receive ga mod p
Calculate (ga)m mod p
Receive gb mod p
Calculate (gb)m mod p
m, gm, gb ⇒ gbm
Computer Science 161
Fall 2022
Diffie-Hellman: Issues
46
Computer Science 161
Fall 2022
Elliptic-Curve Diffie-Hellman (ECDH)
Computer Science 161
Fall 2022
Summary: Diffie-Hellman Key Exchange
48
Computer Science 161
Fall 2022