Cryptanalysis of the counter mode of operation Ferdinand Sibleyras - - PowerPoint PPT Presentation

cryptanalysis of the counter mode of operation
SMART_READER_LITE
LIVE PREVIEW

Cryptanalysis of the counter mode of operation Ferdinand Sibleyras - - PowerPoint PPT Presentation

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion Cryptanalysis of the counter mode of operation Ferdinand Sibleyras joint work with Gatan Leurent Inria, quipe SECRET April 10, 2018 1 / 29 Introduction


slide-1
SLIDE 1

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Cryptanalysis of the counter mode of

  • peration

Ferdinand Sibleyras joint work with Gaëtan Leurent

Inria, équipe SECRET

April 10, 2018

1 / 29

slide-2
SLIDE 2

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Introduction

  • Cryptography: Alice encrypts then sends messages to Bob.
  • Symmetric: Alice and Bob share the same key.
  • Public channel: Eve (attacker) can see and/or manipulate

what is being sent. ...11001101011... Alice Eve Bob

2 / 29

slide-3
SLIDE 3

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Introduction

Block Cipher Ek : {0, 1}n → {0, 1}n A family of permutations indexed by a key (AES, 3DES, ...) where n is the bit size of the permutation or block’s size.

3 / 29

slide-4
SLIDE 4

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Introduction

Block Cipher Ek : {0, 1}n → {0, 1}n A family of permutations indexed by a key (AES, 3DES, ...) where n is the bit size of the permutation or block’s size. Mode of operation Describes how to use a block cipher along with a plaintext message of arbitrary length to achieve some concrete cryptographic goals.

3 / 29

slide-5
SLIDE 5

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Introduction

Modes are classified according to their goals:

  • There are encryption modes (CBC, CTR, ...).

They aim at hiding the plaintext. → Plaintext recovery attacks.

4 / 29

slide-6
SLIDE 6

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Introduction

Modes are classified according to their goals:

  • There are encryption modes (CBC, CTR, ...).

They aim at hiding the plaintext. → Plaintext recovery attacks.

  • There are authentication modes (GMAC, ...).

They aim at authenticating the plaintext. → Forgery attacks.

4 / 29

slide-7
SLIDE 7

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Introduction

Modes are classified according to their goals:

  • There are encryption modes (CBC, CTR, ...).

They aim at hiding the plaintext. → Plaintext recovery attacks.

  • There are authentication modes (GMAC, ...).

They aim at authenticating the plaintext. → Forgery attacks.

  • There are authenticated encryption modes (GCM, ...).

They aim at both authenticating and hiding the plaintext.

4 / 29

slide-8
SLIDE 8

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

The counter mode (CTR)

IV0 Ek m0 c0 m1 c1 Ek IV1 m2 c2 Ek IV2 m3 c3 Ek IV3 mi : The plaintext. Ek : The block cipher. ci : The ciphertext. IV : The Initialisation Value. ci = Ek(IVi) ⊕ mi

5 / 29

slide-9
SLIDE 9

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

The counter mode (CTR)

IV0 Ek m0 c0 m1 c1 Ek IV1 m2 c2 Ek IV2 m3 c3 Ek IV3 mi : The plaintext. Ek : The block cipher. ci : The ciphertext. IV : The Initialisation Value. ci = Ek(IVi) ⊕ mi Akin to a stream cipher: keystream XORed with the plaintext.

5 / 29

slide-10
SLIDE 10

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

The counter mode (CTR)

IV0 Ek m0 c0 m1 c1 Ek IV1 m2 c2 Ek IV2 m3 c3 Ek IV3 mi : The plaintext. Ek : The block cipher. ci : The ciphertext. IV : The Initialisation Value. ci = Ek(IVi) ⊕ mi Akin to a stream cipher: keystream XORed with the plaintext. Inputs IVi to the block cipher never repeat.

5 / 29

slide-11
SLIDE 11

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

The counter mode (CTR)

Let Ki = Ek(IVi) the ith block of keystream.

  • If Ek is a good Pseudo-Random Function (PRF) then all Ki

are random and this is a one-time-pad.

  • A block cipher is a Pseudo-Random Permutation (PRP)

therefore Ki are all distinct: Ki = Kj ∀i = j.

6 / 29

slide-12
SLIDE 12

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

The counter mode (CTR)

Let Ki = Ek(IVi) the ith block of keystream.

  • If Ek is a good Pseudo-Random Function (PRF) then all Ki

are random and this is a one-time-pad.

  • A block cipher is a Pseudo-Random Permutation (PRP)

therefore Ki are all distinct: Ki = Kj ∀i = j. Security proof (σ the number of blocks) AdvCPA

CTR-Ek(σ) ≤ AdvPRF Ek (σ) ≤ AdvPRP Ek (σ) + σ2/2n+1

Distinguishing attack After σ ≃ 2n/2 encrypted blocks we expect a collision on the Ki with high probability in the case of a random ciphertext. That is the birthday bound coming from the birthday paradox.

6 / 29

slide-13
SLIDE 13

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

CBC and CTR

Both modes are:

  • widely deployed
  • proven secure up to

birthday bound (2n/2)

  • allowing attacks when

nearing the bound CBC mode m0 Ek IV c0 m1 Ek c1 m2 Ek c2

7 / 29

slide-14
SLIDE 14

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

CBC and CTR

Both modes are:

  • widely deployed
  • proven secure up to

birthday bound (2n/2)

  • allowing attacks when

nearing the bound CBC mode m0 Ek IV c0 m1 Ek c1 m2 Ek c2 Folklore assumptions [Ferguson, Schneier, Kohno] CTR leaks very little data. [...] It would be reasonable to limit the cipher mode to 260 blocks, which allows you to encrypt 264 bytes but restricts the leakage to a small fraction of a bit. When using CBC mode you should be a bit more restrictive. [...] We suggest limiting CBC encryption to 232 blocks or so.

7 / 29

slide-15
SLIDE 15

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

The counter mode (CTR)

From a distinguishing attack to a plaintext recovery attack ?

  • If we know mi, we recover Ki = ci ⊕ mi.

8 / 29

slide-16
SLIDE 16

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

The counter mode (CTR)

From a distinguishing attack to a plaintext recovery attack ?

  • If we know mi, we recover Ki = ci ⊕ mi.
  • We can observe repeated encryptions of a secret S that is

cj = Kj ⊕ S for many different j.

8 / 29

slide-17
SLIDE 17

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

The counter mode (CTR)

From a distinguishing attack to a plaintext recovery attack ?

  • If we know mi, we recover Ki = ci ⊕ mi.
  • We can observe repeated encryptions of a secret S that is

cj = Kj ⊕ S for many different j.

  • The distinguishing attack uses Ki ⊕ Kj = 0 which implies

Ki ⊕ cj = S ∀i = j.

8 / 29

slide-18
SLIDE 18

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

The counter mode (CTR)

From a distinguishing attack to a plaintext recovery attack ?

  • If we know mi, we recover Ki = ci ⊕ mi.
  • We can observe repeated encryptions of a secret S that is

cj = Kj ⊕ S for many different j.

  • The distinguishing attack uses Ki ⊕ Kj = 0 which implies

Ki ⊕ cj = S ∀i = j. Main Idea Collect many keystream blocks Ki and encryptions of secret block cj = Kj ⊕ S; then look for a value s such that Ki ⊕ cj = s ∀i = j.

8 / 29

slide-19
SLIDE 19

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Missing difference problem

The missing difference problem

  • Given A and B, and a hint S three sets of n-bit words
  • Find S ∈ S such that:

∀(a, b) ∈ A × B, S = a ⊕ b .

9 / 29

slide-20
SLIDE 20

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Missing difference problem

Main Idea Collect many keystream blocks Ki ∈ A and encryptions of secret block cj = Kj ⊕ S ∈ B; then look for a value s ∈ S such that ∀(a, b) ∈ A × B, s = a ⊕ b . The missing difference problem

  • Given A and B, and a hint S three sets of n-bit words
  • Find S ∈ S such that:

∀(a, b) ∈ A × B, S = a ⊕ b .

9 / 29

slide-21
SLIDE 21

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Simple Sieving Algorithm

[McGrew, FSE’13] a1 b1 a2 b2 a3 b3 a4 b4 a5 b5 a6 b6 a7 b7

2n

S × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × Compute all ai ⊕ bj, remove results from a sieve S. Analysis: case |S| = 2n via coupon collector problem

  • To exclude 2n candidates of S, we need n · 2n values ai ⊕ bj
  • Lists A and B of size √n · 2n/2. Complexity: ˜

O(2n)

10 / 29

slide-22
SLIDE 22

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Simple Sieving Algorithm

[McGrew, FSE’13] a1 b1 a2 b2 a3 b3 a4 b4 a5 b5 a6 b6 a7 b7

2n

S × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × × Compute all ai ⊕ bj, remove results from a sieve S. Analysis: case |S| = 2

  • To exclude 1 candidate of S, we need 2n values ai ⊕ bj
  • Lists A and B of size 2n/2. Complexity: ˜

O(2n)

10 / 29

slide-23
SLIDE 23

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Searching Algorithm

[McGrew, FSE’13] a1 b1 a2 b2 a3 b3 a4 b4 a5 b5 a6 b6 a7 b7 ? ⊕ s

  • Make a guess and verify.

Try Guess (s) for a in A do if (s ⊕ a) ∈ B then return 0 return 1

11 / 29

slide-24
SLIDE 24

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Searching Algorithm

[McGrew, FSE’13] a1 b1 a2 b2 a3 b3 a4 b4 a5 b5 a6 b6 a7 b7 ? ⊕ s

  • Make a guess and verify.

Try Guess (s) for a in A do if (s ⊕ a) ∈ B then return 0 return 1

11 / 29

slide-25
SLIDE 25

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Searching Algorithm

[McGrew, FSE’13] a1 b1 a2 b2 a3 b3 a4 b4 a5 b5 a6 b6 a7 b7 ? ⊕ s

  • Make a guess and verify.

Try Guess (s) for a in A do if (s ⊕ a) ∈ B then return 0 return 1

11 / 29

slide-26
SLIDE 26

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Searching Algorithm

[McGrew, FSE’13] a1 b1 a2 b2 a3 b3 a4 b4 a5 b5 a6 b6 a7 b7 ? ⊕ s

  • Make a guess and verify.

Try Guess (s) for a in A do if (s ⊕ a) ∈ B then return 0 return 1

11 / 29

slide-27
SLIDE 27

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Searching Algorithm

[McGrew, FSE’13] a1 b1 a2 b2 a3 b3 a4 b4 a5 b5 a6 b6 a7 b7 ? ⊕ s

  • Make a guess and verify.

Try Guess (s) for a in A do if (s ⊕ a) ∈ B then return 0 return 1

11 / 29

slide-28
SLIDE 28

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Searching Algorithm

[McGrew, FSE’13] a1 b1 a2 b2 a3 b3 a4 b4 a5 b5 a6 b6 a7 b7 ? ⊕ s

  • Make a guess and verify.

Try Guess (s) for a in A do if (s ⊕ a) ∈ B then return 0 return 1

11 / 29

slide-29
SLIDE 29

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Searching Algorithm

[McGrew, FSE’13] a1 b1 a2 b2 a3 b3 a4 b4 a5 b5 a6 b6 a7 b7 ? ⊕ s

  • Make a guess and verify.
  • Complexity ˜

O(2n/2 |S|) with unbalanced A, B. Try Guess (s) for a in A do if (s ⊕ a) ∈ B then return 0 return 1

11 / 29

slide-30
SLIDE 30

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Known-prefix Sieving

a1 b1 a2 b2 a3 b3 a4 b4 a5 b5 a6 b6 a7 b7 2 2 3 4 5 1 2 2 4 5 6

2n 2n−z

S × × × × × × × ×

  • Assume S starts with z zero bits (more generally, linear

subspace with dimS = n − z)

  • Sort lists, consider ai’s and bj’s with matching z-bit prefix
  • Complexity: ˜

O(2n/2 + 2dimS)

  • Looking for collision + needed number of collisions
  • Complexity: ˜

O(2n/2) when dimS ≤ n/2

12 / 29

slide-31
SLIDE 31

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Simulation

We challenge the false assumptions we made like independence of the {a ⊕ b}. Approximations seem good enough. Ran simulations with n = 64 bits and z = n/2 = 32 zeros.

  • Each round we compare two lists of 2n/2 elements.
  • Each round we expect 2n/2 partial collisions.
  • Coupon collector predicts n/2 · ln(2) · 2n/2 partial collisions to

recover S, that is 23 rounds on expectation.

  • Simulation gives an idea of what is hidden in the O notations.

Consistent speed of leaking In every runs, after 16 rounds the sieve was left between 419 and 560 candidates of S only.

13 / 29

slide-32
SLIDE 32

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Simulation

20 22 24 26 28 30 0.2 0.4 0.6 0.8 1 Number of iterations Pr(success) Theoretical lower bound 3700 simulations.

Figure: Probability of success of the known prefix sieving knowing 232 encryptions of a 32-bit secret against the number of chunks of 232 keystream blocks of size n = 64 bits used.

14 / 29

slide-33
SLIDE 33

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Fast Convolution Sieving

a1 b1 a2 b2 a3 b3 a4 b4 a5 b5 a6 b6 a7 b7

2n

S × × × × × × × × × × × × × × × × × × × 19 × × × × × × × × × × × × × × × 15 × × × × × × × × × × × × × × × × × 17 × × × × × × × × × × × 11 × × × × × × × × × × × × × × × × × 17 × × × × × × × × × × × 11 × × × × × × × × × × × × × × × 15 × × × × × × × × × × × × 12 × × × × × × × × × × × × 12 × × × × × × × × × × × × × × 14

  • Instead of computing full sieve, use buckets (ie. truncate)
  • With enough data, missing difference has smallest bucket with

high probability

  • Eg. 22n/3 queries, sieving with 22n/3 buckets of 2n/3 elements

15 / 29

slide-34
SLIDE 34

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Computing the sieve

2n

A

2n

B × 1 × 1 × 1 × × × 3 × 1 × × 2 × × 2 × × 2 × × 2 × × 2 × × 2 × × 2

2n

S × × × × × × × × × × × × × × × × × × × 19 × × × × × × × × × × × × × × × 15 × × × × × × × × × × × × × × × × × 17 × × × × × × × × × × × 11 × × × × × × × × × × × × × × × × × 17 × × × × × × × × × × × 11 × × × × × × × × × × × × × × × 15 × × × × × × × × × × × × 12 × × × × × × × × × × × × 12 × × × × × × × × × × × × × × 14

  • Count buckets for A and B
  • CX [i] =
  • x ∈ X
  • T(x) = i
  • 16 / 29
slide-35
SLIDE 35

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Computing the sieve

  • Count buckets for A and B
  • CX [i] =
  • x ∈ X
  • T(x) = i
  • CS[i] = |{(a, b) ∈ A × B | T(a ⊕ b) = i}|

=

  • a∈A

|{b ∈ B | T(a ⊕ b) = i}| =

  • a∈A

CB[i ⊕ T(a)] =

  • j∈{0,1}n−t

CA[j] · CB[i ⊕ j]

16 / 29

slide-36
SLIDE 36

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Computing the sieve

  • Count buckets for A and B
  • CX [i] =
  • x ∈ X
  • T(x) = i
  • CS[i] = |{(a, b) ∈ A × B | T(a ⊕ b) = i}|

=

  • a∈A

|{b ∈ B | T(a ⊕ b) = i}| =

  • a∈A

CB[i ⊕ T(a)] =

  • j∈{0,1}n−t

CA[j] · CB[i ⊕ j]

  • Discrete convolution can be computed efficiently with the Fast

Walsh-Hadamard transform!

  • Complexity: ˜

O(22n/3) for arbitrary S

16 / 29

slide-37
SLIDE 37

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Then we hope that S is in the bucket with lowest counter: T(S) ? = argmin CS[i] And we can finish with Known-prefix Sieving to recover the rest. In fact, we can check several candidates and simply hope it is in

  • ne of buckets with low counter. The more data, the less bucket

candidates we need to try.

17 / 29

slide-38
SLIDE 38

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Simulation

Figure: Results for √n22n/3 data; counting over 2n/3 bits.

20 22 24 26 28 210 0.4 0.6 0.8 1 Number of bucket candidates Pr(success) n = 12 n = 24 n = 48

18 / 29

slide-39
SLIDE 39

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Missing difference problem algorithms

Algorithms for the missing difference problem Simple Sieving Complexity ˜ O(2n) [McGrew] Searching Complexity ˜ O(2n/2 |S|) [McGrew] Known-prefix Sieving Complexity ˜ O(2n/2 + 2dimS) Fast Convolution Sieving Complexity ˜ O(22n/3)

19 / 29

slide-40
SLIDE 40

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Missing difference problem algorithms

Algorithms for the missing difference problem Simple Sieving Complexity ˜ O(2n) [McGrew] Searching Complexity ˜ O(2n/2 |S|) [McGrew] Known-prefix Sieving Complexity ˜ O(2n/2 + 2dimS) Fast Convolution Sieving Complexity ˜ O(22n/3)

  • Improved algorithm if S is a linear subspace
  • In particular still near optimal when dimS = n/2

19 / 29

slide-41
SLIDE 41

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Missing difference problem algorithms

Algorithms for the missing difference problem Simple Sieving Complexity ˜ O(2n) [McGrew] Searching Complexity ˜ O(2n/2 |S|) [McGrew] Known-prefix Sieving Complexity ˜ O(2n/2 + 2dimS) Fast Convolution Sieving Complexity ˜ O(22n/3)

  • Improved algorithm if S is a linear subspace
  • In particular still near optimal when dimS = n/2
  • Improved algorithm for arbitrary S at the cost of data
  • First algorithm with complexity below 2n in that case

19 / 29

slide-42
SLIDE 42

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Back to Cryptanalysis

New Tools, New Attacks Known-prefix → plaintext recovery on CTR mode Fast Convolution → forgery on GMAC and Poly1305 First, let’s look at a practical setting that gives enough power to the attacker to fully describe an attack.

20 / 29

slide-43
SLIDE 43

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

BEAST Attack Setting

[Duong & Rizzo 2011]

User

https://

Public WiFi Attacker Injects JS Captures encrypted traffic

  • Attacker has access to the network

(eg. public WiFi)

  • 1. Attacker uses JS to generate traffic
  • Tricks victim to malicious site
  • JS makes cross-origin requests
  • 2. Attacker captures encrypted data
  • Chosen plaintext attack
  • Chosen-Prefix Secret-Suffix model

M → E(MS) [Hoang &al., Crypto’15]

21 / 29

slide-44
SLIDE 44

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Application to CTR (CPSS queries)

  • Plaintext recovery using the known-prefix sieving algorithm
  • Two kind of queries; half-block and full-block headers:

Q1 H1 S1 S2 S3 S4 Q2 H1 H2 S1 S2 S3 S4

  • 1. Recover S1 using the first block of each query:

A = {E(H1H2)}

  • → Missing difference:

0(S1 ⊕ H2). B = {E(H1S1)}

22 / 29

slide-45
SLIDE 45

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Application to CTR (CPSS queries)

  • Plaintext recovery using the known-prefix sieving algorithm
  • Two kind of queries; half-block and full-block headers:

Q1 H1 S1 S2 S3 S4 Q2 H1 H2 S1 S2 S3 S4

  • 1. Recover S1 using the first block of each query:

A = {E(H1H2)}

  • → Missing difference:

0(S1 ⊕ H2). B = {E(H1S1)}

  • 2. When S1 is known, recover S2, with Q2 queries:

A = {E(H1H2)}

  • → Missing difference: (S1 ⊕ H1)(S2 ⊕ H2).

B = {E(S1S2)}

22 / 29

slide-46
SLIDE 46

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Application to CTR (CPSS queries)

  • Plaintext recovery using the known-prefix sieving algorithm
  • Two kind of queries; half-block and full-block headers:

Q1 H1 S1 S2 S3 S4 Q2 H1 H2 S1 S2 S3 S4

  • 1. Recover S1 using the first block of each query:

A = {E(H1H2)}

  • → Missing difference:

0(S1 ⊕ H2). B = {E(H1S1)}

  • 2. When S1 is known, recover S2, with Q2 queries:

A = {E(H1H2)}

  • → Missing difference: (S1 ⊕ H1)(S2 ⊕ H2).

B = {E(S1S2)}

  • 3. When S2 is known, recover S3:

A = {E(H1H2)}

  • → Missing difference: (S2 ⊕ H1)(S3 ⊕ H2).

B = {E(S2S3)}

  • 4. . . .

22 / 29

slide-47
SLIDE 47

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Application to CTR (CPSS queries)

Remarks on this attack:

  • We perform the Known-prefix sieving twice per block of secret.
  • We reuse queries so we don’t need additional queries to

uncover additional blocks of secret.

  • Once you gathered enough queries to recover S1 and S2 it is

probably enough to recover all of the secret.

23 / 29

slide-48
SLIDE 48

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Application to CTR (CPSS queries)

Remarks on this attack:

  • We perform the Known-prefix sieving twice per block of secret.
  • We reuse queries so we don’t need additional queries to

uncover additional blocks of secret.

  • Once you gathered enough queries to recover S1 and S2 it is

probably enough to recover all of the secret.

Full Asymptotic Complexity Queries O(√n · 2n/2) Memory O(√n · 2n/2) Time O(n · 2n/2)

23 / 29

slide-49
SLIDE 49

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Wegman-Carter Authentication Modes

  • Wegman-Carter: build a MAC from a universal hash function

and a PRF WC(N, M) = Hk1(M) ⊕ Fk2(N). AdvMAC

WC[H,F] ≤ AdvPRF F

+ ε + 2−n

  • Wegman-Carter-Shoup: use a block cipher as a PRF

WCS(N, M) = Hk1(M) ⊕ Ek2(N), Example: Polynomial-based hashing (GMAC, Poly1305-AES) m1 ⊙H m2 ⊙H len(M) ⊙H Ek N τ

24 / 29

slide-50
SLIDE 50

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Application to GMAC

Authentication of one block A of authenticated data in a given Galois field: MAC(N, A) = A · H2 ⊕ H ⊕ Ek(N) with N a never repeating nonce, H the hash key.

25 / 29

slide-51
SLIDE 51

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Application to GMAC

Authentication of one block A of authenticated data in a given Galois field: MAC(N, A) = A · H2 ⊕ H ⊕ Ek(N) with N a never repeating nonce, H the hash key. Collect many signatures for A and A′, then ∀i = j: MAC(i, A) ⊕ MAC(j, A′) = A · H2 ⊕ H ⊕ A′ · H2 ⊕ H = (A ⊕ A′) · H2

25 / 29

slide-52
SLIDE 52

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Application to GMAC

Authentication of one block A of authenticated data in a given Galois field: MAC(N, A) = A · H2 ⊕ H ⊕ Ek(N) with N a never repeating nonce, H the hash key. Collect many signatures for A and A′, then ∀i = j: MAC(i, A) ⊕ MAC(j, A′) = A · H2 ⊕ H ⊕ A′ · H2 ⊕ H = (A ⊕ A′) · H2

  • Solve the missing difference problem.
  • Invert A ⊕ A′, get H2.
  • Find the square root, get H, the hash key!

25 / 29

slide-53
SLIDE 53

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Key recovery as a missing difference problem

  • Fix two messages M = M′, capture MACs
  • ai = MAC(i, M ) = HK1(M ) ⊕ Ki
  • bj = MAC(j, M′) = HK1(M′) ⊕ Kj
  • ai ⊕ bj = HK1(M) ⊕ HK1(M′)
  • For polynomial hashing, easy to recover universal hash key

from HK1(M) ⊕ HK1(M′)

26 / 29

slide-54
SLIDE 54

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Key recovery as a missing difference problem

  • Fix two messages M = M′, capture MACs
  • ai = MAC(i, M ) = HK1(M ) ⊕ Ki
  • bj = MAC(j, M′) = HK1(M′) ⊕ Kj
  • ai ⊕ bj = HK1(M) ⊕ HK1(M′)
  • For polynomial hashing, easy to recover universal hash key

from HK1(M) ⊕ HK1(M′)

  • Sieving algorithm recovers H(M) ⊕ H(M′) with

˜ O(2n/2) queries and ˜ O(2n) computations

  • Independently done in another Eurocrypt paper!

Optimal Forgeries Against Polynomial-Based MACs and GCM Atul Luykx, Bart Preneel [Eurocrypt ’18]

26 / 29

slide-55
SLIDE 55

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Key recovery as a missing difference problem

  • Fix two messages M = M′, capture MACs
  • ai = MAC(i, M ) = HK1(M ) ⊕ Ki
  • bj = MAC(j, M′) = HK1(M′) ⊕ Kj
  • ai ⊕ bj = HK1(M) ⊕ HK1(M′)
  • For polynomial hashing, easy to recover universal hash key

from HK1(M) ⊕ HK1(M′)

  • Sieving algorithm recovers H(M) ⊕ H(M′) with

˜ O(2n/2) queries and ˜ O(2n) computations

  • Independently done in another Eurocrypt paper!

Optimal Forgeries Against Polynomial-Based MACs and GCM Atul Luykx, Bart Preneel [Eurocrypt ’18]

  • Fast convolution sieving recovers H(M) ⊕ H(M′) with

˜ O(22n/3) queries and computations

  • First universal forgery attack with less than 2n operations

26 / 29

slide-56
SLIDE 56

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Impacts

How practical can be the plaintext recovery attack on CTR ?

  • Mostly used with AES, famous 128-bit block cipher, as part of
  • GCM. 90% of Firefox HTTPS traffic uses AES-GCM.
  • Requires 128 × 264 bits = 256 exbibytes over one session
  • 2016 global IP traffic is 82.3 exbibytes per month [Cisco]

27 / 29

slide-57
SLIDE 57

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Impacts

How practical can be the plaintext recovery attack on CTR ?

  • Mostly used with AES, famous 128-bit block cipher, as part of
  • GCM. 90% of Firefox HTTPS traffic uses AES-GCM.
  • Requires 128 × 264 bits = 256 exbibytes over one session
  • 2016 global IP traffic is 82.3 exbibytes per month [Cisco]
  • SSHv2 implements CTR with 3DES, a 64-bit block cipher.
  • Requires 64 × 232 bits = 32 gibibytes
  • Quickly attainable with modern internet speed

27 / 29

slide-58
SLIDE 58

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Impacts

How practical can be the plaintext recovery attack on CTR ?

  • Mostly used with AES, famous 128-bit block cipher, as part of
  • GCM. 90% of Firefox HTTPS traffic uses AES-GCM.
  • Requires 128 × 264 bits = 256 exbibytes over one session
  • 2016 global IP traffic is 82.3 exbibytes per month [Cisco]
  • SSHv2 implements CTR with 3DES, a 64-bit block cipher.
  • Requires 64 × 232 bits = 32 gibibytes
  • Quickly attainable with modern internet speed

Sweet32 attack Attack in the BEAST setting with birthday bound complexity already shown to be a threat over the web in previous work by Bhargavan and Leurent. This is the Sweet32 attack on CBC mode, more commonly used with 64-bit block ciphers.

27 / 29

slide-59
SLIDE 59

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Counter-measures

  • 1. Use AES, or any good 128-bit block cipher.
  • Make n big enough so that 2n/2 is impractical.
  • Most obvious choice for most new implementations.

28 / 29

slide-60
SLIDE 60

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Counter-measures

  • 1. Use AES, or any good 128-bit block cipher.
  • Make n big enough so that 2n/2 is impractical.
  • Most obvious choice for most new implementations.
  • 2. Forget block ciphers, use a PRF.
  • CTR is perfectly secure as long as we use a good PRF.
  • Dedicated PRF are rare but many solutions exist (XoP).

28 / 29

slide-61
SLIDE 61

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Counter-measures

  • 1. Use AES, or any good 128-bit block cipher.
  • Make n big enough so that 2n/2 is impractical.
  • Most obvious choice for most new implementations.
  • 2. Forget block ciphers, use a PRF.
  • CTR is perfectly secure as long as we use a good PRF.
  • Dedicated PRF are rare but many solutions exist (XoP).
  • 3. Forget CTR, use advanced Beyond Birthday Bound schemes.
  • They have a proof with better security bounds.
  • CENC is a BBB scheme derived from CTR.

[Iwata, FSE’06]

28 / 29

slide-62
SLIDE 62

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Counter-measures

  • 1. Use AES, or any good 128-bit block cipher.
  • Make n big enough so that 2n/2 is impractical.
  • Most obvious choice for most new implementations.
  • 2. Forget block ciphers, use a PRF.
  • CTR is perfectly secure as long as we use a good PRF.
  • Dedicated PRF are rare but many solutions exist (XoP).
  • 3. Forget CTR, use advanced Beyond Birthday Bound schemes.
  • They have a proof with better security bounds.
  • CENC is a BBB scheme derived from CTR.

[Iwata, FSE’06]

  • 4. Simply rekey frequently.
  • Rekeying way before 2n/2 blocks efficiently prevents the attack.
  • Maybe the easiest hotfix.

28 / 29

slide-63
SLIDE 63

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Conclusion

Case Previous This work Improved attacks S affine subspace CTR

  • f dim n/2 .

˜ O(23n/4) ˜ O(2n/2) plaintext recovery. No prior info on S. GMAC, Poly1305

  • ie. |S| = 2n .

˜ O(2n) ˜ O(22n/3) universal forgery.

29 / 29

slide-64
SLIDE 64

Introduction The counter mode Missing difference problem Cryptanalysis Conclusion

Conclusion

Case Previous This work Improved attacks S affine subspace CTR

  • f dim n/2 .

˜ O(23n/4) ˜ O(2n/2) plaintext recovery. No prior info on S. GMAC, Poly1305

  • ie. |S| = 2n .

˜ O(2n) ˜ O(22n/3) universal forgery. Especially when n = 64 bits, main take away :

  • CTR mode not more secure than CBC (Sweet32).
  • Frequent rekeying away from birthday bound will prevent these

attacks.

29 / 29

slide-65
SLIDE 65

Supporting Slides

Fast Walsh-Hadamard transform

We need an efficient algorithm to compute the multiplication of a Hadamard matrix Hm by a vector of size 2m in O(m · 2m). H = 1 1 1 −1

  • Hm =

1 2m/2 H⊗m That is the fast Walsh-Hadamard transform (FWHT), akin to a fast Fourier transform.

1 / 6

slide-66
SLIDE 66

Supporting Slides

Fast XOR-counting

CK FWHT CE FWHT * FWHT CX

Figure: Fast XOR-counting algorithm

2 / 6

slide-67
SLIDE 67

Supporting Slides

Fast XOR-counting

CK FWHT CE FWHT * FWHT CX

Figure: Fast XOR-counting algorithm

Note that FWHT−1 = FWHT. We hope that : S2n/3

?

= argmin

i

CX[i]

2 / 6

slide-68
SLIDE 68

Supporting Slides

Fast XOR-counting

For an Ω(1) probability of success on the first trial assuming independence of the counters (/!\ False as CX = |K × E| .) : Complexity O(√n · 22n/3) queries O(n · 22n/3) + O(n√n · 2n/2) bits memory (counters + sieving) O(n · 22n/3) + O(n√n · 2n/2) computations (FWHT + sieving)

3 / 6

slide-69
SLIDE 69

Supporting Slides

(a) Results for lists size of 3 · 22n/3

20 22 24 26 28 210 0.2 0.4 0.6 0.8 1 Number of key candidates Pr(success) n = 12 bits n = 24 bits

(b) Results for n = 24 bits

20 22 24 26 28 210 0.2 0.4 0.6 0.8 1 Number of key candidates Pr(success) ≃ 4.90 · 22n/3 data 3 · 22n/3 data

4 / 6

slide-70
SLIDE 70

Supporting Slides

(a) Results for n = 32 bits; √n22n/3 ≃ 5.66 · 22n/3 data

20 22 24 26 28 210 0.4 0.6 0.8 1 Number of key candidates Pr(success) counting over 22 bits counting over 21 bits

(b) Results for √n22n/3 data; counting

  • ver 2n/3 bits

20 22 24 26 28 210 0.4 0.6 0.8 1 Number of key candidates Pr(success) n = 12 n = 24 n = 48

5 / 6

slide-71
SLIDE 71

Supporting Slides

Poly1305

For a key r, some nonce N and message M of length q the Poly1305’s MAC is defined as: T(M, N) = ((c1rq+c2rq−1+...+cqr) mod 2130−5)+Ek(N) mod 2128

6 / 6

slide-72
SLIDE 72

Supporting Slides

Poly1305

For a key r, some nonce N and message M of length q the Poly1305’s MAC is defined as: T(M, N) = ((c1rq+c2rq−1+...+cqr) mod 2130−5)+Ek(N) mod 2128 Then for two messages M, M′ the missing difference will be : ((c1−c′

1)rq+(c2−c′ 2)rq−1+...+(cq−c′ q)r)

mod 2130−5 mod 2128

6 / 6

slide-73
SLIDE 73

Supporting Slides

Poly1305

For a key r, some nonce N and message M of length q the Poly1305’s MAC is defined as: T(M, N) = ((c1rq+c2rq−1+...+cqr) mod 2130−5)+Ek(N) mod 2128 Then for two messages M, M′ the missing difference will be : ((c1−c′

1)rq+(c2−c′ 2)rq−1+...+(cq−c′ q)r)

mod 2130−5 mod 2128 Choose M and M′ so that (cq − c′

q) = 1, (ci − c′ i ) = 0 and the

missing difference will be r as r < 2124 by construction. This is the hash key!

6 / 6

slide-74
SLIDE 74

Supporting Slides

Poly1305

For a key r, some nonce N and message M of length q the Poly1305’s MAC is defined as: T(M, N) = ((c1rq+c2rq−1+...+cqr) mod 2130−5)+Ek(N) mod 2128 Then for two messages M, M′ the missing difference will be : ((c1−c′

1)rq+(c2−c′ 2)rq−1+...+(cq−c′ q)r)

mod 2130−5 mod 2128 Choose M and M′ so that (cq − c′

q) = 1, (ci − c′ i ) = 0 and the

missing difference will be r as r < 2124 by construction. This is the hash key! Note : As we play with modular addition and not xor operation we have to compute a cyclic convolution using fast Fourier transform instead of Walsh-Hadamard.

6 / 6