A key-recovery timing attack on post-quantum primitives using the - - PowerPoint PPT Presentation

a key recovery timing attack on post quantum primitives
SMART_READER_LITE
LIVE PREVIEW

A key-recovery timing attack on post-quantum primitives using the - - PowerPoint PPT Presentation

A key-recovery timing attack on post-quantum primitives using the Fujisaki-Okamoto transformation and its application on FrodoKEM Qian Guo, Thomas Johansson, Alexander Nilsson August 10, 2020 Preliminaries Implementing Crypto Is Hard


slide-1
SLIDE 1

A key-recovery timing attack on post-quantum primitives using the Fujisaki-Okamoto transformation and its application on FrodoKEM

Qian Guo, Thomas Johansson, Alexander Nilsson August 10, 2020

slide-2
SLIDE 2

Preliminaries

slide-3
SLIDE 3

Implementing Crypto Is Hard

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

As shown by attacks on:

1

slide-4
SLIDE 4

Implementing Crypto Is Hard

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

As shown by attacks on:

  • DH / RSA / DSS in 1996 [Koc96]

1

slide-5
SLIDE 5

Implementing Crypto Is Hard

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

As shown by attacks on:

  • DH / RSA / DSS in 1996 [Koc96]
  • Openssl in 2002 and 2016 [BB03; YGH16] . . .

1

slide-6
SLIDE 6

Implementing Crypto Is Hard

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

As shown by attacks on:

  • DH / RSA / DSS in 1996 [Koc96]
  • Openssl in 2002 and 2016 [BB03; YGH16] . . .
  • 212 CVEs currently in NIST’s Vulnerability Database

1

slide-7
SLIDE 7

Implementing Crypto Is Hard

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

As shown by attacks on:

  • DH / RSA / DSS in 1996 [Koc96]
  • Openssl in 2002 and 2016 [BB03; YGH16] . . .
  • 212 CVEs currently in NIST’s Vulnerability Database

Post quantum Schemes?

1

slide-8
SLIDE 8

Implementing Crypto Is Hard

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

As shown by attacks on:

  • DH / RSA / DSS in 1996 [Koc96]
  • Openssl in 2002 and 2016 [BB03; YGH16] . . .
  • 212 CVEs currently in NIST’s Vulnerability Database

Post quantum Schemes?

  • McEliece in 2010 and 2013 [Str10; Str13]

1

slide-9
SLIDE 9

Implementing Crypto Is Hard

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

As shown by attacks on:

  • DH / RSA / DSS in 1996 [Koc96]
  • Openssl in 2002 and 2016 [BB03; YGH16] . . .
  • 212 CVEs currently in NIST’s Vulnerability Database

Post quantum Schemes?

  • McEliece in 2010 and 2013 [Str10; Str13]
  • BLISS in 2016 [Bru+16]

1

slide-10
SLIDE 10

Implementing Crypto Is Hard

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

As shown by attacks on:

  • DH / RSA / DSS in 1996 [Koc96]
  • Openssl in 2002 and 2016 [BB03; YGH16] . . .
  • 212 CVEs currently in NIST’s Vulnerability Database

Post quantum Schemes?

  • McEliece in 2010 and 2013 [Str10; Str13]
  • BLISS in 2016 [Bru+16]
  • LAC & Ramstake in 2019 [D’A+19]

1

slide-11
SLIDE 11

Implementing Crypto Is Hard

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

As shown by attacks on:

  • DH / RSA / DSS in 1996 [Koc96]
  • Openssl in 2002 and 2016 [BB03; YGH16] . . .
  • 212 CVEs currently in NIST’s Vulnerability Database

Post quantum Schemes?

  • McEliece in 2010 and 2013 [Str10; Str13]
  • BLISS in 2016 [Bru+16]
  • LAC & Ramstake in 2019 [D’A+19]

This presentation: A general attack against the Fujisaki-Okamoto transformation.

1

slide-12
SLIDE 12

Our contribution

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

The Fujisaki-Okamoto (FO) transform does not directly handle secret data, yet must be implemented in constant time.

2

slide-13
SLIDE 13

Our contribution

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

The Fujisaki-Okamoto (FO) transform does not directly handle secret data, yet must be implemented in constant time. Potentially vulnerable NIST PQC candidates: FrodoKEM, LAC, BIKE (early version), HQC, ROLLO and RQC. Maybe others?

2

slide-14
SLIDE 14

Our contribution

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

The Fujisaki-Okamoto (FO) transform does not directly handle secret data, yet must be implemented in constant time. Potentially vulnerable NIST PQC candidates: FrodoKEM, LAC, BIKE (early version), HQC, ROLLO and RQC. Maybe others? We show the attack for FrodoKEM (Lattice/LWE based).

2

slide-15
SLIDE 15

A quick, lightweight, background

slide-16
SLIDE 16

PKE’s and KEM’s

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Publik Key Encryption Schemes sk, pk ← KeyGen(·) (sk, pk) ⇔ (secret key, public key) c ← PKE.CPA.Encrypt(pk,m) (m, c) ⇔ (plaintext, ciphertext) m ← PKE.CPA.Decrypt(sk,c)

3

slide-17
SLIDE 17

PKE’s and KEM’s

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Publik Key Encryption Schemes sk, pk ← KeyGen(·) (sk, pk) ⇔ (secret key, public key) c ← PKE.CPA.Encrypt(pk,m) (m, c) ⇔ (plaintext, ciphertext) m ← PKE.CPA.Decrypt(sk,c) Key Encapsulation Mechanisms sk, pk ← KeyGen(·) c, ss ← KEM.CCA.Encaps(pk) ss ⇔ (shared secret) ss ← KEM.CCA.Decaps(sk,c)

3

slide-18
SLIDE 18

Security Models

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

PKE-schemes are often proven under the IND-CPA model

4

slide-19
SLIDE 19

Security Models

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

PKE-schemes are often proven under the IND-CPA model INDistinguishability under Chosen Plaintext Attack: Security game with no access to a decryption oracle.

4

slide-20
SLIDE 20

Security Models

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

PKE-schemes are often proven under the IND-CPA model INDistinguishability under Chosen Plaintext Attack: Security game with no access to a decryption oracle. Often, IND-CCA is desirable.

4

slide-21
SLIDE 21

Security Models

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

PKE-schemes are often proven under the IND-CPA model INDistinguishability under Chosen Plaintext Attack: Security game with no access to a decryption oracle. Often, IND-CCA is desirable. INDistinguishability under Chosen Ciphertext Attack: Security game with access to a decryption oracle.

4

slide-22
SLIDE 22

Security Models

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

PKE-schemes are often proven under the IND-CPA model INDistinguishability under Chosen Plaintext Attack: Security game with no access to a decryption oracle. Often, IND-CCA is desirable. INDistinguishability under Chosen Ciphertext Attack: Security game with access to a decryption oracle. The Fujisaki-Okamoto (FO) transform can be used to transform a CPA secure PKE-cipher into a CCA secure cipher.

4

slide-23
SLIDE 23

LWE and Code-based schemes

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

A common property:

5

slide-24
SLIDE 24

LWE and Code-based schemes

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

A common property: LWE encoding c = g(pk, m; r) + e(r) Code-based encoding c = mG ⊕ e

5

slide-25
SLIDE 25

LWE and Code-based schemes

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

A common property: LWE encoding c = g(pk, m; r) + e(r) Code-based encoding c = mG ⊕ e e can vary by a small degree without affecting decryption.

5

slide-26
SLIDE 26

LWE and Code-based schemes

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

A common property: LWE encoding c = g(pk, m; r) + e(r) Code-based encoding c = mG ⊕ e e can vary by a small degree without affecting decryption. Decryption fails if e varies by a larger degree.

5

slide-27
SLIDE 27

Fujisaki-Okamoto I

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

The FO-transform can be used to transform a CPA secure PK-cipher into a CCA secure non-malleable KEM:

6

slide-28
SLIDE 28

Fujisaki-Okamoto I

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

The FO-transform can be used to transform a CPA secure PK-cipher into a CCA secure non-malleable KEM: Algorithm 1: KEM.CCA.Encaps Input: pk Output: (c, ss)

1 pick a random m 2 (r, k) ← H(m, pk) 3 c ← PKE.CPA.Encrypt(pk,m;r) 4 ss ← H(c, k) 5 return (c, ss) 6

slide-29
SLIDE 29

Fujisaki-Okamoto I

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

The FO-transform can be used to transform a CPA secure PK-cipher into a CCA secure non-malleable KEM: Algorithm 1: KEM.CCA.Encaps Input: pk Output: (c, ss)

1 pick a random m 2 (r, k) ← H(m, pk) 3 c ← PKE.CPA.Encrypt(pk,m;r) /* IND-CPA secure

*/

4 ss ← H(c, k) 5 return (c, ss) 6

slide-30
SLIDE 30

Fujisaki-Okamoto II

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

The decapsulation function decodes and compare the re-encoding with the received ciphertext.

7

slide-31
SLIDE 31

Fujisaki-Okamoto II

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

The decapsulation function decodes and compare the re-encoding with the received ciphertext. Algorithm 2: KEM.CCA.Decaps Input: (sk, pk, c) Output: (ss)

1 m′ ← PKE.CPA.Decrypt(sk,c) 2 (r′, k′) ← H(m′, pk) 3 c′ ← PKE.CPA.Encrypt(pk,m’;r) 4 if (c′ = c) then return ss′ ← H(c, k) 5 else return ss′ ← H(c, k′) 6 end if 7 return (c, ss) 7

slide-32
SLIDE 32

Fujisaki-Okamoto II

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

The decapsulation function decodes and compare the re-encoding with the received ciphertext. Algorithm 2: KEM.CCA.Decaps Input: (sk, pk, c) Output: (ss)

1 m′ ← PKE.CPA.Decrypt(sk,c) 2 (r′, k′) ← H(m′, pk) 3 c′ ← PKE.CPA.Encrypt(pk,m’;r) 4 if (c′ = c) then return ss′ ← H(c, k) 5 else return ss′ ← H(c, k′) 6 end if 7 return (c, ss) 7

slide-33
SLIDE 33

Fujisaki-Okamoto II

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

The decapsulation function decodes and compare the re-encoding with the received ciphertext. Algorithm 2: KEM.CCA.Decaps Input: (sk, pk, c) Output: (ss)

1 m′ ← PKE.CPA.Decrypt(sk,c) 2 (r′, k′) ← H(m′, pk) 3 c′ ← PKE.CPA.Encrypt(pk,m’;r) 4 if (c′ = c) then return ss′ ← H(c, k) 5 else return ss′ ← H(c, k′) 6 end if 7 return (c, ss) 7

slide-34
SLIDE 34

Fujisaki-Okamoto II

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

The decapsulation function decodes and compare the re-encoding with the received ciphertext. Algorithm 2: KEM.CCA.Decaps Input: (sk, pk, c) Output: (ss)

1 m′ ← PKE.CPA.Decrypt(sk,c) 2 (r′, k′) ← H(m′, pk) 3 c′ ← PKE.CPA.Encrypt(pk,m’;r) 4 if (c′ = c) then return ss′ ← H(c, k) 5 else return ss′ ← H(c, k′) 6 end if 7 return (c, ss)

memcmp? Constant time?

7

slide-35
SLIDE 35

The Attack, Generalized

slide-36
SLIDE 36

The Vulnerability

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

FF EE DD CC BB AA 99 88 77 66 c: FF EE DD CC BB AA 99 88 77 66 c’: memcmp Assumptions:

  • 1. Not constant time
  • 2. Tiny modification to c → no change to c’
  • 3. Large modification to c → total change of c’

Strategy:

  • Do modifications at the end of c
  • Find the exact threshold between case 2 and 3.
  • Time KEM.CCA.Decaps, repeat as necessary.
  • Extract secrets from the KEM-scheme.

8

slide-37
SLIDE 37

The Vulnerability

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

FF EE DD DD BB AA 99 88 77 66 c: FF EE DD CC BB AA 99 88 77 66 c’: memcmp Assumptions:

  • 1. Not constant time
  • 2. Tiny modification to c → no change to c’
  • 3. Large modification to c → total change of c’

Strategy:

  • Do modifications at the end of c
  • Find the exact threshold between case 2 and 3.
  • Time KEM.CCA.Decaps, repeat as necessary.
  • Extract secrets from the KEM-scheme.

8

slide-38
SLIDE 38

The Vulnerability

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

FF EE DD 00 BB AA 99 88 77 66 c: 15 CB B8 E2 C6 66 79 1A A1 3F c’: memcmp Assumptions:

  • 1. Not constant time
  • 2. Tiny modification to c → no change to c’
  • 3. Large modification to c → total change of c’

Strategy:

  • Do modifications at the end of c
  • Find the exact threshold between case 2 and 3.
  • Time KEM.CCA.Decaps, repeat as necessary.
  • Extract secrets from the KEM-scheme.

8

slide-39
SLIDE 39

The Vulnerability

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

FF EE DD CC BB AA 99 88 77 77 c: FF EE DD CC BB AA 99 88 77 66 c’: memcmp Assumptions:

  • 1. Not constant time
  • 2. Tiny modification to c → no change to c’
  • 3. Large modification to c → total change of c’

Strategy:

  • Do modifications at the end of c
  • Find the exact threshold between case 2 and 3.
  • Time KEM.CCA.Decaps, repeat as necessary.
  • Extract secrets from the KEM-scheme.

8

slide-40
SLIDE 40

The Vulnerability

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

FF EE DD CC BB AA 99 88 77 AA c: 15 CB B8 E2 C6 66 79 1A A1 3F c’: memcmp Assumptions:

  • 1. Not constant time
  • 2. Tiny modification to c → no change to c’
  • 3. Large modification to c → total change of c’

Strategy:

  • Do modifications at the end of c
  • Find the exact threshold between case 2 and 3.
  • Time KEM.CCA.Decaps, repeat as necessary.
  • Extract secrets from the KEM-scheme.

8

slide-41
SLIDE 41

The Vulnerability

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

FF EE DD CC BB AA 99 88 77 66 c: FF EE DD CC BB AA 99 88 77 66 c’: memcmp Assumptions:

  • 1. Not constant time
  • 2. Tiny modification to c → no change to c’
  • 3. Large modification to c → total change of c’

Strategy:

  • Do modifications at the end of c
  • Find the exact threshold between case 2 and 3.
  • Time KEM.CCA.Decaps, repeat as necessary.
  • Extract secrets from the KEM-scheme.

8

slide-42
SLIDE 42

The Vulnerability

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

FF EE DD CC BB AA 99 88 77 66 c: FF EE DD CC BB AA 99 88 77 66 c’: memcmp Assumptions:

  • 1. Not constant time
  • 2. Tiny modification to c → no change to c’
  • 3. Large modification to c → total change of c’

Strategy:

  • Do modifications at the end of c
  • Find the exact threshold between case 2 and 3.
  • Time KEM.CCA.Decaps, repeat as necessary.
  • Extract secrets from the KEM-scheme.

8

slide-43
SLIDE 43

Decryption Error Oracle

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 3: Error.Oracle Input: m, a ciphertext modification d Output: b (decryption failure or not)

1 (r, k) ← H1(m, pk) 2 c ← PKE.CPA.Encrypt(pk,m;r) 3 c′ ← c + d 4 t ← Measure[KEM.CCA.Decaps(sk,c’)] 5 b ← F(t) 6 return b

where F(t) uses t to determine whether PKE.CPA.Decrypt returns m′ = m or m′ = m.

9

slide-44
SLIDE 44

Decryption Error Oracle

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 3: Error.Oracle Input: m, a ciphertext modification d Output: b (decryption failure or not)

1 (r, k) ← H1(m, pk) 2 c ← PKE.CPA.Encrypt(pk,m;r) 3 c′ ← c + d 4 t ← Measure[KEM.CCA.Decaps(sk,c’)] 5 b ← F(t) 6 return b

where F(t) uses t to determine whether PKE.CPA.Decrypt returns m′ = m or m′ = m.

9

slide-45
SLIDE 45

Decryption Error Oracle

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 3: Error.Oracle Input: m, a ciphertext modification d Output: b (decryption failure or not)

1 (r, k) ← H1(m, pk) 2 c ← PKE.CPA.Encrypt(pk,m;r) 3 c′ ← c + d 4 t ← Measure[KEM.CCA.Decaps(sk,c’)] 5 b ← F(t) 6 return b

where F(t) uses t to determine whether PKE.CPA.Decrypt returns m′ = m or m′ = m.

9

slide-46
SLIDE 46

Decryption Error Oracle

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 3: Error.Oracle Input: m, a ciphertext modification d Output: b (decryption failure or not)

1 (r, k) ← H1(m, pk) 2 c ← PKE.CPA.Encrypt(pk,m;r) 3 c′ ← c + d 4 t ← Measure[KEM.CCA.Decaps(sk,c’)] 5 b ← F(t) 6 return b

where F(t) uses t to determine whether PKE.CPA.Decrypt returns m′ = m or m′ = m.

9

slide-47
SLIDE 47

Decryption Error Oracle

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 3: Error.Oracle Input: m, a ciphertext modification d Output: b (decryption failure or not)

1 (r, k) ← H1(m, pk) 2 c ← PKE.CPA.Encrypt(pk,m;r) 3 c′ ← c + d 4 t ← Measure[KEM.CCA.Decaps(sk,c’)] 5 b ← F(t) 6 return b

where F(t) uses t to determine whether PKE.CPA.Decrypt returns m′ = m or m′ = m.

9

slide-48
SLIDE 48

Secret Key Recovery

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 4: Secret Key Recovery Input: n1 Output: sk

1 for i ← 0;

i < n1; i ← i + 1 do

2

begin find (mi, di) such that

3

Error.Oracle(mi, di) = 0 and

4

Error.Oracle(mi, di + 1) = 1

5

end

6 end 7 Use set {((mi, di), 0 ≤ i < n)} to extract the secret key 8 return sk 10

slide-49
SLIDE 49

Secret Key Recovery

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 4: Secret Key Recovery Input: n1 Output: sk

1 for i ← 0;

i < n1; i ← i + 1 do

2

begin find (mi, di) such that

3

Error.Oracle(mi, di) = 0 and

4

Error.Oracle(mi, di + 1) = 1

5

end

6 end 7 Use set {((mi, di), 0 ≤ i < n)} to extract the secret key 8 return sk 10

slide-50
SLIDE 50

Secret Key Recovery

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 4: Secret Key Recovery Input: n1 Output: sk

1 for i ← 0;

i < n1; i ← i + 1 do

2

begin find (mi, di) such that

3

Error.Oracle(mi, di) = 0 and

4

Error.Oracle(mi, di + 1) = 1

5

end

6 end 7 Use set {((mi, di), 0 ≤ i < n)} to extract the secret key 8 return sk 10

slide-51
SLIDE 51

The case of FrodoKEM

slide-52
SLIDE 52

FrodoKEM KeyGen

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Simplified: (r1, r2, seedA, s) ← uniform random seeds. E ← Frodo.SampleMatrix(r2) Secret Key (S, s) S ← Frodo.SampleMatrix(r1) Public Key (seedA, B) A ← Frodo.Gen(seedA) B ← AS + E (1)

11

slide-53
SLIDE 53

FrodoKEM KeyGen

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Simplified: (r1, r2, seedA, s) ← uniform random seeds. E ← Frodo.SampleMatrix(r2) Secret Key (S, s) S ← Frodo.SampleMatrix(r1) Public Key (seedA, B) A ← Frodo.Gen(seedA) B ← AS + E (1)

11

slide-54
SLIDE 54

FrodoKEM Encaps

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 5: FrodoKEM.Encaps (simplified) Input: pk Output: ss, c

1 m ← uniform random plaintext 2 (r1, r2, r3, k) ← H(H(pk)||m) 3 (S′, E ′, E ′′) ← for i ∈ {1, 2, 3} do Frodo.SampleMatrix(ri) end 4 B′ ← S′A + E ′ 5 C ← S′B + E ′′ + Frodo.Encode(m) 6 c ← Frodo.Pack(B′||C) 7 return (H(c||k), c) 12

slide-55
SLIDE 55

FrodoKEM Encaps

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 5: FrodoKEM.Encaps (simplified) Input: pk Output: ss, c

1 m ← uniform random plaintext 2 (r1, r2, r3, k) ← H(H(pk)||m) 3 (S′, E ′, E ′′) ← for i ∈ {1, 2, 3} do Frodo.SampleMatrix(ri) end 4 B′ ← S′A + E ′ 5 C ← S′B + E ′′ + Frodo.Encode(m) 6 c ← Frodo.Pack(B′||C) 7 return (H(c||k), c) 12

slide-56
SLIDE 56

FrodoKEM Encaps

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 5: FrodoKEM.Encaps (simplified) Input: pk Output: ss, c

1 m ← uniform random plaintext 2 (r1, r2, r3, k) ← H(H(pk)||m) 3 (S′, E ′, E ′′) ← for i ∈ {1, 2, 3} do Frodo.SampleMatrix(ri) end 4 B′ ← S′A + E ′ 5 C ← S′B + E ′′ + Frodo.Encode(m) 6 c ← Frodo.Pack(B′||C) 7 return (H(c||k), c) 12

slide-57
SLIDE 57

FrodoKEM Encaps

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 5: FrodoKEM.Encaps (simplified) Input: pk Output: ss, c

1 m ← uniform random plaintext 2 (r1, r2, r3, k) ← H(H(pk)||m) 3 (S′, E ′, E ′′) ← for i ∈ {1, 2, 3} do Frodo.SampleMatrix(ri) end 4 B′ ← S′A + E ′ 5 C ← S′B + E ′′ + Frodo.Encode(m) 6 c ← Frodo.Pack(B′||C) 7 return (H(c||k), c) 12

slide-58
SLIDE 58

FrodoKEM Encaps

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 5: FrodoKEM.Encaps (simplified) Input: pk Output: ss, c

1 m ← uniform random plaintext 2 (r1, r2, r3, k) ← H(H(pk)||m) 3 (S′, E ′, E ′′) ← for i ∈ {1, 2, 3} do Frodo.SampleMatrix(ri) end 4 B′ ← S′A + E ′ 5 C ← S′B + E ′′ + Frodo.Encode(m) 6 c ← Frodo.Pack(B′||C) 7 return (H(c||k), c) 12

slide-59
SLIDE 59

FrodoKEM Encaps

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 5: FrodoKEM.Encaps (simplified) Input: pk Output: ss, c

1 m ← uniform random plaintext 2 (r1, r2, r3, k) ← H(H(pk)||m) 3 (S′, E ′, E ′′) ← for i ∈ {1, 2, 3} do Frodo.SampleMatrix(ri) end 4 B′ ← S′A + E ′ 5 C ← S′B + E ′′ + Frodo.Encode(m) 6 c ← Frodo.Pack(B′||C) 7 return (H(c||k), c) 12

slide-60
SLIDE 60

FrodoKEM Decaps

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 6: FrodoKEM.Decaps (simplified)

Input: c, sk Output: ss

1 (B′, C) ⇐ Frodo.Unpack(c) 2 m′ ← Frodo.Decode(C − B′S) 3 (r1, r2, r3, k′) ← H(H(pk)||m′) 4 (S′, E ′, E ′′) ← for i ∈ {1, 2, 3} do Frodo.SampleMatrix(ri) end 5 B′′ ← S′A + E ′ 6 C ′ ← S′B + E ′′ + Frodo.Encode(m′) 7 if B′||C = B′′||C ′ then 8

return H(c||k′)

9 else 10

return H(c||s)

11 end

13

slide-61
SLIDE 61

FrodoKEM Decaps

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 6: FrodoKEM.Decaps (simplified)

Input: c, sk Output: ss

1 (B′, C) ⇐ Frodo.Unpack(c) 2 m′ ← Frodo.Decode(C − B′S) 3 (r1, r2, r3, k′) ← H(H(pk)||m′) 4 (S′, E ′, E ′′) ← for i ∈ {1, 2, 3} do Frodo.SampleMatrix(ri) end 5 B′′ ← S′A + E ′ 6 C ′ ← S′B + E ′′ + Frodo.Encode(m′) 7 if B′||C = B′′||C ′ then 8

return H(c||k′)

9 else 10

return H(c||s)

11 end

13

slide-62
SLIDE 62

FrodoKEM Decaps

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 6: FrodoKEM.Decaps (simplified)

Input: c, sk Output: ss

1 (B′, C) ⇐ Frodo.Unpack(c) 2 m′ ← Frodo.Decode(C − B′S) 3 (r1, r2, r3, k′) ← H(H(pk)||m′) 4 (S′, E ′, E ′′) ← for i ∈ {1, 2, 3} do Frodo.SampleMatrix(ri) end 5 B′′ ← S′A + E ′ 6 C ′ ← S′B + E ′′ + Frodo.Encode(m′) 7 if B′||C = B′′||C ′ then 8

return H(c||k′)

9 else 10

return H(c||s)

11 end

13

slide-63
SLIDE 63

FrodoKEM Decaps

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Algorithm 6: FrodoKEM.Decaps (simplified)

Input: c, sk Output: ss

1 (B′, C) ⇐ Frodo.Unpack(c) 2 m′ ← Frodo.Decode(C − B′S) 3 (r1, r2, r3, k′) ← H(H(pk)||m′) 4 (S′, E ′, E ′′) ← for i ∈ {1, 2, 3} do Frodo.SampleMatrix(ri) end 5 B′′ ← S′A + E ′ 6 C ′ ← S′B + E ′′ + Frodo.Encode(m′) 7 if B′||C = B′′||C ′ then 8

return H(c||k′)

9 else 10

return H(c||s) /* where s is part of secret key */

11 end

13

slide-64
SLIDE 64

The combined noise matrix E ′′′

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

line 2: m′ ← Frodo.Decode(C − B′S) C − B′S = Frodo.Encode(m′) + S′E − E ′S + E ′′

  • E ′′′

14

slide-65
SLIDE 65

The combined noise matrix E ′′′

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

line 2: m′ ← Frodo.Decode(C − B′S) C − B′S = Frodo.Encode(m′) + S′E − E ′S + E ′′

  • E ′′′

Since S′, E ′ and E ′′ are known and Equation (1) ⇒ E = B − AS:

14

slide-66
SLIDE 66

The combined noise matrix E ′′′

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

line 2: m′ ← Frodo.Decode(C − B′S) C − B′S = Frodo.Encode(m′) + S′E − E ′S + E ′′

  • E ′′′

Since S′, E ′ and E ′′ are known and Equation (1) ⇒ E = B − AS: We get linear equations for the values in S, if we know E ′′′.

14

slide-67
SLIDE 67

Figuring out E ′′′

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Paraphrasing lemma 2.18 from [Nae+18]: For successfull decryption: −2D−Bp−1 ≤ E ′′′

i,j < 2D−Bp−1 for all entries i, j in matrix E ′′′.

Where Bp ≤ D and Bp, D ∈ Z are FrodoKEM paramters.

15

slide-68
SLIDE 68

Figuring out E ′′′

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Paraphrasing lemma 2.18 from [Nae+18]: For successfull decryption: −2D−Bp−1 ≤ E ′′′

i,j < 2D−Bp−1 for all entries i, j in matrix E ′′′.

Where Bp ≤ D and Bp, D ∈ Z are FrodoKEM paramters. Picking x0 > 0 we get decryption failure when E ′′′

i,j + x0 ≥ 2D−Bp−1 15

slide-69
SLIDE 69

Figuring out E ′′′

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Paraphrasing lemma 2.18 from [Nae+18]: For successfull decryption: −2D−Bp−1 ≤ E ′′′

i,j < 2D−Bp−1 for all entries i, j in matrix E ′′′.

Where Bp ≤ D and Bp, D ∈ Z are FrodoKEM paramters. Picking x0 > 0 we get decryption failure when E ′′′

i,j + x0 ≥ 2D−Bp−1

Thus E ′′′

i,j = 2D−Bp−1 − x0

if Error.Oracle(mi, x0) = 1 and Error.Oracle(mi, x0 − 1) = 0.

15

slide-70
SLIDE 70

Graphs, numbers and such

slide-71
SLIDE 71

Results

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

I

1000 2000 3000 4000 5000

Reference clock-cycles

0.000 0.005 0.010 0.015 0.020

Density

memcmp only

x = 0 x = 1 x = 2D−B 16

slide-72
SLIDE 72

Results II

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

1.267 1.268 1.269 1.270 1.271 1.272 1.273

Reference clock-cycles

×107 0.00000 0.00001 0.00002 0.00003 0.00004 0.00005 0.00006

Density

FrodoKEM.Decaps

x = 0 x = 1 x = 2D−B 17

slide-73
SLIDE 73

Results III

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Tiny differences

4800 12700000 ≈ 0.04% 18

slide-74
SLIDE 74

Results III

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Tiny differences

4800 12700000 ≈ 0.04%

Binary search

  • One binary search ≈ 97000 decapsulations
  • Size of combined noice matrix 1344 × 8

18

slide-75
SLIDE 75

Results III

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

Tiny differences

4800 12700000 ≈ 0.04%

Binary search

  • One binary search ≈ 97000 decapsulations
  • Size of combined noice matrix 1344 × 8

Complete Key Recovery 97000 × 1344 × 8 ≈ 230 queries for FrodoKEM-1344-AES

  • n a Intel i5-4200U CPU running at 1.6GHz.

18

slide-76
SLIDE 76

Summary

slide-77
SLIDE 77

Conclusions

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

“All our implementations avoid the use of secret address accesses and secret branches and, hence, are protected against timing and cache attacks.” — FrodoKEM Specification. Very good, but still not enough

19

slide-78
SLIDE 78

Thank you!

WALLENBERG AI, AUTONOMOUS SYSTEMS AND SOFTWARE PROGRAM

20

slide-79
SLIDE 79

References

[BB03] David Brumley and Dan Boneh. “Remote Timing Attacks Are Practical”. In: 2003. [Bru+16] Leon Groot Bruinderink et al. “Flush, Gauss, and Reload - A Cache Attack on the BLISS Lattice-Based Signature Scheme”. In: 2016,

  • pp. 323–345. doi: 10.1007/978-3-662-53140-2_16.

[D’A+19] Jan-Pieter D’Anvers et al. “Timing attacks on Error Correcting Codes in Post-Quantum Secure Schemes.”. In: IACR Cryptology ePrint Archive 2019 (2019), p. 292. [GJN20] Qian Guo, Thomas Johansson, and Alexander Nilsson. “A key-recovery timing attack on post-quantum primitives using the Fujisaki-Okamoto transformation and its application on FrodoKEM”. In: Crypto (2020). [Koc96] Paul C. Kocher. “Timing Attacks on Implementations of Diffie-Hellman, RSA, DSS, and Other Systems”. In: 1996, pp. 104–113. doi: 10.1007/3-540-68697-5_9. 21

slide-80
SLIDE 80

[Nae+18] M Naehrig et al. FrodoKEM: Learning With Errors Key Encapsulation–Algorithm Specifications And Supporting Documentation.

  • Tech. rep. tech. rep., National Institute of Standards and Technology,
  • 2019. https, 2018.

[Str10] Falko Strenzke. “A Timing Attack against the Secret Permutation in the McEliece PKC”. In: 2010, pp. 95–107. doi: 10.1007/978-3-642-12929-2_8. [Str13] Falko Strenzke. “Timing Attacks against the Syndrome Inversion in Code-Based Cryptosystems”. In: 2013, pp. 217–230. doi: 10.1007/978-3-642-38616-9_15. [YGH16] Yuval Yarom, Daniel Genkin, and Nadia Heninger. CacheBleed: A Timing Attack on OpenSSL Constant Time RSA. Cryptology ePrint Archive, Report 2016/224. https://eprint.iacr.org/2016/224. 2016. 22