Authenticated Encryption in SSH
Kenny Paterson Information Security Group @kennyog; www.isg.rhul.ac.uk/~kp
Authenticated Encryption in SSH Kenny Paterson Information - - PowerPoint PPT Presentation
Authenticated Encryption in SSH Kenny Paterson Information Security Group @kennyog; www.isg.rhul.ac.uk/~kp Overview (both lectures) Secure channels and their properties AEAD (revision) AEAD secure channel the [APW09] attack
Kenny Paterson Information Security Group @kennyog; www.isg.rhul.ac.uk/~kp
2
4 4
5 5
6 6
7 7
8 8
message-oriented functionality?
its own fragmentation and reassembly, or is there a maximum message length?
tear-down of channel, or is the channel tolerant of errors?
should the programmer handle them?
to the application? Or is it guaranteed by the underlying network transport?
symmetric encryption
9 9
11
m1 m2 Pictures by Giorgia Azzurra Marson
12
m1 m2 K K
KE Ch
13
c1 c2 K K
Ch
c1 = EncK(m1) m2 = DecK(c2) m1 = DecK(c1) c2 = EncK(m2)
14
c1 c2 K K
Ch
c1 = EncK(m1) m2 = DecK(c2) m1 = DecK(c1) c2 = EncK(m2) Enc Oracle learn b in {0,1} from c* = EncK(mb) IND-CPA (Goldwasser-Micali, 1984; Bellare-Desai-Jokipii-Rogaway, 1997).
15
c1 c2 K K
Ch
c1 = EncK(m1) m2 = DecK(c2) m1 = DecK(c1) c2 = EncK(m2) Enc Oracle learn b in {0,1} from c* = EncK(mb) IND-CPA (Goldwasser-Micali, 1984; Bellare-Desai-Jokipii-Rogaway, 1997). Dec Oracle IND-CCA (Naor-Yung, 1990; Rackoff-Simon, 1997).
16
c1 c2 K K
Ch
c1 = EncK(m1) m2 = DecK(c2) m1 = DecK(c1) c2 = EncK(m2) Is this what you wrote?
17
c1 c2 K K
Ch
c1 = EncK(m1) m2 = DecK(c2) m1 = DecK(c1) c2 = EncK(m2) Enc Oracle come up with valid c* Dec Oracle INT-CTXT (Bellare, Rogaway, 2000)
18
c1 c2 K K
Ch
c1 = EncK(m1) m2 = DecK(c2) m1 = DecK(c1) c2 = EncK(m2) Enc Oracle come up with valid c* for a new m* Dec Oracle INT-CTXT (Bellare, Rogaway, 2000) INT-PTXT (Bellare-Namprempre, 2000)
19
c1 c2 K K
Ch
c1 = EncK(m1) m2 = DecK(c2) m1 = DecK(c1) c2 = EncK(m2) Enc Oracle Dec Oracle INT-CTXT (Bellare, Rogaway, 2000) INT-PTXT (Bellare-Namprempre, 2000) Authenticated Encryption IND-CPA + INT-CTXT (èIND-CCA)
20
c1 c2 K K
Ch
c1 = EncK(AD1,m1) m2 = DecK(AD2,c2) m1 = DecK(AD1,c1) c2 = EncK(AD2,m2) Enc Oracle Dec Oracle Authenticated Encryption with Associated Data AE security for message m Integrity for associated data AD Strong binding between c and AD (Rogaway 2002)
Which came first?
21
c1 c2 K K
Ch
c1 = EncK(AD1,m1) m2 = DecK(AD2,c2) m3 = DecK(AD3,c3) m1 = DecK(AD1,c1) c2 = EncK(AD2,m2) c3 = EncK(AD3,m3) c3
22
c1 c2 K K
Ch
c1 = EncK(AD1,m1) m2 = DecK(AD2,c2) m3 = DecK(AD3,c3) m1 = DecK(AD1,c1) c2 = EncK(AD2,m2) c3 = EncK(AD3,m3) c3 Enc Oracle Dec Oracle learn b in {0,1} from c* = EncK(mb) IND-sfCCA (Bellare-Kohno-Namprempre, 2002)
23
c1 c2 K K
Ch
c1 = EncK(AD1,m1) m2 = DecK(AD2,c2) m3 = DecK(AD3,c3) m1 = DecK(AD1,c1) c2 = EncK(AD2,m2) c3 = EncK(AD3,m3) c3 Enc Oracle Dec Oracle learn b in {0,1} from c* = EncK(mb) or come up with valid/out of order c* IND-sfCCA (Bellare-Kohno-Namprempre, 2002) INT-sfCTXT
INT-sfPTXT (Brzuska-Smart-Warinschi-Watson, 2013)
Stateful AEAD
24
c1 c2 K K
Ch
c1 = EncK(N1,AD1,m1) m2 = DecK(N2,AD2,c2) m1 = DecK(N1,AD1,c1) c2 = EncK(N2,AD2,m2) Enc Oracle Dec Oracle Nonce-based Authenticated Encryption with Associated Data As per AEAD, but with additional input N to Enc and Dec algorithms Adversary may arbitrarily specify N, but “no repeats” rule Enc and Dec can now be stateless and deterministic (Rogaway 2004)
25
26
28
29
m1 m2
Ch
30
number.
31
Encrypt PRF-MAC
Payload Ciphertext MAC tag Sequence Number
4
Packet Length
4
Pad Len 1 Padding ≥4
32
CBC and recommends AES- CBC.
CBC mode:
– IV for current packet is the last
ciphertext block from the previous packet.
– Effectively creates a single
stream of data from multiple SSH packets.
Ci-1 Ci Pi-1 Pi
dK dK
Pi-1 Pi Ci-1 Ci
eK eK
33
a stream cipher.
RFC 4344.
protocol.
CBC case.
CTR with 128, 192 and 256-bit keys, and 3DES-CTR.
Ci
eK
Pi ctr+i Pi
eK
Ci ctr+i
plaintext and because of chosen plaintext requirement.
34
Encrypt PRF-MAC
Payload Ciphertext MAC tag Sequence Number
4
Packet Length
4
Pad Len 1 Padding ≥4
35
Encrypt PRF-MAC
Payload Ciphertext MAC tag Sequence Number
4
Packet Length
4
Pad Len 1 Padding ≥4
36 IV Ci
*
P0
’
dK
as the packet length field for the new packet.
P0’ = IV ⊕ dK(Ci*) where IV is known.
Target ciphertext block from stream Length field
37 IV Ci
*
P0
’
dK
R R P2’
dK dK
P1’
– One block at a time, waiting to see what happens at the server when each new block is processed – This is possible because SSH runs over TCP and tries to do online processing of incoming blocks
38 IV Ci
*
P0
’
dK
the MAC tag
– The MAC check will fail with overwhelming probability – Consequently the connection is terminated (with an error message)
MAC?
R R P2’
dK dK
P1’
MAC tag
39 IV Ci
*
P0
’
dK
Ci-1
*
Ci
*
Pi
*
dK
’, the attacker can now recover
*:
* = Ci-1 * ⊕ dK(Ci *) = Ci-1 * ⊕ IV ⊕ P0 ’
40
41
LF +4 mod BL = 0.
42
2-18 (for BL= 16) and requires injection of at most 218 bytes of data. 43
44
0.53.
were subsequently added to OpenSSH.
45
46
ciphertexts.
possible.
plaintext is meant to be, and act on it before performing any authentication.
47
and server preferences.
49
50
Mostly OpenSSH and dropbear; others less than 5%.
51
Dropbear at 56-58%. 886k older then version 0.53, so vulnerable to variant of 2009 CBC- mode attack!
52
OpenSSH at 37-39%. 130-166k older then version 5.2 and prefer CBC mode, so vulnerable to 2009 attack!
range dropped from 2M+ devices running Dropbear (Feb 2016) to 83k (May 2016).
2009 (current version is 7.2).
53
54 OpenSSH preferred algorithms
55
Dropbear preferred algorithms
until 218 bytes have arrived, then check the MAC.
then wait until 218 bytes have arrived, then check the MAC.
57
*.
58
evaluations.
block.
attack for random, explicit IV version.) 59
timing information.
30 bits of plaintext from target block.
second MAC on 218 – LF bytes instead of on all 218 bytes.
HMAC.
to eliminate this class of attack.
60
61
its decryption in true position: 63 IV Ci
*
P0
’
dK
Ci-1
*
Ci
*
Pi
*
dK
* in the stream results in unrelated plaintext:
P0
’ = Ci * ⊕ eK(ctr0) = Pi * ⊕ eK(ctri) ⊕ eK(ctr0)
64
failures, etc.
65
66
GCM, and ChaCha20-Poly1305 in OpenSSH.
adversary.
E&M code, the MAC is computed once the ciphertext has arrived but is not compared to received MAC until after decryption.
attacker.
67
68
Payload MAC tag SQN
4
Packet Length
4
Pad Len 1 Padding ≥4
C1 C2
K1
IV = SQN||064
ChaCha20 ChaCha20 K2
IV = SQN||0631
ChaCha20 K2
IV = SQN||0630
0256 Kpoly Poly1305
ChaCha20(K2,IV = SQN||0630, M=0256).
the rest stops attacks.
69
reverse).
71
72