Introduction to the theory of secret key cryptography Andreas H - - PowerPoint PPT Presentation

introduction to the theory of secret key cryptography
SMART_READER_LITE
LIVE PREVIEW

Introduction to the theory of secret key cryptography Andreas H - - PowerPoint PPT Presentation

Introduction to the theory of secret key cryptography Andreas H ulsing Eindhoven University of Technology 17 June 2019 Secret key encryption MAC Main primitives of secret key / symmetric cryptography High-level primitives Low-level


slide-1
SLIDE 1

Introduction to the theory of secret key cryptography

Andreas H¨ ulsing Eindhoven University of Technology 17 June 2019

slide-2
SLIDE 2

Secret key encryption MAC

Main primitives of secret key / symmetric cryptography

High-level primitives Low-level primitives

2 / 50

slide-3
SLIDE 3

Secret key encryption MAC

Main primitives of secret key / symmetric cryptography

High-level primitives Secret key encryption (SKE)

Provides: Secrecy Applications: File encryption, communication secrecy

Low-level primitives

2 / 50

slide-4
SLIDE 4

Secret key encryption MAC

Main primitives of secret key / symmetric cryptography

High-level primitives Secret key encryption (SKE)

Provides: Secrecy Applications: File encryption, communication secrecy

Message authentication codes (MAC)

Provides: Integrity & authentication Applications: Secure communication (allows for deniability), secure storage

Low-level primitives

2 / 50

slide-5
SLIDE 5

Secret key encryption MAC

Main primitives of secret key / symmetric cryptography

High-level primitives Secret key encryption (SKE)

Provides: Secrecy Applications: File encryption, communication secrecy

Message authentication codes (MAC)

Provides: Integrity & authentication Applications: Secure communication (allows for deniability), secure storage

Low-level primitives Pseudorandom generator (PRG) / function (PRF)

Provides: Pseudorandom behaviour Applications: Replace random bits / functions with deterministic object

2 / 50

slide-6
SLIDE 6

Secret key encryption MAC

Main primitives of secret key / symmetric cryptography

High-level primitives Secret key encryption (SKE)

Provides: Secrecy Applications: File encryption, communication secrecy

Message authentication codes (MAC)

Provides: Integrity & authentication Applications: Secure communication (allows for deniability), secure storage

Low-level primitives Pseudorandom generator (PRG) / function (PRF)

Provides: Pseudorandom behaviour Applications: Replace random bits / functions with deterministic object

Cryptographic hash functions

Provides: One-wayness, collision resistance Applications: From digital signatures to password hashing and PoW

2 / 50

slide-7
SLIDE 7

Secret key encryption MAC

Secret key encryption

3 / 50

slide-8
SLIDE 8

Secret key encryption MAC

Secret key encryption (SKE)

4 / 50

slide-9
SLIDE 9

Secret key encryption MAC

Secret key cryptography

Definition (Secret key encryption scheme) A secret key encryption scheme is a tripple of algorithms E = (Gen, Enc, Dec) and a message or plaintext space M such that the following holds Gen is a probabilistic algorithm that outputs a key k. The

  • utput space of Gen is called key space K.

Enc takes as inputs a key k ∈ K and message m ∈ M, and outputs ciphertext c = Enck(m). The output space of Enc is called ciphertext space C. Dec is a deterministic algorithm that takes as inputs a key k ∈ K and ciphertext c ∈ C and outputs a plaintext m′ ∈ M : m′ = Deck(c). Correctness: (∀k ← Gen(), ∀m ∈ M) : Deck(Enck(m)) = m

5 / 50

slide-10
SLIDE 10

Secret key encryption MAC

How to define security?

Definition (Perfect secrecy) A secret key encryption scheme E = (Gen, Enc, Dec) with message space M is perfectly secret if for every probability distribution over M, every message m ∈ M, and every ciphertext c ∈ C for which Pr [C = c] > 0: Pr [M = m | C = c] = Pr [M = m] Perfect secrecy considers adversaries A with unlimited power.

6 / 50

slide-11
SLIDE 11

Secret key encryption MAC

Is perfect secrecy achievable?

A scheme that is perfectly secret is Vernam’s one-time pad (OTP): Construction (One-time pad) Let M = {0, 1}ℓ(= K = C), the one-time pad is the encryption scheme consisting of the following three algorithms: Gen(): Return k ←R {0, 1}ℓ. Enck(m): Return c = m ⊕ k. Deck(c): Return m′ = c ⊕ k.

7 / 50

slide-12
SLIDE 12

Secret key encryption MAC

Is perfect secrecy achievable?

A scheme that is perfectly secret is Vernam’s one-time pad (OTP): Construction (One-time pad) Let M = {0, 1}ℓ(= K = C), the one-time pad is the encryption scheme consisting of the following three algorithms: Gen(): Return k ←R {0, 1}ℓ. Enck(m): Return c = m ⊕ k. Deck(c): Return m′ = c ⊕ k. Correctness Deck(Enck(m)) = (m ⊕ k) ⊕ k = m

7 / 50

slide-13
SLIDE 13

Secret key encryption MAC

Is perfect secrecy achievable?

A scheme that is perfectly secret is Vernam’s one-time pad (OTP): Construction (One-time pad) Let M = {0, 1}ℓ(= K = C), the one-time pad is the encryption scheme consisting of the following three algorithms: Gen(): Return k ←R {0, 1}ℓ. Enck(m): Return c = m ⊕ k. Deck(c): Return m′ = c ⊕ k. Correctness Deck(Enck(m)) = (m ⊕ k) ⊕ k = m Main observation behind security proof For every pair (m, c) of message and ciphertext there exists exactly

  • ne key that encrypts m as c.

7 / 50

slide-14
SLIDE 14

Secret key encryption MAC

Is perfect secrecy efficiently achievable?

Theorem Let E be a perfectly secret encryption scheme over message space M, and let K be the key space determined by Gen. Then |K| ≥ |M|.

8 / 50

slide-15
SLIDE 15

Secret key encryption MAC

Is perfect secrecy efficiently achievable?

Theorem Let E be a perfectly secret encryption scheme over message space M, and let K be the key space determined by Gen. Then |K| ≥ |M|. Proof sketch Assume |K| < |M|.

1 An arbitrary ciphertext c can only decrypt to ≤ |K| different

messages.

2 Consequently, there exist messages m such that

Pr [M = m | C = c] = 0.

3 If we choose the uniform distribution as message distribution

Pr [M = m] > 0. Hence, E is not perfectly secure.

8 / 50

slide-16
SLIDE 16

Secret key encryption MAC

Back to square 1: How to define security?

Consider security against efficient (= computationally bounded [= polytime]) adversaries. Experiment- / game-based security definitions: We define a game that is played by the adversary and analyze its success probability.

9 / 50

slide-17
SLIDE 17

Secret key encryption MAC

Attempt 1: Semantic security

Intuition: Everything adversary A learns about m knowing c, one could have learned without knowing c.

10 / 50

slide-18
SLIDE 18

Secret key encryption MAC

Attempt 1: Semantic security

Intuition: Everything adversary A learns about m knowing c, one could have learned without knowing c. Simulation-based security: A is compared to simulator S which plays in a slightly different ‘experiment’ (real VS ideal).

10 / 50

slide-19
SLIDE 19

Secret key encryption MAC

Attempt 1: Semantic security

Intuition: Everything adversary A learns about m knowing c, one could have learned without knowing c. Simulation-based security: A is compared to simulator S which plays in a slightly different ‘experiment’ (real VS ideal). ExpSEM

E,A (n):

A chooses a challenge template:

10 / 50

slide-20
SLIDE 20

Secret key encryption MAC

Attempt 1: Semantic security

Intuition: Everything adversary A learns about m knowing c, one could have learned without knowing c. Simulation-based security: A is compared to simulator S which plays in a slightly different ‘experiment’ (real VS ideal). ExpSEM

E,A (n):

A chooses a challenge template: a message distribution X on plaintext space M,

10 / 50

slide-21
SLIDE 21

Secret key encryption MAC

Attempt 1: Semantic security

Intuition: Everything adversary A learns about m knowing c, one could have learned without knowing c. Simulation-based security: A is compared to simulator S which plays in a slightly different ‘experiment’ (real VS ideal). ExpSEM

E,A (n):

A chooses a challenge template: a message distribution X on plaintext space M, an advice function h : M → N,

10 / 50

slide-22
SLIDE 22

Secret key encryption MAC

Attempt 1: Semantic security

Intuition: Everything adversary A learns about m knowing c, one could have learned without knowing c. Simulation-based security: A is compared to simulator S which plays in a slightly different ‘experiment’ (real VS ideal). ExpSEM

E,A (n):

A chooses a challenge template: a message distribution X on plaintext space M, an advice function h : M → N, a target function f : M → N.

10 / 50

slide-23
SLIDE 23

Secret key encryption MAC

Attempt 1: Semantic security

Intuition: Everything adversary A learns about m knowing c, one could have learned without knowing c. Simulation-based security: A is compared to simulator S which plays in a slightly different ‘experiment’ (real VS ideal). ExpSEM

E,A (n):

A chooses a challenge template: a message distribution X on plaintext space M, an advice function h : M → N, a target function f : M → N. x is sampled from X and A receives (Enck(x), h(x)). A succeeds if A(Enck(x), h(x)) = f (x).

10 / 50

slide-24
SLIDE 24

Secret key encryption MAC

Attempt 1: Semantic security

Intuition: Everything adversary A learns about m knowing c, one could have learned without knowing c. Simulation-based security: A is compared to simulator S which plays in a slightly different ‘experiment’ (real VS ideal). ExpSEM

E,A (n):

A chooses a challenge template: a message distribution X on plaintext space M, an advice function h : M → N, a target function f : M → N. x is sampled from X and A receives (Enck(x), h(x)). A succeeds if A(Enck(x), h(x)) = f (x). (S only receives h(x). S succeeds if S(h(x)) = f (x).)

10 / 50

slide-25
SLIDE 25

Secret key encryption MAC

Attempt 1: Semantic security

Definition (Semantic Security (SEM)) A secret key encryption scheme has semantic security if for any efficient adversary A there exists an efficient simulator S such that their probabilites of success playing ExpSEM

E,A (n) are negligibly close

to each other.

11 / 50

slide-26
SLIDE 26

Secret key encryption MAC

Attempt 1: Semantic security

Definition (Semantic Security (SEM)) A secret key encryption scheme has semantic security if for any efficient adversary A there exists an efficient simulator S such that their probabilites of success playing ExpSEM

E,A (n) are negligibly close

to each other. For unbounded adversaries this is equivalent to perfect secrecy. This definition is cumbersome to work with!

11 / 50

slide-27
SLIDE 27

Secret key encryption MAC

Attempt 2: Indistinguishable ciphertext security

ExpIND

E,A (n):

1 k ← Gen(1n) 12 / 50

slide-28
SLIDE 28

Secret key encryption MAC

Attempt 2: Indistinguishable ciphertext security

ExpIND

E,A (n):

1 k ← Gen(1n) 2 m0, m1 ← A(1n) with m0, m1 ∈ M ∧ |m0| = |m1| 12 / 50

slide-29
SLIDE 29

Secret key encryption MAC

Attempt 2: Indistinguishable ciphertext security

ExpIND

E,A (n):

1 k ← Gen(1n) 2 m0, m1 ← A(1n) with m0, m1 ∈ M ∧ |m0| = |m1| 3 b ←R {0, 1}, c ← Enck(mb) 12 / 50

slide-30
SLIDE 30

Secret key encryption MAC

Attempt 2: Indistinguishable ciphertext security

ExpIND

E,A (n):

1 k ← Gen(1n) 2 m0, m1 ← A(1n) with m0, m1 ∈ M ∧ |m0| = |m1| 3 b ←R {0, 1}, c ← Enck(mb) 4 b′ ← A(c) 12 / 50

slide-31
SLIDE 31

Secret key encryption MAC

Attempt 2: Indistinguishable ciphertext security

ExpIND

E,A (n):

1 k ← Gen(1n) 2 m0, m1 ← A(1n) with m0, m1 ∈ M ∧ |m0| = |m1| 3 b ←R {0, 1}, c ← Enck(mb) 4 b′ ← A(c) 5 Output 1 if b′ = b, otherwise 0 12 / 50

slide-32
SLIDE 32

Secret key encryption MAC

Attempt 2: Indistinguishable ciphertext security

ExpIND

E,A (n):

1 k ← Gen(1n) 2 m0, m1 ← A(1n) with m0, m1 ∈ M ∧ |m0| = |m1| 3 b ←R {0, 1}, c ← Enck(mb) 4 b′ ← A(c) 5 Output 1 if b′ = b, otherwise 0

Definition (Indistinguishable ciphertexts (IND)) A secret key encryption scheme E has indistinguishable ciphertexts if for all efficient adversaries A their advantage ε in winning above game is negligible Pr

  • ExpIND

E,A (n) = 1

  • = 1

2 + ε. This definition is a lot easier to work with and equivalent to SEM!

12 / 50

slide-33
SLIDE 33

Secret key encryption MAC

Is IND efficiently achievable?

We first need tooling. Definition (Pseudorandom generator (PRG)) Let ℓ be a polynomial and let G be a deterministic, efficient algorithm that implements a function G : {0, 1}n → {0, 1}ℓ(n). We say G is a secure PRG if the following two conditions hold:

13 / 50

slide-34
SLIDE 34

Secret key encryption MAC

Is IND efficiently achievable?

We first need tooling. Definition (Pseudorandom generator (PRG)) Let ℓ be a polynomial and let G be a deterministic, efficient algorithm that implements a function G : {0, 1}n → {0, 1}ℓ(n). We say G is a secure PRG if the following two conditions hold:

1 Expansion: For every n it holds that ℓ(n) > n. 13 / 50

slide-35
SLIDE 35

Secret key encryption MAC

Is IND efficiently achievable?

We first need tooling. Definition (Pseudorandom generator (PRG)) Let ℓ be a polynomial and let G be a deterministic, efficient algorithm that implements a function G : {0, 1}n → {0, 1}ℓ(n). We say G is a secure PRG if the following two conditions hold:

1 Expansion: For every n it holds that ℓ(n) > n. 2 Pseudorandomness: For all efficient distinguishers D the

advantage ε distinguishing outputs of G from random is negligible, where ε =

  • Pr

r←R{0,1}ℓ(n) [D(r) = 1] −

Pr

s←R{0,1}n [D(G(s)) = 1]

  • .

13 / 50

slide-36
SLIDE 36

Secret key encryption MAC

Is IND efficiently achievable?

We first need tooling. Definition (Pseudorandom generator (PRG)) Let ℓ be a polynomial and let G be a deterministic, efficient algorithm that implements a function G : {0, 1}n → {0, 1}ℓ(n). We say G is a secure PRG if the following two conditions hold:

1 Expansion: For every n it holds that ℓ(n) > n. 2 Pseudorandomness: For all efficient distinguishers D the

advantage ε distinguishing outputs of G from random is negligible, where ε =

  • Pr

r←R{0,1}ℓ(n) [D(r) = 1] −

Pr

s←R{0,1}n [D(G(s)) = 1]

  • .

PRG’s exist if one-way functions exist. Will see examples later.

13 / 50

slide-37
SLIDE 37

Secret key encryption MAC

Is IND efficiently achievable?

Construction (PRG-ENC) Let n ∈ N be the security parameter, let M = {0, 1}ℓ(n)(= C), and let G be a PRG as defined above. The PRG-ENC encryption scheme consists of the following three algorithms: Gen(1n): Return k ←R {0, 1}n. Enck(m): Return c = m ⊕ G(k). Deck(c): Return m′ = c ⊕ G(k).

14 / 50

slide-38
SLIDE 38

Secret key encryption MAC

Is IND efficiently achievable?

Construction (PRG-ENC) Let n ∈ N be the security parameter, let M = {0, 1}ℓ(n)(= C), and let G be a PRG as defined above. The PRG-ENC encryption scheme consists of the following three algorithms: Gen(1n): Return k ←R {0, 1}n. Enck(m): Return c = m ⊕ G(k). Deck(c): Return m′ = c ⊕ G(k). Correctness Deck(Enck(m)) = (m ⊕ G(k)) ⊕ G(k) = m

14 / 50

slide-39
SLIDE 39

Secret key encryption MAC

PRG-ENC is IND secure

Proof by reduction. If there exists A that can distinguish ciphertexts of PRG-ENC in time t with advantage ε then the following algorithm D runs in time ≈ t and succeeds in distinguishing G with advantage ε′ = ε.

15 / 50

slide-40
SLIDE 40

Secret key encryption MAC

PRG-ENC is IND secure

Proof by reduction. If there exists A that can distinguish ciphertexts of PRG-ENC in time t with advantage ε then the following algorithm D runs in time ≈ t and succeeds in distinguishing G with advantage ε′ = ε. Construction (Distinguisher D) Given as input a string w ∈ {0, 1}ℓ(n):

1 Run m0, m1 ← A(1n) 2 Set b ←R {0, 1}, c = mb ⊕ w 3 Run b′ ← A(c) 4 Return 1 if b = b′, otherwise 0. 15 / 50

slide-41
SLIDE 41

Secret key encryption MAC

Advantage of D

Construction (Distinguisher D) Given as input a string w ∈ {0, 1}ℓ(n):

1 Run m0, m1 ← A(1n) 2 Set b ←R {0, 1}, c = mb ⊕ w 3 Run b′ ← A(c) 4 Return 1 if b = b′, otherwise 0.

ε′ = |Pr [D(r) = 1] − Pr [D(G(s)) = 1]|

16 / 50

slide-42
SLIDE 42

Secret key encryption MAC

Advantage of D

Construction (Distinguisher D) Given as input a string w ∈ {0, 1}ℓ(n):

1 Run m0, m1 ← A(1n) 2 Set b ←R {0, 1}, c = mb ⊕ w 3 Run b′ ← A(c) 4 Return 1 if b = b′, otherwise 0.

ε′ = |Pr [D(r) = 1] − Pr [D(G(s)) = 1]| Pr [D(r) = 1] = Pr

  • ExpIND

OTP,A (n) = 1

  • = 1

2

16 / 50

slide-43
SLIDE 43

Secret key encryption MAC

Advantage of D

Construction (Distinguisher D) Given as input a string w ∈ {0, 1}ℓ(n):

1 Run m0, m1 ← A(1n) 2 Set b ←R {0, 1}, c = mb ⊕ w 3 Run b′ ← A(c) 4 Return 1 if b = b′, otherwise 0.

ε′ = |Pr [D(r) = 1] − Pr [D(G(s)) = 1]| Pr [D(r) = 1] = Pr

  • ExpIND

OTP,A (n) = 1

  • = 1

2 Pr [D(G(s)) = 1] = Pr

  • ExpIND

PRG−ENC,A (n) = 1

  • = 1

2 + ε

16 / 50

slide-44
SLIDE 44

Secret key encryption MAC

Advantage of D

Construction (Distinguisher D) Given as input a string w ∈ {0, 1}ℓ(n):

1 Run m0, m1 ← A(1n) 2 Set b ←R {0, 1}, c = mb ⊕ w 3 Run b′ ← A(c) 4 Return 1 if b = b′, otherwise 0.

ε′ = |Pr [D(r) = 1] − Pr [D(G(s)) = 1]| Pr [D(r) = 1] = Pr

  • ExpIND

OTP,A (n) = 1

  • = 1

2 Pr [D(G(s)) = 1] = Pr

  • ExpIND

PRG−ENC,A (n) = 1

  • = 1

2 + ε ε′ =

  • 1

2 − 1 2 + ε

  • = ε

16 / 50

slide-45
SLIDE 45

Secret key encryption MAC

PRG-ENC is IND secure

Theorem If there exists A that can distinguish ciphertexts of PRG-ENC in time t with advantage ε then the algorithm D from above runs in time ≈ t and succeeds in breaking G with advantage ε′ = ε. Hence, if G is a secure PRG, then PRG-ENC has indistinguishable ciphertexts.

17 / 50

slide-46
SLIDE 46

Secret key encryption MAC

What did we achieve?

SEM, IND, and perfect secrecy define A’s goal

18 / 50

slide-47
SLIDE 47

Secret key encryption MAC

What did we achieve?

SEM, IND, and perfect secrecy define A’s goal What about A’s attack capabilities?

18 / 50

slide-48
SLIDE 48

Secret key encryption MAC

What did we achieve?

SEM, IND, and perfect secrecy define A’s goal What about A’s attack capabilities? In this sense they are unrealistic single message notions.

18 / 50

slide-49
SLIDE 49

Secret key encryption MAC

Is this realistic?

19 / 50

slide-50
SLIDE 50

Secret key encryption MAC

Or rather this.

20 / 50

slide-51
SLIDE 51

Secret key encryption MAC

What can A learn?

Often messages follow known format (MIME, HTML, XML,. . . ).

21 / 50

slide-52
SLIDE 52

Secret key encryption MAC

What can A learn?

Often messages follow known format (MIME, HTML, XML,. . . ). Often parts of messages are guessable:

“To whom it may concern,” “Dear [Recipient],” “Best regards, \n [Sender]” “Cheers, \n [Sender]”

21 / 50

slide-53
SLIDE 53

Secret key encryption MAC

What can A learn?

Often messages follow known format (MIME, HTML, XML,. . . ). Often parts of messages are guessable:

“To whom it may concern,” “Dear [Recipient],” “Best regards, \n [Sender]” “Cheers, \n [Sender]”

Want to model the worst case: Let A choose messages that get encrypted!

21 / 50

slide-54
SLIDE 54

Secret key encryption MAC

IND under chosen plaintext attacks (IND-CPA)

22 / 50

slide-55
SLIDE 55

Secret key encryption MAC

IND under chosen plaintext attacks (IND-CPA).

ExpIND−CPA

E,A

(n):

1 k ← Gen(1n) 2 m0, m1 ← AEnck(·)(1n) with m0, m1 ∈ M ∧ |m0| = |m1| 3 b ←R {0, 1}, c ← Enck(mb) 4 b′ ← AEnck(·)(c) 5 Output 1 if b′ = b, otherwise 0 23 / 50

slide-56
SLIDE 56

Secret key encryption MAC

IND under chosen plaintext attacks (IND-CPA).

ExpIND−CPA

E,A

(n):

1 k ← Gen(1n) 2 m0, m1 ← AEnck(·)(1n) with m0, m1 ∈ M ∧ |m0| = |m1| 3 b ←R {0, 1}, c ← Enck(mb) 4 b′ ← AEnck(·)(c) 5 Output 1 if b′ = b, otherwise 0

Definition (IND-CPA) A secret key encryption scheme E has indistinguishable ciphertexts under chosen plaintext attacks if for all efficient adversaries A their advantage ε in winning above game is negligible Pr

  • ExpIND−CPA

E,A

(n) = 1

  • ≤ 1

2 + ε.

23 / 50

slide-57
SLIDE 57

Secret key encryption MAC

IND under chosen plaintext attacks (IND-CPA).

ExpIND−CPA

E,A

(n):

1 k ← Gen(1n) 2 m0, m1 ← AEnck(·)(1n) with m0, m1 ∈ M ∧ |m0| = |m1| 3 b ←R {0, 1}, c ← Enck(mb) 4 b′ ← AEnck(·)(c) 5 Output 1 if b′ = b, otherwise 0

Definition (IND-CPA) A secret key encryption scheme E has indistinguishable ciphertexts under chosen plaintext attacks if for all efficient adversaries A their advantage ε in winning above game is negligible Pr

  • ExpIND−CPA

E,A

(n) = 1

  • ≤ 1

2 + ε. Note: This definition is equivalent to SEM-CPA.

23 / 50

slide-58
SLIDE 58

Secret key encryption MAC

IND-CPA secure SKE

Is the one-time pad IND-CPA-secure?

24 / 50

slide-59
SLIDE 59

Secret key encryption MAC

IND-CPA secure SKE

Is the one-time pad IND-CPA-secure? What about PRG-ENC?

24 / 50

slide-60
SLIDE 60

Secret key encryption MAC

IND-CPA secure SKE

Is the one-time pad IND-CPA-secure? What about PRG-ENC? Theorem A deterministic encryption scheme cannot be IND-CPA secure.

24 / 50

slide-61
SLIDE 61

Secret key encryption MAC

IND-CPA secure SKE

Is the one-time pad IND-CPA-secure? What about PRG-ENC? Theorem A deterministic encryption scheme cannot be IND-CPA secure. Proof idea. Send m0 to Enck(·) and compare result with challenge ciphertext.

24 / 50

slide-62
SLIDE 62

Secret key encryption MAC

Pseudorandom function families

A keyed function is a two input function F : K × X → Y where the first input is called the key and denoted k. We will write Fk(x) def = F(k, x).

25 / 50

slide-63
SLIDE 63

Secret key encryption MAC

Pseudorandom function families

A keyed function is a two input function F : K × X → Y where the first input is called the key and denoted k. We will write Fk(x) def = F(k, x). Definition (Pseudorandom function family (PRF)) Let F : {0, 1}n × {0, 1}n → {0, 1}n be an efficient, length-preserving, keyed function. We say F is a pseudorandom function if for all efficient distinguishers D the distinguishing advantage ε is negligible, where ε =

  • Pr

k←R{0,1}n

  • DFk(·)(1n) = 1

Pr

fn←RFUNCn

  • Dfn(·)(1n) = 1
  • .

25 / 50

slide-64
SLIDE 64

Secret key encryption MAC

Pseudorandom function families

A keyed function is a two input function F : K × X → Y where the first input is called the key and denoted k. We will write Fk(x) def = F(k, x). Definition (Pseudorandom function family (PRF)) Let F : {0, 1}n × {0, 1}n → {0, 1}n be an efficient, length-preserving, keyed function. We say F is a pseudorandom function if for all efficient distinguishers D the distinguishing advantage ε is negligible, where ε =

  • Pr

k←R{0,1}n

  • DFk(·)(1n) = 1

Pr

fn←RFUNCn

  • Dfn(·)(1n) = 1
  • .

PRF’s exist if PRG’s exist [GGM’84]. For length doubling PRG G define Fk(x) def = G

  • . . . G (G(k)x1)x2 . . .
  • xn .

25 / 50

slide-65
SLIDE 65

Secret key encryption MAC

Pseudorandom permutation families

Formal model for block ciphers is PRP. Definition (Pseudorandom permutation family (PRP)) Let n ∈ N be the security parameter, F : {0, 1}n × {0, 1}n → {0, 1}n be an efficient, length-preserving, keyed permutation. We say F is a family of pseudorandom permutations (PRP) if for all efficient distinguishers D the distinguishing advantage ε is negligible, where ε =

  • Pr

k←R{0,1}n

  • DFk(·),F −1

k

(·)(1n) = 1

Pr

fn←RPermn

  • Dfn(·),f −1

n

(·)(1n) = 1

  • ,

where Permn denotes the set of all permutations over {0, 1}n. A PRP is a PRF (Switching-Lemma) but not vice-versa.

26 / 50

slide-66
SLIDE 66

Secret key encryption MAC

IND-CPA-secure SKE

Construction (PRF-ENC) Let n ∈ N be the security parameter, let M = {0, 1}n(= C = K), and let F be a length-preserving PRF as defined above. The PRF-ENC encryption scheme consists of the following three algorithms: Gen(1n): Return k ←R {0, 1}n. Enck(m): Sample r ←R {0, 1}n, compute ¯ c = m ⊕ Fk(r), and return c = r, ¯ c. Deck(c): Parse c as r, ¯

  • c. Return m′ = ¯

c ⊕ Fk(r).

27 / 50

slide-67
SLIDE 67

Secret key encryption MAC

IND-CPA-secure SKE

Construction (PRF-ENC) Let n ∈ N be the security parameter, let M = {0, 1}n(= C = K), and let F be a length-preserving PRF as defined above. The PRF-ENC encryption scheme consists of the following three algorithms: Gen(1n): Return k ←R {0, 1}n. Enck(m): Sample r ←R {0, 1}n, compute ¯ c = m ⊕ Fk(r), and return c = r, ¯ c. Deck(c): Parse c as r, ¯

  • c. Return m′ = ¯

c ⊕ Fk(r). Correctness Deck(Enck(m)) = (m ⊕ Fk(r)) ⊕ Fk(r) = m

27 / 50

slide-68
SLIDE 68

Secret key encryption MAC

PRF-ENC is IND-CPA secure

Proof idea. Similar to PRG-ENC. Given A that breaks IND-CPA

  • f PRF-ENC in time t, with advantage ε then the following

algorithm D runs in time ≈ t and succeeds in distinguishing F with advantage ε′ ≈ ε.

28 / 50

slide-69
SLIDE 69

Secret key encryption MAC

PRF-ENC is IND-CPA secure

Proof idea. Similar to PRG-ENC. Given A that breaks IND-CPA

  • f PRF-ENC in time t, with advantage ε then the following

algorithm D runs in time ≈ t and succeeds in distinguishing F with advantage ε′ ≈ ε. Construction (Distinguisher D) Given access to oracle O : {0, 1}n → {0, 1}n:

1 Run m0, m1 ← AEnc′(·)(1n) 2 Set b ←R {0, 1}, r∗ ←R {0, 1}n, ¯

c∗ = mb ⊕ O(r∗)

3 Run b′ ← AEnc′(·)(r∗, ¯

c∗)

4 Return 1 if b = b′, otherwise 0

where Enc′(·) computes r ←R {0, 1}n, ¯ c = mb ⊕ O(r) and returns r, ¯ c.

28 / 50

slide-70
SLIDE 70

Secret key encryption MAC

Advantage of D

Construction (Distinguisher D) Given access to oracle O : {0, 1}n → {0, 1}n:

2 Set b ←R {0, 1}, r∗ ←R {0, 1}n, ¯

c∗ = mb ⊕ O(r∗) where Enc′(·) computes r ←R {0, 1}n, ¯ c = mb ⊕ O(r) and returns r, ¯ c. ε′ =

  • Pr

k←R{0,1}n

  • DFk(·)(1n) = 1

Pr

fn←RFUNCn

  • Dfn(·)(1n) = 1
  • 29 / 50
slide-71
SLIDE 71

Secret key encryption MAC

Advantage of D

Construction (Distinguisher D) Given access to oracle O : {0, 1}n → {0, 1}n:

2 Set b ←R {0, 1}, r∗ ←R {0, 1}n, ¯

c∗ = mb ⊕ O(r∗) where Enc′(·) computes r ←R {0, 1}n, ¯ c = mb ⊕ O(r) and returns r, ¯ c. ε′ =

  • Pr

k←R{0,1}n

  • DFk(·)(1n) = 1

Pr

fn←RFUNCn

  • Dfn(·)(1n) = 1
  • =
  • Pr
  • ExpIND−CPA

PRF−ENC,A (n) = 1

  • − Pr
  • ExpIND−CPA
  • PRF−ENC,A (n) = 1
  • 29 / 50
slide-72
SLIDE 72

Secret key encryption MAC

Advantage of D

Construction (Distinguisher D) Given access to oracle O : {0, 1}n → {0, 1}n:

2 Set b ←R {0, 1}, r∗ ←R {0, 1}n, ¯

c∗ = mb ⊕ O(r∗) where Enc′(·) computes r ←R {0, 1}n, ¯ c = mb ⊕ O(r) and returns r, ¯ c. ε′ =

  • Pr

k←R{0,1}n

  • DFk(·)(1n) = 1

Pr

fn←RFUNCn

  • Dfn(·)(1n) = 1
  • =
  • Pr
  • ExpIND−CPA

PRF−ENC,A (n) = 1

  • − Pr
  • ExpIND−CPA
  • PRF−ENC,A (n) = 1
  • =
  • 1

2 + ε − 1 2 + q 2n

  • =
  • ε − q

2n

  • 29 / 50
slide-73
SLIDE 73

Secret key encryption MAC

PRF-ENC is IND-CPA secure

Theorem If there exists A that can distinguish ciphertexts of PRF-ENC during a CPA-experiment in time t with advantage ε then the algorithm D from above runs in time ≈ t and succeeds in breaking F with advantage ε′ ≥ ε − q/2n. Hence, if F is a secure PRF, then PRF-ENC has indistinguishable ciphertexts under chosen plaintext attacks.

30 / 50

slide-74
SLIDE 74

Secret key encryption MAC

Arbitrary length messages

PRF-ENC only works for n-bit messages.

31 / 50

slide-75
SLIDE 75

Secret key encryption MAC

Arbitrary length messages

PRF-ENC only works for n-bit messages. Can repeat fixed-length scheme: For ℓn-bit message m = (m1m2 . . . mℓ) ciphertext is c = r1, Fk(r1) ⊕ m1, r2, Fk(r2) ⊕ m2, . . . , rℓ, Fk(rℓ) ⊕ mℓ

31 / 50

slide-76
SLIDE 76

Secret key encryption MAC

Arbitrary length messages

PRF-ENC only works for n-bit messages. Can repeat fixed-length scheme: For ℓn-bit message m = (m1m2 . . . mℓ) ciphertext is c = r1, Fk(r1) ⊕ m1, r2, Fk(r2) ⊕ m2, . . . , rℓ, Fk(rℓ) ⊕ mℓ Pretty inefficient! Solution: Modes of operation

31 / 50

slide-77
SLIDE 77

Secret key encryption MAC

Electronic code book mode (ECB)

32 / 50

slide-78
SLIDE 78

Secret key encryption MAC

Electronic code book mode (ECB)

Deterministic! Even worse, not even IND for single message attacks! (Consider m0 = mm; m1 = mm′ for m, m′ ∈ {0, 1}n)

32 / 50

slide-79
SLIDE 79

Secret key encryption MAC

Cipher block chaining mode (CBC)

33 / 50

slide-80
SLIDE 80

Secret key encryption MAC

Cipher block chaining mode (CBC)

IND-CPA if F is a PRP. IV has to be random, if it is predictable CBC is vulnerable!

33 / 50

slide-81
SLIDE 81

Secret key encryption MAC

Counter mode (CTR)

34 / 50

slide-82
SLIDE 82

Secret key encryption MAC

Counter mode (CTR)

IND-CPA if F is a PRF.

34 / 50

slide-83
SLIDE 83

Secret key encryption MAC

What about active attacks?

A might be able to learn decryption of ciphertexts at a later point by compromising the system.

35 / 50

slide-84
SLIDE 84

Secret key encryption MAC

What about active attacks?

A might be able to learn decryption of ciphertexts at a later point by compromising the system. A might even get access to a decryption oracle (lunch time attack).

35 / 50

slide-85
SLIDE 85

Secret key encryption MAC

What about active attacks?

A might be able to learn decryption of ciphertexts at a later point by compromising the system. A might even get access to a decryption oracle (lunch time attack). Want to model the worst case: Let A choose ciphertexts that get decrypted!

35 / 50

slide-86
SLIDE 86

Secret key encryption MAC

IND under chosen ciphertext attacks

ExpIND−CCA

E,A

(n):

1 k ← Gen(1n) 2 m0, m1 ← AEnck(·),Deck(·)(1n) with m0, m1 ∈ M ∧ |m0 = m1| 3 b ←R {0, 1}, c∗ ← Enck(mb) 4 b′ ← AEnck(·),Deck(·)(c∗) with Deck(c∗) = ⊥ 5 Output 1 if b′ = b, otherwise 0 36 / 50

slide-87
SLIDE 87

Secret key encryption MAC

IND under chosen ciphertext attacks

ExpIND−CCA

E,A

(n):

1 k ← Gen(1n) 2 m0, m1 ← AEnck(·),Deck(·)(1n) with m0, m1 ∈ M ∧ |m0 = m1| 3 b ←R {0, 1}, c∗ ← Enck(mb) 4 b′ ← AEnck(·),Deck(·)(c∗) with Deck(c∗) = ⊥ 5 Output 1 if b′ = b, otherwise 0

Definition (IND-CCA) A secret key encryption scheme E has indistinguishable ciphertexts under chosen ciphertext attacks if for all efficient adversaries A their advantage ε in winning above game is negligible Pr

  • ExpIND−CCA

E,A

(n) = 1

  • ≤ 1

2 + ε.

36 / 50

slide-88
SLIDE 88

Secret key encryption MAC

IND under chosen ciphertext attacks

ExpIND−CCA

E,A

(n):

1 k ← Gen(1n) 2 m0, m1 ← AEnck(·),Deck(·)(1n) with m0, m1 ∈ M ∧ |m0 = m1| 3 b ←R {0, 1}, c∗ ← Enck(mb) 4 b′ ← AEnck(·),Deck(·)(c∗) with Deck(c∗) = ⊥ 5 Output 1 if b′ = b, otherwise 0

Definition (IND-CCA) A secret key encryption scheme E has indistinguishable ciphertexts under chosen ciphertext attacks if for all efficient adversaries A their advantage ε in winning above game is negligible Pr

  • ExpIND−CCA

E,A

(n) = 1

  • ≤ 1

2 + ε. This definition is equivalent to SEM-CCA.

36 / 50

slide-89
SLIDE 89

Secret key encryption MAC

MAC

37 / 50

slide-90
SLIDE 90

Secret key encryption MAC

Message authentication

Sometimes we want more than secrecy! Acknowledgement of receipt, social communication, source of executable, . . .

38 / 50

slide-91
SLIDE 91

Secret key encryption MAC

Message authentication

Sometimes we want more than secrecy! Acknowledgement of receipt, social communication, source of executable, . . . We need integrity and authenticity!

38 / 50

slide-92
SLIDE 92

Secret key encryption MAC

Message authentication

Sometimes we want more than secrecy! Acknowledgement of receipt, social communication, source of executable, . . . We need integrity and authenticity! Encryption

?

⇒ Authenticity / integrity?

38 / 50

slide-93
SLIDE 93

Secret key encryption MAC

Message authentication

Sometimes we want more than secrecy! Acknowledgement of receipt, social communication, source of executable, . . . We need integrity and authenticity! Encryption

?

⇒ Authenticity / integrity?

PRG-ENC, PRF-ENC, ... any stream cipher allows controlled bit-flips. If format is known this may be disastrous Block ciphers make similar attacks harder but no guarantees. ECB-mode allows to switch order of blocks, repeat blocks, etc.

38 / 50

slide-94
SLIDE 94

Secret key encryption MAC

MAC

39 / 50

slide-95
SLIDE 95

Secret key encryption MAC

Message authentication codes (MAC)

Definition (message authentication code) A message authentication code or MAC is a tuple of probabilistic polynomial-time algorithms MAC = (Gen, Mac, Vrfy) over a message space M, fulfilling the following: Gen is a probabilistic algorithm that on input 1n outputs a key k. The output space of Gen is called the key space K. Mac takes as input a key k ∈ K and a message m ∈ M, and outputs a tag t ∈ T . The output space of Mac is called tag space T . Vrfy is a deterministic algorithm that takes as inputs a key k ∈ K, a message m ∈ M, and a tag t ∈ T , and

  • utputs a bit b ∈ {0, 1}.

Correctness: For every n, every k ← Gen(1n), and every m ∈ M it holds that Vrfyk(m, Mack(m)) = 1.

40 / 50

slide-96
SLIDE 96

Secret key encryption MAC

Existential unforgeability under (adaptive) chosen message attacks (EU-CMA)

41 / 50

slide-97
SLIDE 97

Secret key encryption MAC

Existential unforgeability under (adaptive) chosen message attacks (EU-CMA)

ExpEU−CMA

MAC,A

(n)

1 k ← Gen(1n) 2 (m, t) ← AMack(·)(1n). Let {mi}q

1 denote A’s queries to

Mack

3 If Vrfyk(m, t) := 1 and m ∈ {mi}q

1 return 1

4 Else return 0. 42 / 50

slide-98
SLIDE 98

Secret key encryption MAC

Existential unforgeability under (adaptive) chosen message attacks (EU-CMA)

Definition (EU-CMA) A message authentication code MAC = (Gen, Mac, Vrfy) over a message space M is existentially unforgeable under an adaptive chosen-message attack, or just secure, if for all efficient adversaries A the success probability ε in winning ExpEU−CMA

MAC,A

(n) is negligible, where ε = Pr

  • ExpEU−CMA

MAC,A

(n) = 1

  • 43 / 50
slide-99
SLIDE 99

Secret key encryption MAC

Remarks

There exists a constant time attack with success probability 1/|T | against every MAC ⇒ Tags must not be too short

44 / 50

slide-100
SLIDE 100

Secret key encryption MAC

Remarks

There exists a constant time attack with success probability 1/|T | against every MAC ⇒ Tags must not be too short MAC’s do not prevent replay attacks! Replay attacks have to be handled on protocol level (e.g., using sequence numbers).

44 / 50

slide-101
SLIDE 101

Secret key encryption MAC

PRF is a MAC

Theorem A secure PRF F leads a secure MAC with Gen(1n) returns k ←R {0, 1}n. Mack(m) returns t = Fk(m). Vrfyk(m, t) returns 1 if t = Fk(m), and 0 otherwise. Proof idea Build distinguisher that simulates experiment using its oracle instead of F. A valid forgery must be on a new message. So if

  • racle is random, tag is a correct guess for a random function at

some point m that was not queried. If A succeeds more often when the oracle was F, this allows to distinguish F as for PRF-ENC.

45 / 50

slide-102
SLIDE 102

Secret key encryption MAC

CBC-MAC

Construction Let F be an efficient, length-preserving keyed function over {0, 1}n. CBC-MAC has message space M = ({0, 1}ℓn). The algorithms are as follows: Gen(1n) returns k ←R {0, 1}n. Mack(m) upon input key k ∈ {0, 1}n and a message m of length ℓn, do the following:

1 Denote m = m1, . . . , mℓ where each mi is of

length n, and set t0 = 0n.

2 For i = 1 to ℓ, set ti ← Fk(ti−1 ⊕ mi). 3 Output tℓ.

Vrfyk(m, t) returns 1 if t = Mack(m), and 0 otherwise.

46 / 50

slide-103
SLIDE 103

Secret key encryption MAC

Variable message length CBC-MAC

CBC-MAC is not secure for variable length messages

47 / 50

slide-104
SLIDE 104

Secret key encryption MAC

Variable message length CBC-MAC

CBC-MAC is not secure for variable length messages Solutions for variable ℓ: Derived key: Compute k′ = Fk(ℓ) and use k′ to compute t = Mack′(m) Prepend length: Compute t = Mack(ℓm). Encrypted tag: Use two keys k1, k2 ∈ {0, 1}n, compute t′ = Mack1(m) and output t = Fk2(t′). We can generate k1, k2 from a single key using F as a length-doubling PRG (< k1, k2 >=< Fk(0), Fk(1) >)

47 / 50

slide-105
SLIDE 105

Secret key encryption MAC

Padding

What if the message length is not a multiple of the block length: |m| = x · n?

48 / 50

slide-106
SLIDE 106

Secret key encryption MAC

Padding

What if the message length is not a multiple of the block length: |m| = x · n? Solution: Padding Expand message to match multiple of block length. Usually injective function Pad : {0, 1}∗ → ({0, 1}n)∗. E.g., m → m10∗. Properties depend on cryptographic application:

Encryption - invertible MAC - injective

Often used for additional purposes: Randomization, or encoding message length.

48 / 50

slide-107
SLIDE 107

Secret key encryption MAC

Secrecy + Authenticity

We actually want IND-CCA and EU-CMA security of our connections.

49 / 50

slide-108
SLIDE 108

Secret key encryption MAC

Secrecy + Authenticity

We actually want IND-CCA and EU-CMA security of our connections. Options: Encrypt-and-MAC: c = Enck1(m), t = Mack2(m). MAC-then-Encrypt. t = Mack2(m), c = Enck1(mt). Encrypt-then-MAC. c = Enck1(m), t = Mack2(c).

49 / 50

slide-109
SLIDE 109

Secret key encryption MAC

Secrecy + Authenticity

We actually want IND-CCA and EU-CMA security of our connections. Options: Encrypt-and-MAC: c = Enck1(m), t = Mack2(m). Possibly insecure as MAC might leak! MAC-then-Encrypt. t = Mack2(m), c = Enck1(mt). Encrypt-then-MAC. c = Enck1(m), t = Mack2(c).

49 / 50

slide-110
SLIDE 110

Secret key encryption MAC

Secrecy + Authenticity

We actually want IND-CCA and EU-CMA security of our connections. Options: Encrypt-and-MAC: c = Enck1(m), t = Mack2(m). Possibly insecure as MAC might leak! MAC-then-Encrypt. t = Mack2(m), c = Enck1(mt). Possibly insecure but counter-examples are more involved Encrypt-then-MAC. c = Enck1(m), t = Mack2(c).

49 / 50

slide-111
SLIDE 111

Secret key encryption MAC

Secrecy + Authenticity

We actually want IND-CCA and EU-CMA security of our connections. Options: Encrypt-and-MAC: c = Enck1(m), t = Mack2(m). Possibly insecure as MAC might leak! MAC-then-Encrypt. t = Mack2(m), c = Enck1(mt). Possibly insecure but counter-examples are more involved Encrypt-then-MAC. c = Enck1(m), t = Mack2(c). Secure! (And the generic way to turn an IND-CPA secure encryption into an IND-CCA secure one.)

49 / 50

slide-112
SLIDE 112

Secret key encryption MAC

Secrecy + Authenticity

We actually want IND-CCA and EU-CMA security of our connections. Options: Encrypt-and-MAC: c = Enck1(m), t = Mack2(m). Possibly insecure as MAC might leak! MAC-then-Encrypt. t = Mack2(m), c = Enck1(mt). Possibly insecure but counter-examples are more involved Encrypt-then-MAC. c = Enck1(m), t = Mack2(c). Secure! (And the generic way to turn an IND-CPA secure encryption into an IND-CCA secure one.) Or the most simple one: Use Authenticated encryption (AE)!

49 / 50

slide-113
SLIDE 113

Secret key encryption MAC

Conclusion

We covered secret key encryption schemes and their security. We covered message authentication codes and their security. On the way we looked at PRFs and PRGs. I skipped cryptographic hash functions due to time. Will be covered by Gilles and in my lecture Friday afternoon.

50 / 50

slide-114
SLIDE 114

Secret key encryption MAC

Conclusion

We covered secret key encryption schemes and their security. We covered message authentication codes and their security. On the way we looked at PRFs and PRGs. I skipped cryptographic hash functions due to time. Will be covered by Gilles and in my lecture Friday afternoon. Thank you! Questions?

50 / 50