Cryptographic Hashes and MACs
CS 161 Fall 2023 - Lecture 9
Computer Science 161
Last Time: Block Ciphers
2
Computer Science 161
Last Time: Block Cipher Modes of Operation
3
Computer Science 161
Lack of Integrity and Authenticity
4
Computer Science 161
Lack of Integrity and Authenticity
5
P | a | y | | M | a | l | | $ | 1 | 0 | 0 |
0x50 | 0x61 | 0x79 | 0x20 | 0x4d | 0x61 | 0x6c | 0x20 | 0x24 | 0x31 | 0x30 | 0x30 |
0x8a | 0xe3 | 0x5e | 0xcf | 0x3b | 0x40 | 0x46 | 0x57 | 0xb8 | 0x69 | 0xd2 | 0x96 |
⊕
=
0xda | 0x82 | 0x27 | 0xef | 0x76 | 0x21 | 0x2a | 0x77 | 0x9c | 0x58 | 0xe2 | 0xa6 |
M
EK(i)
C
Computer Science 161
Lack of Integrity and Authenticity
6
P | a | y | | M | a | l | | $ | 1 | 0 | 0 |
0x50 | 0x61 | 0x79 | 0x20 | 0x4d | 0x61 | 0x6c | 0x20 | 0x24 | 0x31 | 0x30 | 0x30 |
0x8a | 0xe3 | 0x5e | 0xcf | 0x3b | 0x40 | 0x46 | 0x57 | 0xb8 | 0x69 | 0xd2 | 0x96 |
⊕
=
0xda | 0x82 | 0x27 | 0xef | 0x76 | 0x21 | 0x2a | 0x77 | 0x9c | 0x58 | 0xe2 | 0xa6 |
M
EK(i)
C
Computer Science 161
Lack of Integrity and Authenticity
7
Ci | = | Mi ⊕ Padi | 0x58 | = | 0x31 ⊕ Padi | Definition of CTR |
Padi | = | Mi ⊕ Ci | Padi | = | 0x58 ⊕ 0x31 | Solve for the ith byte of the pad |
| | | | = | 0x69 | |
C'i | = | M'i ⊕ Padi | C'i | = | 0x39 ⊕ 0x69 | Compute the changed ith byte |
| | | | = | 0x50 | |
0xda | 0x82 | 0x27 | 0xef | 0x76 | 0x21 | 0x2a | 0x77 | 0x9c | 0x58 | 0xe2 | 0xa6 |
0xda | 0x82 | 0x27 | 0xef | 0x76 | 0x21 | 0x2a | 0x77 | 0x9c | 0x50 | 0xe2 | 0xa6 |
C
C’
Computer Science 161
Lack of Integrity and Authenticity
8
0xda | 0x82 | 0x27 | 0xef | 0x76 | 0x21 | 0x2a | 0x77 | 0x9c | 0x50 | 0xe2 | 0xa6 |
0x8a | 0xe3 | 0x5e | 0xcf | 0x3b | 0x40 | 0x46 | 0x57 | 0xb8 | 0x69 | 0xd2 | 0x96 |
⊕
=
C'
P'
0x50 | 0x61 | 0x79 | 0x20 | 0x4d | 0x61 | 0x6c | 0x20 | 0x24 | 0x39 | 0x30 | 0x30 |
P | a | y | | M | a | l | | $ | 9 | 0 | 0 |
EK(i)
Computer Science 161
Lack of Integrity and Authenticity
9
Computer Science 161
Today: Cryptography Hashes and MACs
10
Computer Science 161
Cryptographic Hashes
11
Textbook Chapter 7.1–7.3
Computer Science 161
Cryptography Roadmap
12
| Symmetric-key | Asymmetric-key |
Confidentiality |
|
|
Integrity,�Authentication |
|
|
Computer Science 161
Cryptographic Hash Function: Definition
13
Computer Science 161
Hash Function: Intuition
14
Computer Science 161
Hash Function: One-way-ness or Preimage Resistance
Pr[x chosen randomly from plaintext space; y = H(x):
Adv(y) outputs x' s.t. H(x') = y] is negligible
15
Computer Science 161
Hash Function: Collision Resistance
16
Computer Science 161
Hash Function: Collision Resistance
17
Computer Science 161
Hash Function: Examples
18
A GIF that displays its own MD5 hash
Computer Science 161
Length Extension Attacks
19
Computer Science 161
Do hashes provide integrity?
20
Computer Science 161
Do hashes provide integrity?
21
Computer Science 161
Do hashes provide integrity?
22
Computer Science 161
Message Authentication Codes (MACs)
23
Textbook Chapter 8.1–8.3 & 8.5–8.6
Computer Science 161
Cryptography Roadmap
24
| Symmetric-key | Asymmetric-key |
Confidentiality |
|
|
Integrity,�Authentication |
|
|
Computer Science 161
How to Provide Integrity
25
Computer Science 161
MACs: Usage
26
Message
Key
MAC
Message
Key
Verify
Message
Alice
Bob
Insecure Channel
T
Computer Science 161
MACs: Definition
27
Computer Science 161
Defining Integrity: EU-CPA
28
Computer Science 161
Defining Integrity: EU-CPA
29
M
MAC(K, M)
(repeat)
Alice (challenger)
Mallory (adversary)
Output (M', T')
Computer Science 161
Example: NMAC
30
Computer Science 161
Example: HMAC
31
Computer Science 161
Example: HMAC
32
Computer Science 161
HMAC Properties
33
Computer Science 161
Do MACs provide integrity?
34
Computer Science 161
Authenticated Encryption
35
Textbook Chapter 8.7 & 8.8
Computer Science 161
Cryptography Roadmap
36
| Symmetric-key | Asymmetric-key |
Confidentiality |
|
|
Integrity,�Authentication |
|
|
Computer Science 161
Authenticated Encryption: Definition
37
Computer Science 161
Combining Schemes: Let’s design it together
38
Computer Science 161
MAC-then-Encrypt or Encrypt-then-MAC?
39
Computer Science 161
Key Reuse
40
Computer Science 161
Key Reuse
41
Computer Science 161
TLS 1.0 “Lucky 13” Attack
42
Computer Science 161
AEAD Encryption
43
Computer Science 161
AEAD Example: Galois Counter Mode (GCM)
44
Computer Science 161
AEAD Example: Galois Counter Mode (GCM)
45
Computer Science 161
Hashes: Summary
46
Computer Science 161
MACs: Summary
47
Computer Science 161
Authenticated Encryption: Summary
48
Computer Science 161
Next Time
49
Computer Science 161