18
SYMMETRIC ENCRYPTION Mihir Bellare UCSD 1 Syntax A symmetric encryption scheme SE =(K, E , D) consists of three algorithms: K and E may be randomized, but D must be deterministic. Mihir Bellare UCSD 2 Correct decryption requirement More formally: For all keys K that may be output by K, and for all M in the message space, we have Pr [D K (E K (M)) = M]=1 , where the probability is over the coins of E . A scheme will usually specify an associated message space. Mihir Bellare UCSD 3 Modes of operation E : {0, 1} k {0, 1} n ! {0, 1} ` a family of functions Usually a block cipher, in which case ` = n. Notation: x [i ] is the i-th block of a string x, so that x = x [1] ... x [m]. Length of blocks varies. Always: Alg K K $ {0, 1} k return K Mihir Bellare UCSD 4

SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

SYMMETRIC ENCRYPTION

Mihir Bellare UCSD 1

Syntax

A symmetric encryption scheme SE = (K, E ,D) consists of threealgorithms:

K and E may be randomized, but D must be deterministic.

Mihir Bellare UCSD 2

Correct decryption requirement

More formally: For all keys K that may be output by K, and for all M inthe message space, we have

Pr [DK (EK (M)) = M] = 1 ,

where the probability is over the coins of E .

A scheme will usually specify an associated message space.

Mihir Bellare UCSD 3

Modes of operation

E : {0, 1}k ⇥ {0, 1}n ! {0, 1}` a family of functions

Usually a block cipher, in which case ` = n.

Notation: x [i ] is the i-th block of a string x, so that x = x [1] . . . x [m].Length of blocks varies.

Always:

Alg K

K$ {0, 1}k

return K

Mihir Bellare UCSD 4

Page 2: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

Modes of operation

Block cipher provides parties sharing K with

EK

M

C

which enables them to encrypt a 1-block message.

How do we encrypt a long message using a primitive that only applies ton-bit blocks?

Mihir Bellare UCSD 5

ECB: Electronic Codebook Mode

SE = (K, E ,D) where:

Alg EK (M)

for i = 1, . . . ,m doC [i ] EK (M[i ])

return C

Alg DK (C )

for i = 1, . . . ,m doM[i ] E

�1K (C [i ])

return M

Correct decryption relies on E being a block cipher, so that EK is invertible

Mihir Bellare UCSD 6

Security of ECB

Weakness: M1 = M2 ) C1 = C2

Why is the above true? Because EK is deterministic:

EK. . .EK

M1[1] M1[m]

C1[1] C1[m]

EK EK. . .

M2[1] M2[m]

C2[1] C2[m]

Why does this matter?

Mihir Bellare UCSD 7

Security of ECB

Suppose we know that there are only two possible messages, Y = 1n andN = 0n, for example representing

• FIRE or DON’T FIRE a missile• BUY or SELL a stock• Vote YES or NO

Then ECB algorithm will be EK (M) = EK (M).

EK

M

C

Mihir Bellare UCSD 8

Page 3: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

Security of ECB

Votes M1,M2 2 {Y ,N} are ECB encrypted and adversary sees ciphertextsC1 = EK (M1) and C2 = EK (M2)

EK

C1

M1

EK

M2

C2

Adversary may have cast the first vote and thus knows M1; say M1 = Y .Then adversary can figure out M2:

• If C2 = C1 then M2 must be Y

• Else M2 must be N

Mihir Bellare UCSD 9

Is this avoidable?

Let SE = (K, E ,D) be ANY encryption scheme.

Suppose M1,M2 2 {Y ,N} and

• Sender sends ciphertexts C1 EK (M1) and C2 EK (M2)

• Adversary A knows that M1 = Y

Adversary says: If C2 = C1 then M2 must be Y else it must be N.

Does this attack work?

Yes, if E is deterministic.

Mihir Bellare UCSD 10

Is this avoidable?

Let SE = (K, E ,D) be ANY encryption scheme.

Suppose M1,M2 2 {Y ,N} and

• Sender sends ciphertexts C1 EK (M1) and C2 EK (M2)

• Adversary A knows that M1 = Y

Adversary says: If C2 = C1 then M2 must be Y else it must be N.

Does this attack work?

Yes, if E is deterministic.

Mihir Bellare UCSD 11

Randomized encryption

For encryption to be secure it must be randomized

That is, algorithm EK flips coins.

If the same message is encrypted twice, we are likely to get back di↵erentanswers. That is, if M1 = M2 and we let

C1$ EK (M1) and C2

$ EK (M2)

thenPr [C1 = C2]

will (should) be small, where the probability is over the coins of E .

Mihir Bellare UCSD 12

Page 4: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

Randomized encryption

There are many possible ciphertexts corresponding to each message.

If so, how can we decrypt?

We will see examples soon.

EKM

C1

DK M

C2

Cs

Mihir Bellare UCSD 13

Randomized encryption

A fundamental departure from classical and conventional notions ofencryption.

Clasically, encryption (e.g., substitution cipher) is a code, associating toeach message a unique ciphertext.

Now, we are saying no such code is secure, and we look to encryptionmechanisms which associate to each message a number of di↵erentpossible ciphertexts.

Mihir Bellare UCSD 14

CBC$: Cipher Block Chaining with random IV mode

SE = (K, E ,D) where:

Alg EK (M)

C [0] $ {0, 1}n

for i = 1, . . . ,m doC [i ] EK (M[i ]� C [i � 1])

return C

Alg DK (C )

for i = 1, . . . ,m doM[i ] E

�1K (C [i ])� C [i � 1]

return M

Correct decryption relies on E being a block cipher.Mihir Bellare UCSD 15

CTR$ mode

Let E : {0, 1}k ⇥ {0, 1}n ! {0, 1}` be a family of functions. If X 2 {0, 1}n

and i 2 N then X + i denotes the n-bit string formed by converting X toan integer, adding i modulo 2n, and converting the result back to an n-bitstring. Below the message is a sequence of `-bit blocks:

Alg EK (M)

C [0] $ {0, 1}n

for i = 1, . . . ,m doP[i ] EK (C [0] + i)C [i ] P[i ]�M[i ]

return C

Alg DK (C )

for i = 1, . . . ,m doP[i ] EK (C [0] + i)M[i ] P[i ]� C [i ]

return M

Mihir Bellare UCSD 16

Page 5: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

CTR$ mode

Alg EK (M)

C [0] $ {0, 1}n

for i = 1, . . . ,m doP[i ] EK (C [0] + i)C [i ] P[i ]�M[i ]

return C

Alg DK (C )

for i = 1, . . . ,m doP[i ] EK (C [0] + i)M[i ] P[i ]� C [i ]

return M

• D does not use E�1K ! This is why CTR$ can use a family of functions

E that is not required to be a blockcipher.

• Encryption and Decryption are parallelizable.

Mihir Bellare UCSD 17

Voting with CBC$

Suppose we encrypt M1,M2 2 {Y ,N} with CBC$.

EK

M1

C1[1]{0, 1}n $! C1[0]

EK

M2

C2[1]{0, 1}n $! C2[0]

Adversary A sees C1 = C1[0]C1[1] and C2 = C2[0]C2[1].

Suppose A knows that M1 = Y .

Can A determine whether M2 = Y or M2 = N?

NO!

Mihir Bellare UCSD 18

Voting with CBC$

Suppose we encrypt M1,M2 2 {Y ,N} with CBC$.

EK

M1

C1[1]{0, 1}n $! C1[0]

EK

M2

C2[1]{0, 1}n $! C2[0]

Adversary A sees C1 = C1[0]C1[1] and C2 = C2[0]C2[1].

Suppose A knows that M1 = Y .

Can A determine whether M2 = Y or M2 = N?

NO!

Mihir Bellare UCSD 19

Assessing security

So CBC$ is better than ECB. But is it secure?

CBC$ is widely used so knowing whether it is secure is important

To answer this we first need to decide and formalize what we mean bysecure.

Mihir Bellare UCSD 20

Page 6: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

Security requirements

Suppose sender computes

C1$ EK (M1) ; · · · ; Cq

$ EK (Mq)

Adversary A has C1, . . . ,Cq

What if A

Retrieves K Bad!Retrieves M1 Bad!

But also we want to hide all partial information about the data stream,such as

• Does M1 = M2?

• What is first bit of M1?

• What is XOR of first bits of M1,M2?

Something we won’t hide: the length of the messageMihir Bellare UCSD 21

What we seek

We want a single “master” property MP of an encryption scheme suchthat

• MP can be easily specified

• We can evaluate whether a scheme meets it

• MP implies ALL the security conditions we want: it guarantees that aciphertext reveals NO partial information about the plaintext.

Mihir Bellare UCSD 22

Intuition for definition of IND-CPA

The master property MP is called IND-CPA (indistinguishability underchosen plaintext attack).

Consider encrypting one of two possible message streams, either

M10 , ...,M

q0

orM

11 , ...,M

q1 ,

where |Mi0| = |M

i1| for all 1 i q. Adversary, given ciphertexts C 1, . . . ,

Cq and both data streams, has to figure out which of the two streams was

encrypted.

We will even let the adversary pick the messages: It picks (M10 ,M

11 ) and

gets back C1, then picks (M2

0 ,M21 ) and gets back C

2, and so on.

Mihir Bellare UCSD 23

Games for ind-cpa-advantage of an adversary A

Let SE = (K, E ,D) be an encryption scheme

Game LeftSE

procedure InitializeK

$ K

procedure LR(M0,M1)

Return C$ EK (M0)

Game RightSEprocedure InitializeK

$ K

procedure LR(M0,M1)

Return C$ EK (M1)

Associated to SE ,A are the probabilities

PrhLeftASE)1

iPr

hRightASE)1

i

that A outputs 1 in each world. The (ind-cpa) advantage of A is

Advind-cpaSE (A) = PrhRightASE)1

i� Pr

hLeftASE)1

i

Mihir Bellare UCSD 24

Page 7: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

Message length restriction

It is required that |M0| = |M1| in any query M0,M1 that A makes to LR.An adversary A violating this condition is considered invalid.

This reflects that encryption is not aiming to hide the length of messages.

Mihir Bellare UCSD 25

The measure of success

Advind-cpaSE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure.

Advind-cpaSE (A) ⇡ 0 (or 0) means A is doing poorly and SE resists theattack A is mounting.

Adversary resources are its running time t and the number q of its oraclequeries, the latter representing the number of messages encrypted.

Security: SE is IND-CPA-secure if Advind-cpaSE (A) is “small” for ALL A

that use “practical” amounts of resources.

Insecurity: SE is not IND-CPA-secure if we can specify an explicit A thatuses “few” resources yet achieves “high” ind-cpa-advantage.

Mihir Bellare UCSD 26

ECB is not IND-CPA-secure

Let E : {0, 1}k ⇥ {0, 1}n ! {0, 1}n be a block cipher. Recall that ECBmode defines symmetric encryption scheme SE = (K, E ,D) with

EK (M) = EK (M[1])EK (M[2]) · · ·EK (M[m])

Can we design A so that

Advind-cpaSE (A) = PrhRightASE)1

i� Pr

hLeftASE)1

i

is close to 1?

Exploitable weakness of SE : M1 = M2 implies EK (M1) = EK (M2).

Mihir Bellare UCSD 27

ECB is not IND-CPA-secure

Let E : {0, 1}k ⇥ {0, 1}n ! {0, 1}n be a block cipher. Recall that ECBmode defines symmetric encryption scheme SE = (K, E ,D) with

EK (M) = EK (M[1])EK (M[2]) · · ·EK (M[m])

Can we design A so that

Advind-cpaSE (A) = PrhRightASE)1

i� Pr

hLeftASE)1

i

is close to 1?

Exploitable weakness of SE : M1 = M2 implies EK (M1) = EK (M2).

Mihir Bellare UCSD 28

Page 8: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

ECB is not IND-CPA-secure

Let EK (M) = EK (M[1]) · · ·EK (M[m]).

adversary A

C1 LR(0n, 0n) ; C2 LR(1n, 0n)if C1 = C2 then return 1 else return 0

Mihir Bellare UCSD 29

Right game analysis

E is defined by EK (M) = EK (M[1]) · · ·EK (M[m]).

adversary A

C1 LR(0n, 0n) ; C2 LR(1n, 0n)if C1 = C2 then return 1 else return 0

Game RightSEprocedure InitializeK

$ K

procedure LR(M0,M1)Return EK (M1)

ThenPr

hRightASE)1

i=

1

because C1 = EK (0n) and C2 = EK (0n).

Mihir Bellare UCSD 30

Right game analysis

E is defined by EK (M) = EK (M[1]) · · ·EK (M[m]).

adversary A

C1 LR(0n, 0n) ; C2 LR(1n, 0n)if C1 = C2 then return 1 else return 0

Game RightSEprocedure InitializeK

$ K

procedure LR(M0,M1)Return EK (M1)

ThenPr

hRightASE)1

i= 1

because C1 = EK (0n) and C2 = EK (0n).Mihir Bellare UCSD 31

Left game analysis

E is defined by EK (M) = EK (M[1]) · · ·EK (M[m]).

adversary A

C1 LR(0n, 0n) ; C2 LR(1n, 0n)if C1 = C2 then return 1 else return 0

Game LeftSE

procedure InitializeK

$ K

procedure LR(M0,M1)Return EK (M0)

ThenPr

hLeftASE)1

i=

0

because C1 = EK (0n) 6= EK (1n) = C2.

Mihir Bellare UCSD 32

Page 9: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

Left game analysis

E is defined by EK (M) = EK (M[1]) · · ·EK (M[m]).

adversary A

C1 LR(0n, 0n) ; C2 LR(1n, 0n)if C1 = C2 then return 1 else return 0

Game LeftSE

procedure InitializeK

$ K

procedure LR(M0,M1)Return EK (M0)

ThenPr

hLeftASE)1

i= 0

because C1 = EK (0n) 6= EK (1n) = C2.Mihir Bellare UCSD 33

ECB is not IND-CPA secure

adversary A

C1 LR(0n, 0n) ; C2 LR(1n, 0n)if C1 = C2 then return 1 else return 0

Advind-cpaSE (A) =

1z }| {Pr

hRightASE = 1

i�

0z }| {Pr

hLeftASE = 1

i

= 1

And A is very e�cient, making only two queries.

Thus ECB is not IND-CPA secure.

Mihir Bellare UCSD 34

Exercise

Let SE = (K, E ,D) be any symmetric encryption scheme for which E isdeterministic. Show that SE is not IND-CPA secure by givingpseudo-code for an e�cient adversary A that achieves

Advind-cpaSE (A) = 1 .

Assume the message space is {0, 1}⇤, meaning any string is a legitimatemessage.

Mihir Bellare UCSD 35

Exercise

Let K be the key-generation algorithm that returns a random 128-bitstring as the key K . Define

Alg EK (M)

R$ {0, 1}128; M[1] . . .M[m] M; C [0] R

for i = 1, . . . ,m doW [i ] (R + i) mod 2128; C [i ] AESK (M[i ] �W [i ])

C C [0]C [1] . . .C [n]; Return C

Above W [i ] (R + i) mod 2128 means we regard R as an integer, add i

to it, take the result modulo 2128, view this as a 128-bit string, and assignit to W [i ]. A message must be a string whose length is a positive multipleof 128.

Mihir Bellare UCSD 36

Page 10: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

Exercise

1. Specify a decryption algorithm D such that SE = (K, E ,D) is asymmetric encryption scheme satisfying the correct decryptioncondition.

2. Present in pseudocode a practical adversary A making one LR queryand achieving Advind-cpaSE (A) = 1.

There should be a succinct analysis justifying the claimed advantage.

Mihir Bellare UCSD 37

Why is IND-CPA the “master” property?

We claim that if encryption scheme SE = (K, E ,D) is IND-CPA securethen the ciphertext hides ALL partial information about the plaintext.

For example, from C1$ EK (M1) and C2

$ EK (M2) the adversary cannot

• get M1

• get 1st bit of M1

• get XOR of the 1st bits of M1,M2

• etc.

Exercise: State and prove such claims formally.

Mihir Bellare UCSD 38

Birthday attack on CTR$

Let E : {0, 1}k ⇥ {0, 1}n ! {0, 1}` be a family of functions and SE = (K,E ,D) the corresponding CTR$ symmetric encryption scheme. Suppose1-block messages M0,M1 are encrypted:

C0[0]C0[1]$ E(K ,M0) C1[0]C1[1]

$ E(K ,M1)

Let us say we are lucky If C0[0] = C1[0]. If so:

C0[1] = C1[1] if and only if M0 = M1

So if we are lucky we can detect message equality and violate IND-CPA.Mihir Bellare UCSD 39

Birthday attack on CTR$

Let 1 q < 2n be a parameter and let hii be integer i encoded as an `-bitstring.

adversary A

for i = 1, ..., q do

Ci [0]C i [1] $

LR(hii, h0i)S {(j , t) : C j [0] = C

t [0] and j < t}

If S 6= ;, then

(j , t) $ S

If C j [1] = Ct [1] then return 1

return 0

Mihir Bellare UCSD 40

Page 11: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

Birthday attack on CTR$: Right game analysis

adversary A

for i = 1, ..., q do

Ci [0]C i [1] $

LR(hii, h0i)S {(j , t) : C j [0] = C

t [0] and j < t}

If S 6= ;, then

(j , t) $ S

If C j [1] = Ct [1] then return 1

return 0

Game RightSEprocedure InitializeK

$ K

procedure LR(M0,M1)

C [0] $ {0, 1}n

P E (K ,C [0] + 1)C [1] P � M1

Return C [0]C [1]

If C j [0] = Ct [0] (lucky) then

Cj [1] = h0i � EK (C

j [0] + 1) = h0i � EK (Ct [0] + 1) = C

t [1]

soPr

hRightASE)1

i= Pr [S 6= ;] = C (2n, q)

Mihir Bellare UCSD 41

Birthday attack on CTR$: Left game analysis

adversary A

for i = 1, ..., q do

Ci [0]C i [1] $

LR(hii, h0i)S {(j , t) : C j [0] = C

t [0] and j < t}

If S 6= ;, then

(j , t) $ S

If C j [1] = Ct [1] then return 1

return 0

Game LeftSE

procedure InitializeK

$ K

procedure LR(M0,M1)

C [0] $ {0, 1}n

P E (K ,C [0] + 1)C [1] P � M0

Return C [0]C [1]

If C j [0] = Ct [0] (lucky) then

Cj [1] = hji � EK (C

j [0] + 1) 6= hti � EK (Ct [0] + 1) = C

t [1]

soPr

hLeftASE)1

i= 0.

Mihir Bellare UCSD 42

Birthday attack on CTR$

Advind-cpaSE (A) = PrhRightASE)1

i� Pr

hLeftASE)1

i

= C (2n, q)� 0 � 0.3 ·q(q � 1)

2n

Conclusion: CTR$ can be broken (in the IND-CPA sense) in about 2n/2

queries, where n is the block length of the underlying block cipher,regardless of the cryptanalytic strength of the block cipher.

Mihir Bellare UCSD 43

Exercise

The above attack on CTR$ uses 1-block messages. Letting SE be thesame scheme, give an adversary A that makes q LR-queries, eachconsisting of two m-block messages, and achieves

Advind-cpaSE (A) = ⌦

✓mq

2

2n

The running time of A should be about O(mq(n + `) · log(mq(n + `))).

Mihir Bellare UCSD 44

Page 12: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

Security of CTR$

So far: A q-query adversary can break CTR$ with advantage ⇡ q2

2n+1

Question: Is there any better attack?

Answer: NO!

We can prove that the best q-query attack short of breaking the blockcipher has advantage at most

2(q � 1)�

2n

where � is the total number of blocks across all messages encrypted.

Example: If q 1-block messages are encrypted then � = q so the adversaryadvantage is not more than 2q2/2n.

For E = AES this means up to about 264 blocks may be securelyencrypted, which is good.

Mihir Bellare UCSD 45

Security of CTR$

So far: A q-query adversary can break CTR$ with advantage ⇡ q2

2n+1

Question: Is there any better attack?

Answer: NO!

We can prove that the best q-query attack short of breaking the blockcipher has advantage at most

2(q � 1)�

2n

where � is the total number of blocks across all messages encrypted.

Example: If q 1-block messages are encrypted then � = q so the adversaryadvantage is not more than 2q2/2n.

For E = AES this means up to about 264 blocks may be securelyencrypted, which is good.Mihir Bellare UCSD 46

Security of CTR$

Theorem: [BDJR97] Let E : {0, 1}k ⇥ {0, 1}n ! {0, 1}` be a family offunctions and SE = (K, E ,D) the corresponding CTR$ symmetricencryption scheme. Let A be an ind-cpa adversary against SE that hasrunning time t and makes at most q LR queries, the messages across themtotaling at most � blocks. Then there is a prf-adversary B against E suchthat

Advind-cpaSE (A) 2 · AdvprfE (B) +2(q � 1)�

2n

Furthermore, B makes at most � oracle queries and has running timet +⇥(� · (n + `)).

Mihir Bellare UCSD 47

Intuition and proof

We first give some intuition for the proof and then the proof itself.

We assume for simplicity that both messages in each LR query of A are m

blocks long. Thus � = mq.

Note a block is ` bits, so each message in a query is m` bits.

Extending the proof to the general case is an exercise.

We let Ci = Ci [0]Ci [1] . . .Ci [m] denote the response of the LR oracle toA’s i-th query.

Mihir Bellare UCSD 48

Page 13: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

Intuition for IND-CPA security of CTR$

Consider the CTR$ scheme with EK replaced by a random function Fnwith range {0, 1}`.

Alg EFn(M)

C [0] $ {0, 1}n

for i = 1, . . . ,m doP[i ] Fn(C [0] + i)C [i ] P[i ]�M[i ]

return C

Analyzing this is a thought experiment, but we can ask whether it isIND-CPA secure.

If so, the assumption that E is a PRF says CTR$ with E is IND-CPAsecure.

Mihir Bellare UCSD 49

CTR$ with a random function

Let E be the event that the points

C1[0] + 1, . . . ,C1[0] +m, . . . ,Cq[0] + 1, . . . ,Cq[0] +m ,

on which Fn is evaluated across the q encryptions, are all distinct.

Case 1: E happens. Then the encryption is a one-time-pad: ciphertextsare random, independent strings, regardless of which message is encrypted.So A has zero advantage.

Case 2: E doesn’t happen. Then A may have high advantage but it doesnot matter because Pr[E ] doesn’t happen is small. (It is the small additiveterm in the theorem.)

Mihir Bellare UCSD 50

The Union bound

Let E1, . . . ,En be events in a probability space. Then

Pr[W

1in Ei ] nX

i=1

Pr[Ei ] .

Example: In the case n = 2 we have

Pr[E1 _ E2] = Pr[E1] + Pr[E2]� Pr[E1 ^ E2]

Pr[E1] + Pr[E2] .

Mihir Bellare UCSD 51

Interval intersection probability

Let N, q,m � 1 be integers and let ZN = {0, 1, . . . ,N � 1}. Let + beaddition modulo N. Consider the game

For i = 1, . . . , q do

ci$ ZN ; Ii {ci + 1, . . . , ci +m}

For 1 i < j q define the events

Bi ,j : Ii \ Ij 6= ; and B :W

1i<jqBi ,j .

Then let

IIP(N, q,m) = Pr[B] .

Problem: Upper bound IIP(N, q,m) as a function of N, q,m.

Mihir Bellare UCSD 52

Page 14: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

Interval intersection probability

Claim: IIP(N, q,m) q(q � 1)

2

(2m � 1)

N

Why? For any 1 i < j q we have

Pr[Bi ,j ] = Pr[Ii \ Ij 6= ;]

= Pr[cj 2 {ci �m + 1, . . . , ci +m � 1}] =2m � 1

N.

Then by the Union bound

IIP(N, q,m) = Pr[W

1i<jq] X

1i<jq

Pr[Bi ,j ]

=

✓q

2

◆2m � 1

N.

Mihir Bellare UCSD 53

Alternative formulation of advantage

Let SE = (K, E ,D) be a symmetric encryption scheme and A an adversary.

Game GuessSE

procedure InitializeK

$ K ; b $

{0, 1}

procedure LR(M0,M1)

return C$ EK (Mb)

procedure Finalize(b0)return (b = b

0)

Proposition: Advind-cpaSE (A) = 2 · PrhGuessASE)true

i� 1.

Proof: Observe

Pr⇥b0 = 1 | b = 1

⇤= Pr

hRightASE)1

i

Pr⇥b0 = 1 | b = 0

⇤= Pr

hLeftASE)1

i

Mihir Bellare UCSD 54

Proof of Proposition, continued

PrhGuessASE)true

i

= Pr⇥b = b0⇤

= Pr⇥b = b0 | b = 1

⇤· Pr [b = 1] + Pr

⇥b = b0 | b = 0

⇤· Pr [b = 0]

= Pr⇥b = b0 | b = 1

⇤· 12+ Pr

⇥b = b0 | b = 0

⇤· 12

= Pr⇥b0 = 1 | b = 1

⇤· 12+ Pr

⇥b0 = 0 | b = 0

⇤· 12

= Pr⇥b0 = 1 | b = 1

⇤· 12+

�1� Pr

⇥b0 = 1 | b = 0

⇤�· 12

=12+

12·�Pr

⇥b0 = 1 | b = 1

⇤� Pr

⇥b0 = 1 | b = 0

⇤�

=12+

12·⇣Pr

hRightASE)1

i� Pr

hLeftASE)1

i⌘

=12+

12· Advind-cpaSE (A) .

Mihir Bellare UCSD 55

A game-playing proof

The proof uses a sequence of games and invokes the fundamental lemmaof game playing [BR96].

The games have the following Initialize and Finalize procedures:

Initialize // G0

b$ {0, 1} ; S ;

K$ {0, 1}k

Initialize // G1,G2,G3

b$ {0, 1} ; S ;

Finalize // All games

Return (b = b0)

For brevity we omit writing these procedures explicitly in the games, butyou should remember they are there.

Also for brevity if G is a game and A is an adversary then we let

Pr[GA] = Pr[GA) true]

Mihir Bellare UCSD 56

Page 15: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

Games G0,G1 for the proof

Game G0

procedure LR(M0,M1)

C [0] $ {0, 1}n

for i = 1, ...,m doP C [0] + i

if P 62 S then T[P] EK (P)C [i ] T [P] � Mb[i ]S S [ {P}

return C

Game G1

procedure LR(M0,M1)

C [0] $ {0, 1}n

for i = 1, ...,m doP C [0] + i

if P /2 S then T[P] $ {0, 1}`

C [i ] T[P] � Mb[i ]S S [ {P}

return C

ThenAdvind-cpaSE (A) = 2 · Pr

hG

A0

i� 1

Mihir Bellare UCSD 57

Analysis

Clearly Pr[GA0 ] = Pr[GA

1 ] +�Pr[GA

0 ]� Pr[GA1 ]�.

Claim 1: We can design prf-adversary B so that

Pr[GA0 ]� Pr[GA

1 ] AdvprfE (B)

Claim 2: Pr[GA1 ]

1

2+

(q � 1)�

2n

Given these, we have

Advind-cpaSE (A) 2 ·

✓1

2+

(q � 1)�

2n

◆� 1 + 2 · AdvprfE (B)

=2(q � 1)�

2n+ 2 · AdvprfE (B)

which proves the theorem. It remains to prove the claims.

Mihir Bellare UCSD 58

Proof of Claim 1

adversary B

b$ {0, 1} ; S ;

b0 $ A

LRSim

if (b = b0) then return 1

else return 0

subroutine LRSim(M0,M1)

C [0] $ {0, 1}n

for i = 1, ...,m doP C [0] + i

if P /2 S then T [P] Fn(P)C [i ] T [P] � Mb[i ]S S [ {P}

return C

PrhRealBE ) 1

i= Pr

hG

A0

i

PrhRandB{0,1}n ) 1

i= Pr

hG

A1

i

Subtracting, we get Claim 1.

Mihir Bellare UCSD 59

Where we are

It remains to prove:

Claim 2: Pr[GA1 ]

1

2+

(q � 1)�

2n

Mihir Bellare UCSD 60

Page 16: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

Introducing the “bad” flag

Game G1

procedure LR(M0,M1)

C [0] $ {0, 1}n

for i = 1, ...,m do

P C [0] + i

If P /2 S thenT[P] $ {0, 1}`

C [i ] T[P]�Mb[i ]

S S [ {P}return C

Game G2 , G3

procedure LR(M0,M1)

C [0] $ {0, 1}n

for i = 1, ...,m do

P C [0] + i

C [i ] $ {0, 1}`

If P 2 S thenbad true ; C [i ] T[P]�Mb[i ]

T[P] C [i ]�Mb[i ]

S S [ {P}return C

Pr[GA1 ] = Pr[GA

2 ] = Pr[GA3 ] +

⇣Pr[GA

2 ]� Pr[GA3 ]⌘

Mihir Bellare UCSD 61

Analysis of G3

Game G3

procedure LR(M0,M1)

C [0] $ {0, 1}n

for i = 1, ...,m do

P C [0] + i; C [i ] $ {0, 1}`

If P 2 S then bad true

T[P] C [i ]�Mb[i ]; S S [ {P}return C

Ciphertext C in G3 is always random, independently of b, so

PrhG

A3

i=

1

2.

Mihir Bellare UCSD 62

Fundamental Lemma of game playing

Games G ,H are identical-until-bad if their code di↵ers only in statementsfollowing the setting of bad to true.

Lemma: [BR96] If G ,H are identical-until-bad, then for any adversary Aand any y

���PrhG

A) y

i� Pr

hH

A) y

i��� PrhH

A sets badi

Mihir Bellare UCSD 63

Using the fundamental lemma

Game G2 , G3

procedure LR(M0,M1)

C [0] $ {0, 1}n

for i = 1, ...,m do

P C [0] + i; C [i ] $ {0, 1}`

If P 2 S thenbad true ; C [i ] T[P]�Mb[i ]

T[P] C [i ]�Mb[i ]; S S [ {P}return C

G2 and G3 are identical-until-bad, so Fundamental Lemma implies

PrhG

A2

i� Pr

hG

A3

i Pr

hG

A3 sets bad

i.

Mihir Bellare UCSD 64

Page 17: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

Bounding the probability that G3 sets bad

Game G3

procedure LR(M0,M1)

C [0] $ {0, 1}n

for i = 1, ...,m do

P C [0] + i; C [i ] $ {0, 1}`

If P 2 S then bad true

T[P] C [i ]�Mb[i ]; S S [ {P}return C

PrhG

A3 sets bad

i IIP(2n, q,m)

q(q � 1)

2

2m � 1

2n

mq(q � 1)

2n

(q � 1)�

2n.

Mihir Bellare UCSD 65

Security of CTR$

Theorem: [BDJR97] Let E : {0, 1}k ⇥ {0, 1}n ! {0, 1}` be a family offunctions and SE = (K, E ,D) the corresponding CTR$ symmetricencryption scheme. Let A be an ind-cpa adversary against SE that hasrunning time t and makes at most q LR queries, the messages across themtotaling at most � blocks. Then there is a prf-adversary B against E suchthat

Advind-cpaSE (A) 2 · AdvprfE (B) +2(q � 1)�

2n

Furthermore, B makes at most � oracle queries and has running timet +⇥(� · (n + `)).

Mihir Bellare UCSD 66

Security of CBC$

Let E : {0, 1}k ⇥ {0, 1}n ! {0, 1}n be a block cipher and SE = (K, E ,D)the corresponding CBC$ symmetric encryption scheme.

Exercise: Give an adversary A that makes q LR-queries, each consistingof two 1-block messages, and achieves

Advind-cpaSE (A) = ⌦

✓q2

2n

The running time of A should be about O(qn · log(qn)).

Can you generalize this to m-block messages? What is the best advantageyou can get?

Mihir Bellare UCSD 67

Security of CBC$

Theorem: [BDJR97] Let E : {0, 1}k ⇥ {0, 1}n ! {0, 1}n be a block cipherand SE = (K, E ,D) the corresponding CBC$ symmetric encryptionscheme. Let A be an ind-cpa adversary against SE that has running time t

and makes at most q LR queries, the messages across them totaling atmost � blocks. Then there is a prf-adversary B against E such that

Advind-cpaSE (A) 2 · AdvprfE (B) +�2

2n

Furthermore, B makes at most � oracle queries and has running timet +⇥(� · n).

Exercise: Prove the above theorem.

Mihir Bellare UCSD 68

Page 18: SYMMETRIC ENCRYPTION - cseweb.ucsd.educseweb.ucsd.edu/~mihir/cse207/slides/s-se.pdf · The measure of success Advind-cpa SE (A) ⇡ 1 means A is doing well and SE is not ind-cpa-secure

Exercise

You are hired at a top company with an extravagant salary. Your boss asksyou how secure is CBC$ based on AES. Give a clear and full answer whichincludes an explanation of security metrics, their relative merits, attacksand proofs. This should include an interpretation of the theorem we justsaw. Your description should cover both the value and the limitations ofthis theorem and give a realistic picture of security aimed at someone withlittle understanding of cryptography.

Have a friend play the role of boss and make this a conversation. Yourfriend should be critical and curious about what you say.

Mihir Bellare UCSD 69

Exercise

In CTR$ and CBC$ based on a family of functions E : {0, 1}k ⇥ {0, 1}n !{0, 1}`, the message must have length a positive multiple of `. Specify—by giving clear pseudocode for all three algorithms— a symmetricencryption scheme SE = (K, E ,D) based on E in which the message M

can be a string of arbitrary length. Encryption and decryption should useat most d|M|/`e applications of E or E�1 and the length of the ciphertextshould be |M|+ n. The scheme should achieve IND-CPA with the samekinds of bounds as in the theorems about CTR$ and CBC$. You mayassume E is a block cipher if needed.

Mihir Bellare UCSD 70