CH 3 - Authenticated Encryption
CH 3 - Authenticated Encryption
Authenticated Encryption
Active attacks on
CPA-secure encryption
Dan Boneh
Recap: the story so far
Confidentiality: semantic security against a CPA attack
• Encryption secure against eavesdropping only
Integrity:
• Existential unforgeability under a chosen message attack
• CBC-MAC, HMAC, PMAC, CW-MAC
Dan Boneh
Sample tampering attacks
TCP/IP: (highly abstracted)
a WWW
dat port = 80
packet
dest = 80 data
source machine
TCP/IP
stack Bob
port = 25
destination machine
Dan Boneh
Sample tampering attacks
IPsec: (highly abstracted)
a WWW
TCP/IP dat port = 80
packet stack
dest = 80 data
stuff
dest = 25 stuff
k
k
packets encrypted Bob
port = 25
using key k
Dan Boneh
Reading someone else’s data
Note: attacker obtains decryption of any ciphertext
beginning with “dest=25”
WWW
IV, dest = 80 data port = 80
Bob: data
(only IV is changed)
Dan Boneh
IV , dest = 80 data IV’ , dest = 25 data
IV’ = IV ⨁ (…25…)
IV’ = IV ⨁ (…80…)
IV’ = IV ⨁ (…80…) ⨁ (…25…)
It can’t be done
An attack using only network access
Remote terminal app.: each keystroke encrypted with CTR mode
TCP/IP packet
k
IP hdr TCP hdr T D
Dan Boneh
End of Segment
Dan Boneh
Online Cryptography Course Dan Boneh
Authenticated Encryption
Definitions
Dan Boneh
Goals
An authenticated encryption system (E,D) is a cipher where
As usual: E: K × M × N ⟶ C
but D: K × C × N ⟶ M ∪{⊥}
ciphertext
Security: the system must provide is rejected
• sem. security under a CPA attack, and
• ciphertext integrity:
attacker cannot create new ciphertexts that decrypt
properly Dan Boneh
Ciphertext integrity
Let (E,D) be a cipher with message space M.
m1 M m2 , …, mq
Chal. Adv.
kK c1 E(k,m1) c2 , …, cq
c
b
b=1 if D(k,c) ≠⊥ and c { c1 , … , cq }
b=0 otherwise
Dan Boneh
Implication 1: authenticity
Attacker cannot fool Bob into thinking a
message was sent from Alice
m1 , …, mq c
Alice Bob
ci = E(k, mi)
k k
Cannot create
valid c ∉ { c1, …, cq }
Authenticated encryption ⇒
Dan Boneh
End of Segment
Dan Boneh
Online Cryptography Course Dan Boneh
Authenticated Encryption
Chosen ciphertext
attacks
Dan Boneh
Example chosen ciphertext attacks
Adversary has ciphertext c that it wants to decrypt
• Often, adv. can fool server into decrypting certain ciphertexts (not c)
Dan Boneh
Chosen ciphertext security: definition
E = (E,D) cipher defined over (K,M,C). For b=0,1 define EXP(b):
m0 , m1 : |m0| = |m1|=1
Chal. Adv.
b c E(k, mb) = (IV, c[0])
kK
c’ = (IV⨁1, c[0])
b
D(k, c’) = mb⨁1
Dan Boneh
So what?
Authenticated encryption:
• ensures confidentiality against an active adversary
that can decrypt some ciphertexts
Limitations:
• does not prevent replay attacks
• does not account for side channels (timing)
Dan Boneh
End of Segment
Dan Boneh
Online Cryptography Course Dan Boneh
Authenticated Encryption
Constructions from
ciphers and MACs
Dan Boneh
… but first, some history
Authenticated Encryption (AE): introduced in 2000 [KY’00, BN’00]
Option 2: (IPsec)
E(kE, m) S(kI, c)
always msg m tag
correct
Option 3: (SSH) S(kI, m)
E(kE , m)
msg m tag
Dan Boneh
A.E. Theorems
Let (E,D) be CPA secure cipher and (S,V) secure MAC. Then:
m0, m1
Chal. Adv.
b c E(k, mb) = (c0, t) (c0, t)
kK
c’ = (c0 , t’ ) ≠ c
(c0, t’) b
D(k, c’) = mb
Dan Boneh
OCB: a direct construction from a PRP
More efficient authenticated encryption: one E() op. per block.
Dan Boneh
Performance: Crypto++ 5.6.0 [ Wei Dai ]
code Speed
Cipher size (MB/sec)
AES/GCM large **
108 AES/CTR 139
AES/CCM smaller 61 AES/CBC
109
AES/EAX smaller 61
AES/CMAC 109
AES/OCB 129* HMAC/SHA1 147
* extrapolated from Ted Kravitz’s results ** non-Intel machines
Dan Boneh
End of Segment
Dan Boneh
Online Cryptography Course Dan Boneh
Authenticated Encryption
Dan Boneh
The TLS Record Protocol (TLS 1.2)
Stateful encryption:
• Each side maintains two 64-bit counters: ctrb⇾s , ctrs⇾b
• Init. to 0 when session started. ctr++ for every record.
• Purpose: replay defense
Dan Boneh
TLS record: encryption (CBC AES-128, HMAC-SHA1)
No easy solution
Dan Boneh
802.11b WEP: how not to do it
802.11b WEP:
m CRC(m)
k PRG( IV ll k ) k
IV ciphetext
Dan Boneh
Active attacks
Fact: CRC is linear, i.e. ∀m,p: CRC( m ⨁ p) = CRC(m) ⨁ F(p)
Dan Boneh
Online Cryptography Course Dan Boneh
Authenticated Encryption
Dan Boneh
Recap
Authenticated encryption: CPA security + ciphertext integrity
• Confidentiality in presence of active adversary
• Prevents chosen-ciphertext attacks
⇒ Padding oracle:
attacker submits ciphertext and learns if
last bytes of plaintext are a valid pad
type ll ver ll len
Dan Boneh
Using a padding oracle (CBC encryption)
IV c[0] c[1]
⨁ g ⨁ 0x01
D(k,) D(k,)
= last-byte ⨁ g ⨁ 0x01
m[0] m[1]
if last-byte = g: valid pad
otherwise: invalid pad
Dan Boneh
Using a padding oracle (CBC encryption)
Then use a (02, 02) pad to learn the next byte and so on …
Dan Boneh
IMAP over TLS
Problem: TLS renegotiates key when an invalid record is received
Dan Boneh
Will this attack work if TLS used counter mode instead of CBC?
(i.e. use MAC-then-CTR )
Dan Boneh
Online Cryptography Course Dan Boneh
Authenticated Encryption
Attacking non-atomic
decryption
SSH Binary
This is CBC with IV is encrypted?CPA
Packet Protocol
CBC encryption (chained IV)
seq. packet pad MAC
payload pad
num. len. len. tag
SSH is encrypt and MAC?MAC is the MACed of the plaintext MAC computed
Decryption: over plaintext
Dan Boneh