Cryptographic Hashes and MACs
CS 161 Spring 2025 - Lecture 9
Computer Science 161
Last Time: Block Ciphers and Modes of Operation
2
Computer Science 161
Today: Cryptography Hashes and MACs
3
Computer Science 161
Cryptographic Hashes
4
Textbook Chapter 7.1–7.3
Computer Science 161
Cryptography Roadmap
5
| Symmetric-key | Asymmetric-key |
Confidentiality |
|
|
Integrity,�Authentication |
|
|
Computer Science 161
Cryptographic Hash Function: Definition
6
Computer Science 161
Hash Function: Intuition
7
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
8
Computer Science 161
Hash Function: Collision Resistance
9
Computer Science 161
Hash Function: Collision Resistance
10
Computer Science 161
Hash Function: Examples
11
A GIF that displays its own MD5 hash
Computer Science 161
Length Extension Attacks
12
Computer Science 161
Do hashes provide integrity?
13
Computer Science 161
Do hashes provide integrity?
14
Alice
Bob
M, H(M)
X
MI
X
H(MI)
Computer Science 161
Do hashes provide integrity?
15
Computer Science 161
Message Authentication Codes (MACs)
16
Textbook Chapter 8.1–8.3 & 8.5–8.6
Computer Science 161
Cryptography Roadmap
17
| Symmetric-key | Asymmetric-key |
Confidentiality |
|
|
Integrity,�Authentication |
|
|
Computer Science 161
How to Provide Integrity
18
Computer Science 161
MACs: Usage
19
Message
Key
MAC
Message
Key
Verify
Message
Alice
Bob
Insecure Channel
T
Computer Science 161
MACs: Definition
20
Computer Science 161
Defining Integrity: EU-CPA
21
Computer Science 161
Defining Integrity: EU-CPA
22
M
MAC(K, M)
(repeat)
Alice (challenger)
Mallory (adversary)
Output (M', T')
Computer Science 161
MACs: Usage
23
Message
Key
MAC
Message
Key
Verify
Message
Alice
Bob
Insecure Channel
T
Computer Science 161
Example: NMAC
24
Computer Science 161
Example: HMAC
25
Computer Science 161
Example: HMAC
26
Computer Science 161
HMAC Properties
27
Computer Science 161
Do MACs provide integrity?
28
Computer Science 161
Authenticated Encryption
29
Textbook Chapter 8.7 & 8.8
Computer Science 161
Cryptography Roadmap
30
| Symmetric-key | Asymmetric-key |
Confidentiality |
|
|
Integrity,�Authentication |
|
|
Computer Science 161
Authenticated Encryption: Definition
31
Computer Science 161
Combining Schemes: Let’s design it together
32
Computer Science 161
MAC-then-Encrypt or Encrypt-then-MAC?
33
Computer Science 161
Key Reuse
34
Lecture Version Definition
Enc(K, M) MAC(K, Enc(K, M))
Computer Science 161
Key Reuse
35
Computer Science 161
TLS 1.0 “Lucky 13” Attack
36
Computer Science 161
AEAD Encryption
37
Computer Science 161
AEAD Example: Galois Counter Mode (GCM)
38
Computer Science 161
AEAD Example: Galois Counter Mode (GCM)
39
Computer Science 161
Hashes: Summary
40
Computer Science 161
MACs: Summary
41
Computer Science 161
Authenticated Encryption: Summary
42
Computer Science 161
Next Time
43
Computer Science 161