lecture 3 symmetric encryption, ind-cpa, ctr, cbc
TRANSCRIPT
Lecture 3 โ Symmetric encryption, IND-CPA,
CTR, CBC
TEK4500
08.09.2020
Hรฅkon Jacobsen
Basic goals of cryptography
2
Message privacyMessage integrity /
authentication
Symmetric keys Symmetric encryptionMessage authentication
codes (MAC)
Asymmetric keys
Asymmetric encryption
(a.k.a. public-key
encryption)
Digital signatures
Encryption schemes โ syntax
โข A symmetric encryption scheme ฮฃ = KeyGen, Enc, Dec consists of three
algorithms:
โข Associated to ฮฃ:
โข Key space ๐ฆ
โข Message space โณ
โข Ciphertext space ๐
โข KeyGen and Enc may be randomized ($), but Dec must be deterministic3
Adversary
EncC
M M / โฅ
KeyGen
Dec$
K
$
Correctness requirement: For all
๐พ โ KeyGen :
Dec ๐พ, Enc ๐พ,๐ = ๐
Electronic Code Book (ECB) mode
Given a block cipher โฐ: 0,1 ๐ ร 0,1 ๐ โ 0,1 ๐ how to encrypt a long message?
ECB โฐ = KeyGen, Enc, Dec
4
โฐ๐พ
๐1
๐ถ1
โฐ๐พ
๐2
๐ถ2
โฐ๐พ
๐3
๐ถ3
โฐ๐พ
๐4
๐ถ4
Alg Enc ๐พ,๐---------------------------------1. for ๐ = 1,โฆ ,๐ do2. ๐ถ๐ โ โฐ๐พ ๐๐
3. return ๐ถ
Alg Dec ๐พ, ๐ถ---------------------------------1. for ๐ = 1,โฆ ,๐ do2. ๐๐ โ โฐ๐พ
โ1 ๐ถ๐3. return ๐
ECB problems
โข Weakness: ๐1 = ๐2 โน ๐ถ1 = ๐ถ2
โข Example: Suppose message space only contains two messages: ๐ = 0128
and ๐ = 1128; could represent:
โข Vote YES or NO
โข BUY or SELL a stock
โข FIRE or DON'T FIRE a missile
5
Wanted: security definition for symmetric encryption
โข Perfect privacy: for any ๐0, ๐1 โ โณ and any ๐ถ โ ๐:
Pr โฐ๐พ ๐0 = ๐ถ = Pr โฐ๐พ ๐1 = ๐ถ
โข Security holds for any adversary (no limit on resource usage)
โข Very strict requirements:
โข Keys need to be as long as message
โข Key can only be used for one message
7
Wanted: security definition for symmetric encryption
โข Perfect privacy: for any ๐0, ๐1 โ โณ and any ๐ถ โ ๐:
Pr โฐ๐พ ๐0 = ๐ถ = Pr โฐ๐พ ๐1 = ๐ถ
โข Security holds for any adversary (no limit on resource usage)
โข Very strict requirements:
โข Keys need to be as long as messageโฆwant keys to be short
โข Key can only be used for one messageโฆwant to encrypt many messages
8
Idea
โข Computational privacy: for any ๐0, ๐1 โ โณ and any ๐ถ โ ๐:
Pr โฐ๐พ ๐0 = ๐ถ โ Pr โฐ๐พ ๐1 = ๐ถ
โข Security only required to hold for resource bounded adversaries
โข Very strict requirements:
โข Keys need to be as long as messageโฆwant keys to be short
โข Key can only be used for one messageโฆwant to encrypt many messages
9
IND-CPA โ Indistinguishability against chosen-plaintext attacks
10
๐๐ฑ๐ฉฮฃindโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$ฮฃ. KeyGen
3. ๐0, ๐1 โ ๐ดโฐ๐พ โ // find stage4.5.6. ๐ถโ โ ฮฃ. Enc ๐พ,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐---------------------------------1. return ฮฃ. Enc ๐พ,๐
Definition: The IND-CPA-advantage of an
adversary ๐ด is
๐๐๐ฏฮฃindโcpa
๐ด = Pr ๐๐ฑ๐ฉฮฃindโcpa
๐ด โ true โ 1/2
Test me on ๐0, ๐1
๐ถโ
๐1, ๐2, โฆ
๐ถ1, ๐ถ2, โฆ
Enc(๐พ,โ )
๐1, ๐2, โฆ
๐ถ1, ๐ถ2, โฆ
Enc(๐พ,โ )
What if ๐จ submits ๐ด๐ = ๐and ๐ด๐ = ๐๐๐๐๐๐?
๐ถโ was an
encryption of ๐1
IND-CPA โ Indistinguishability against chosen-plaintext attacks
11
๐๐ฑ๐ฉฮฃindโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$ฮฃ. KeyGen
3. ๐0, ๐1 โ ๐ดโฐ๐พ โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ ฮฃ. Enc ๐พ,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐---------------------------------1. return ฮฃ. Enc ๐พ,๐
Definition: The IND-CPA-advantage of an
adversary ๐ด is
๐๐๐ฏฮฃindโcpa
๐ด = Pr ๐๐ฑ๐ฉฮฃindโcpa
๐ด โ true โ 1/2
Test me on ๐0, ๐1
๐ถโ
๐1, ๐2, โฆ
๐ถ1, ๐ถ2, โฆ
Enc(๐พ,โ )
๐1, ๐2, โฆ
๐ถ1, ๐ถ2, โฆ
Enc(๐พ,โ )
๐ถโ was an
encryption of ๐1
IND-CPA โ Indistinguishability against chosen-plaintext attacks
12
๐๐ฑ๐ฉฮฃindโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$ฮฃ. KeyGen
3. ๐0, ๐1 โ ๐ดโฐ๐พ โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ ฮฃ. Enc ๐พ,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐---------------------------------1. return ฮฃ. Enc ๐พ,๐
Definition: The IND-CPA-advantage of an
adversary ๐ด is
๐๐๐ฏฮฃindโcpa
๐ด = 2 โ Pr ๐๐ฑ๐ฉฮฃindโcpa
๐ด โ true โ 1
Test me on ๐0, ๐1
๐ถโ
๐1, ๐2, โฆ
๐ถ1, ๐ถ2, โฆ
Enc(๐พ,โ )
๐1, ๐2, โฆ
๐ถ1, ๐ถ2, โฆ
Enc(๐พ,โ )
๐ถโ was an
encryption of ๐1
๐๐๐ฏฮฃindโcpa
๐ด โ 1 = adversary is doing well
๐๐๐ฏฮฃindโcpa
๐ด โ 0 = adversary is doing poorly
ECB IND-CPA insecurity
13
๐๐ฑ๐ฉECB[โฐ]indโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$ECB. KeyGen
3. ๐0, ๐1 โ ๐ดโฐ๐พ โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ ECB. Enc ๐พ,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐---------------------------------1. return ECB. Enc ๐พ,๐
Adversary ๐จ
1. Query ๐ถ โ โฐ๐พ 0128 in find stage 2. Submit ๐0 = 0128 and ๐1 = 1128
3. Receive challenge ๐ถโ
4. if ๐ถโ = ๐ถ output 05. else, output 1
Pr ๐๐ฑ๐ฉECB[โฐ]indโcpa
๐ด โ true
= 1
= Pr ๐โฒ = 0 ๐ = 0 โ 1/2 + Pr ๐โฒ = 1 ๐ = 1 โ 1/2
= Pr โฐ๐พ 0128 = โฐ๐พ 0128 ๐ = 0 + Pr โฐ๐พ 0128 โ โฐ๐พ 1128 ๐ = 1 โ 1/ 2
1
= Pr ๐โฒ = ๐
1
๐๐๐ฏฮฃindโcpa
๐ด = 2 โ Pr ๐๐ฑ๐ฉฮฃindโcpa
๐ด โ true โ 1 = 1
Consequences of the definition
โข An IND-CPA secure scheme cannot be deterministic
โข IND-CPA security implies other properties that we want:
โข P1: Should be hard to obtain ๐พ from ๐ โ ๐ธ๐พ(๐) for secret ๐พ
โข P2: Should be hard to obtain ๐พ from ๐1, ๐2, โฆ where ๐๐ โ ๐ธ๐พ ๐๐โข P3: Should be hard to obtain ๐ from ๐ โ ๐ธ๐พ(๐)
โข P4: Should be hard to obtain any ๐๐ from ๐1, ๐2 , โฆ where ๐๐ โ ๐ธ๐พ ๐๐โข P5: Should be hard to learn any bit of ๐ from ๐ โ ๐ธ๐พ(๐)
โข P6: Should be hard to detect repetitions among ๐1, ๐2, โฆ from ๐1, ๐2, โฆ
โข
โข But does it give us all the properties we want? I.e., is IND-CPA the "master property"?
14
Semantic security
โข The conceptually "right" definition
โข High level idea: an encryption scheme is semantically secure if by observing
a ciphertext ๐ถ the adversary learns nothing about the plaintext (except its
length)
โข Harder to formalize + IND-CPA is easier to work with
15
Theorem: (Goldwasser & Micali '83)
An encryption scheme ฮฃ is IND-CPA secure โบ ฮฃ is semantically secure.
Length-leaking attacks
โข Google maps
โข World regions have unique "fingerprints" based on length of data (based on map tiles)
โข Variable-bitrate encoding
โข Can e.g., fingerprint movies streamed over Netflix
โข To combat length-leaking attacks: message padding
โข Can be expensive
โข Supported in TLS, but seldom used
โข Used by TOR
16
How to achieve non-deterministic encryption?
โข Randomized encryption
โข Coins flipped internally by the algorithm
โข Nonce-based encryption
โข Encryption scheme itself is deterministic
โข Non-determinism injected from the outside
18
๐
Ciphertext
๐โฒ
Plaintext
CTR$ mode
Block cipher โฐ: 0,1 ๐ ร 0,1 ๐ โ 0,1 ๐
CTR$ โฐ = KeyGen, Enc, Dec :
19
Alg Enc ๐พ,๐---------------------------------
1. ctrโ$
0,1 ๐
2. ๐ถ0 โ ctr3. for ๐ = 1,โฆ ,๐ do4. ๐ถ๐ โ โฐ๐พ ctr + ๐ โ๐๐
5. return ๐ถ0||๐ถ1||โฏ ||๐ถ๐
Alg Dec ๐พ, ๐ถ---------------------------------1. ctr โ ๐ถ02. for ๐ = 1,โฆ ,๐ do3. ๐๐ โ โฐ๐พ ctr + ๐ โ ๐ถ๐4. return๐1||๐2||โฏ ||๐๐
ctr + 1
๐ถ1
ctr
๐ถ0
โฐ๐พ
๐1
ctr + 2
๐ถ2
โฐ๐พ
๐2
ctr + 3
๐ถ3
โฐ๐พ
๐3
CTR properties
โข Fully parallelizable
โข Inverse direction of โฐ๐พ not needed
โข Can use a PRF instead of a PRP
โข Key stream can be generated in advance
โข No padding needed for messages not a multiple of block length
โข What about security?
20
ctr + 1
๐ถ1
ctr
๐ถ0
โฐ๐พ
๐1
ctr + 2
๐ถ2
โฐ๐พ
๐2
ctr + 3
๐ถ3
โฐ๐พ
๐3
Modern approach to cryptography
โข Trying to make cryptography more a science than an art
โข Focus on formal definitions of security (and insecurity)
โข Clearly stated assumptions
โข Analysis supported by mathematical proofs
21
Security of CTR$
22
Theorem (idea):
If ๐น: 0,1 ๐ ร 0,1 ๐ โ 0,1 ๐ is a secure PRF then CTR$[๐น] is IND-CPA secure.
Logic 101
is equivalent to:
Theorem (idea):
If CTR$[๐น] is not IND-CPA secure then ๐น is not a secure PRF.
โบ equivalent!
Security of CTR$
Proof idea:
โข CTR$[๐น] not IND-CPA secure โน there exists adversary ๐ด with good advantage ๐๐๐ฏCTR$ ๐นindโcpa
๐ด
โข Can use ๐ด to create a new adversary ๐ต that has good advantage ๐๐๐ฏ๐นprf
๐ต against ๐น
โน ๐น is not a secure PRF!
23
Theorem (idea):
If CTR$[๐น] is not IND-CPA secure then ๐น is not a secure PRF.
Security of CTR$
24
Theorem (actual): For any IND-CPA adversary ๐ด against CTR$ ๐น that runs in time ๐ก๐ดand asks at most ๐ queries (each of max length ๐ ๐-bit blocks), there exists an PRF-
adversary ๐ต such that
๐๐๐ฏCTR$ ๐นindโcpa
๐ด โค ๐๐๐ฏ๐นprf
๐ต +2๐2
2๐
where ๐ต runs in time ๐ก๐ต = ๐ก๐ด + ๐(๐2) and asks at most ๐๐ต = ๐2 PRF-queries.
Security of CTR$
โข Logic 101: ๐น secure PRF โน๐๐๐ฏ๐นprf
๐ต โ 0
โน๐๐๐ฏCTR$ ๐นindโcpa
๐ด โค2๐2
2๐
โน๐๐๐ฏCTR$ ๐นindโcpa
๐ด โ 0
โน CTR$[๐น] is IND-CPA secure!
25
Theorem (actual): For any IND-CPA adversary ๐ด against CTR$ ๐น that runs in time ๐ก๐ดand asks at most ๐ queries (each of max length ๐ ๐-bit blocks), there exists an PRF-
adversary ๐ต such that
๐๐๐ฏCTR$ ๐นindโcpa
๐ด โค ๐๐๐ฏ๐นprf
๐ต +2๐2
2๐
where ๐ต runs in time ๐ก๐ต = ๐ก๐ด + ๐(๐2) and asks at most ๐๐ต = ๐2 PRF-queries.
๐ โช 2๐/2
Example:
AES: ๐ = 128๐ = 240 โ 17.5 TB of data
Security of CTR$ โ proof idea
26
๐๐ฑ๐ฉCTR$ โฐindโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$CTR$ ๐น . KeyGen
3. ๐0,๐1 โ ๐ดโฐ๐พ โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ CTR$ โฐ . Enc ๐พ,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐---------------------------------1. return CTR$ ๐น . Enc ๐พ,๐
๐1 ๐2 ๐3 โฏ ๐๐ฟ
๐น๐พ(๐ โ + 1) ๐น๐พ(๐
โ + 2) ๐น๐พ(๐ โ + 3) โฏ ๐น๐พ(๐
โ + ๐ฟ) Alg CTR ๐น . Enc ๐พ,๐---------------------------------
1. ctrโ$
0,1 ๐
2. ๐ถ0 โ ctr3. for ๐ = 1,โฆ ,๐ do4. ๐ถ๐ โ ๐น๐พ ctr + ๐ โ๐๐
5. return๐ถ0||๐ถ1||โฏ ||๐ถ๐
๐ถ1โ ๐ถ2
โ ๐ถ3โ โฏ ๐ถ๐ฟ
โ
=
๐๐
๐ถโ
Theorem: For any ๐ด โฆ there exists ๐ต such that
๐๐๐ฏCTR$ ๐นindโcpa
๐ด โค ๐๐๐ฏ๐นprf
๐ต +2๐2
2๐
Security of CTR$ โ proof idea
27
Theorem: For any ๐ด โฆ there exists ๐ต such that
๐๐๐ฏCTR$ ๐นindโcpa
๐ด โค ๐๐๐ฏ๐นprf
๐ต +2๐2
2๐
๐๐ฑ๐ฉCTR$ โฐindโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$CTR$ ๐น . KeyGen
3. ๐0,๐1 โ ๐ดโฐ๐พ โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ CTR$ โฐ . Enc ๐พ,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐---------------------------------1. return CTR$ ๐น . Enc ๐พ,๐
Alg CTR ๐น . Enc ๐พ,๐---------------------------------
1. ctrโ$
0,1 ๐
2. ๐ถ0 โ ctr3. for ๐ = 1,โฆ ,๐ do4. ๐ถ๐ โ ๐น๐พ ctr + ๐ โ๐๐
5. return๐ถ0||๐ถ1||โฏ ||๐ถ๐
๐1 ๐2 ๐3 โฏ ๐๐ฟ
=
๐๐
๐ถโ ๐โ$Func[๐, ๐] โ ๐น๐พ by PRF-security
๐(๐ โ + 1) ๐(๐ โ + 2) ๐(๐ โ + 3) โฏ ๐(๐ โ + ๐ฟ)
๐ถ1โ ๐ถ2
โ ๐ถ3โ โฏ ๐ถ๐ฟ
โ
Security of CTR$ โ proof idea
28
Theorem: For any ๐ด โฆ there exists ๐ต such that
๐๐๐ฏCTR$ ๐นindโcpa
๐ด โค ๐๐๐ฏ๐นprf
๐ต +2๐2
2๐
๐๐ฑ๐ฉCTR$ โฐindโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$CTR$ ๐น . KeyGen
3. ๐0,๐1 โ ๐ดโฐ๐พ โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ CTR$ โฐ . Enc ๐พ,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐---------------------------------1. return CTR$ ๐น . Enc ๐พ,๐
Alg CTR ๐น . Enc ๐พ,๐---------------------------------
1. ctrโ$
0,1 ๐
2. ๐ถ0 โ ctr3. for ๐ = 1,โฆ ,๐ do4. ๐ถ๐ โ ๐น๐พ ctr + ๐ โ๐๐
5. return๐ถ0||๐ถ1||โฏ ||๐ถ๐
๐1 ๐2 ๐3 โฏ ๐๐ฟ
=
๐๐
๐ถโ ๐โ$Func[๐, ๐] โ ๐น๐พ by PRF-security
๐(๐ โ + 1) ๐(๐ โ + 2) ๐(๐ โ + 3) โฏ ๐(๐ โ + ๐ฟ)
๐ถ1โ ๐ถ2
โ ๐ถ3โ โฏ ๐ถ๐ฟ
โ
๐ถ1โ ๐ถ2
โ ๐ถ3โ โฏ ๐ถ๐ฟ
โ
Security of CTR$ โ proof idea
29
Theorem: For any ๐ด โฆ there exists ๐ต such that
๐๐๐ฏCTR$ ๐นindโcpa
๐ด โค ๐๐๐ฏ๐นprf
๐ต +2๐2
2๐
๐๐ฑ๐ฉCTR$ โฐindโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$CTR$ ๐น . KeyGen
3. ๐0,๐1 โ ๐ดโฐ๐พ โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ CTR$ โฐ . Enc ๐พ,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐---------------------------------1. return CTR$ ๐น . Enc ๐พ,๐
Alg CTR ๐น . Enc ๐พ,๐---------------------------------
1. ctrโ$
0,1 ๐
2. ๐ถ0 โ ctr3. for ๐ = 1,โฆ ,๐ do4. ๐ถ๐ โ ๐น๐พ ctr + ๐ โ๐๐
5. return๐ถ0||๐ถ1||โฏ ||๐ถ๐
๐1 ๐2 ๐3 โฏ ๐๐ฟ
=
๐๐
๐ถโ ๐โ$Func[๐, ๐] โ ๐น๐พ by PRF-securityOTP
๐(๐ โ + 1) ๐(๐ โ + 2) ๐(๐ โ + 3) โฏ ๐(๐ โ + ๐ฟ)
๐ถ1โ ๐ถ2
โ ๐ถ3โ โฏ ๐ถ๐ฟ
โ
Security of CTR$ โ proof idea
30
Theorem: For any ๐ด โฆ there exists ๐ต such that
๐๐๐ฏCTR$ ๐นindโcpa
๐ด โค ๐๐๐ฏ๐นprf
๐ต +2๐2
2๐
๐๐ฑ๐ฉCTR$ โฐindโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$CTR$ ๐น . KeyGen
3. ๐0,๐1 โ ๐ดโฐ๐พ โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ CTR$ โฐ . Enc ๐พ,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐---------------------------------1. return CTR$ ๐น . Enc ๐พ,๐
Alg CTR ๐น . Enc ๐พ,๐---------------------------------
1. ctrโ$
0,1 ๐
2. ๐ถ0 โ ctr3. for ๐ = 1,โฆ ,๐ do4. ๐ถ๐ โ ๐น๐พ ctr + ๐ โ๐๐
5. return๐ถ0||๐ถ1||โฏ ||๐ถ๐
๐1 ๐2 ๐3 โฏ ๐๐ฟ
=
๐๐
๐ถโ ๐โ$Func[๐, ๐] โ ๐น๐พ by PRF-security
๐(1)โฐ๐พ
๐ 1||๐ถ11||๐ถ2
(1)โฆ
๐(2)โฐ๐พ
๐ 2||๐ถ12||๐ถ2
(2)โฆ
โฎ
๐(๐)โฐ๐พ
๐ ๐||๐ถ1๐||๐ถ2
(๐)โฆ
๐(๐ โ + 1) ๐(๐ โ + 2) ๐(๐ โ + 3) โฏ ๐(๐ โ + ๐ฟ)
๐ถ1โ ๐ถ2
โ ๐ถ3โ โฏ ๐ถ๐ฟ
โ
Security of CTR$ โ proof idea
31
Theorem: For any ๐ด โฆ there exists ๐ต such that
๐๐๐ฏCTR$ ๐นindโcpa
๐ด โค ๐๐๐ฏ๐นprf
๐ต +2๐2
2๐
๐๐ฑ๐ฉCTR$ โฐindโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$CTR$ ๐น . KeyGen
3. ๐0,๐1 โ ๐ดโฐ๐พ โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ CTR$ โฐ . Enc ๐พ,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐---------------------------------1. return CTR$ ๐น . Enc ๐พ,๐
Alg CTR ๐น . Enc ๐พ,๐---------------------------------
1. ctrโ$
0,1 ๐
2. ๐ถ0 โ ctr3. for ๐ = 1,โฆ ,๐ do4. ๐ถ๐ โ ๐น๐พ ctr + ๐ โ๐๐
5. return๐ถ0||๐ถ1||โฏ ||๐ถ๐
๐1 ๐2 ๐3 โฏ ๐๐ฟ
=
๐๐
๐ถโ ๐โ$Func[๐, ๐] โ ๐น๐พ by PRF-security
๐(1)โฐ๐พ
๐ 1||๐ถ11||๐ถ2
1โฆ = ๐ 1||๐(๐ 1 + 1)โ๐1
1||๐(๐ 1 + 2)โ๐2
1|| โฆ
๐(2)โฐ๐พ
๐ 2||๐ถ12||๐ถ2
(2)โฆ = ๐ 2||๐(๐ 2 + 1)โ๐1
2||๐(๐ 2 + 2)โ๐2
2|| โฆ
โฎ
๐(๐)โฐ๐พ
๐ ๐||๐ถ1๐||๐ถ2
(๐)โฆ = ๐ ๐||๐(๐ ๐ + 1)โ๐1
๐||๐(๐ ๐ + 2)โ๐2
๐|| โฆ
๐(๐ โ + 1) ๐(๐ โ + 2) ๐(๐ โ + 3) โฏ ๐(๐ โ + ๐ฟ)
๐ถ1โ ๐ถ2
โ ๐ถ3โ โฏ ๐ถ๐ฟ
โ
Security of CTR$ โ proof idea
32
Theorem: For any ๐ด โฆ there exists ๐ต such that
๐๐๐ฏCTR$ ๐นindโcpa
๐ด โค ๐๐๐ฏ๐นprf
๐ต +2๐2
2๐
๐๐ฑ๐ฉCTR$ โฐindโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$CTR$ ๐น . KeyGen
3. ๐0,๐1 โ ๐ดโฐ๐พ โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ CTR$ โฐ . Enc ๐พ,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐---------------------------------1. return CTR$ ๐น . Enc ๐พ,๐
Alg CTR ๐น . Enc ๐พ,๐---------------------------------
1. ctrโ$
0,1 ๐
2. ๐ถ0 โ ctr3. for ๐ = 1,โฆ ,๐ do4. ๐ถ๐ โ ๐น๐พ ctr + ๐ โ๐๐
5. return๐ถ0||๐ถ1||โฏ ||๐ถ๐
๐1 ๐2 ๐3 โฏ ๐๐ฟ
๐(๐ โ + 1) ๐(๐ โ + 2) ๐(๐ โ + 3) โฏ ๐(๐ โ + ๐ฟ)
=
๐๐
๐ถโ ๐โ$Func[๐, ๐] โ ๐น๐พ by PRF-security
๐(1)โฐ๐พ
๐ 1||๐ถ11||๐ถ2
1โฆ = ๐ 1||๐(๐ 1 + 1)โ๐1
1||๐(๐ 1 + 2)โ๐2
1|| โฆ
๐(2)โฐ๐พ
๐ 2||๐ถ12||๐ถ2
(2)โฆ = ๐ 2||๐(๐ 2 + 1)โ๐1
2||๐(๐ 2 + 2)โ๐2
2|| โฆ
โฎ
๐(๐)โฐ๐พ
๐ ๐||๐ถ1๐||๐ถ2
(๐)โฆ = ๐ ๐||๐(๐ ๐ + 1)โ๐1
๐||๐(๐ ๐ + 2)โ๐2
๐|| โฆ
Event ๐๐จ๐ฅ๐ฅ๐:
๐ ๐ + ๐ = ๐ โ + ๐โฒ โน ๐ ๐ ๐ + ๐ = ๐ ๐ โ + ๐โฒ = ๐
โน ๐ถ๐๐โ๐ถ๐โฒ
โ = ๐ โ๐๐๐
โ ๐ โ๐๐โฒโ = ๐๐
๐โ๐๐โฒ
โ
Security of CTR$ โ proof idea
33
๐ โ, ๐ โ + 1,โฆ ๐ ๐ , ๐ ๐+1,โฆ๐ ๐ , ๐ ๐+1,โฆ ๐ ๐, ๐ ๐+1,โฆ
0 1 โฆ 2๐ โ 1
Security of CTR$ โ proof idea
34
๐ โ, ๐ โ + 1,โฆ ๐ ๐ , ๐ ๐+1,โฆ๐ ๐ , ๐ ๐+1,โฆ ๐ ๐, ๐ ๐+1,โฆ
0 1 โฆ 2๐ โ 1Coll๐
Coll = Coll1 โจ Coll2 โจ โฏโจ Coll๐
Pr Coll = Pr Coll1 โจ Coll2 โจ โฏโจ Coll๐ โค
๐=1
๐
Pr Coll๐
Pr Coll๐ = Pr ๐ โ + 1 โ ๐ฟ โค ๐ ๐ โค ๐ โ + ๐ฟ โ 1
Security of CTR$ โ proof idea
35
๐ โ, ๐ โ + 1,โฆ ๐ ๐ , ๐ ๐+1,โฆ๐ ๐ , ๐ ๐+1,โฆ ๐ ๐, ๐ ๐+1,โฆ
0 1 โฆ 2๐ โ 1
Coll = Coll1 โจ Coll2 โจ โฏโจ Coll๐
Pr Coll = Pr Coll1 โจ Coll2 โจ โฏโจ Coll๐ โค
๐=1
๐
Pr Coll๐
Pr Coll๐ = Pr ๐ โ + 1 โ ๐ฟ โค ๐ ๐ โค ๐ โ + ๐ฟ โ 1
Coll๐
Security of CTR$ โ proof idea
36
๐ โ, ๐ โ + 1,โฆ๐ ๐ , ๐ ๐+1,โฆ๐ ๐ , ๐ ๐+1,โฆ ๐ ๐, ๐ ๐+1,โฆ
0 1 โฆ 2๐ โ 1
Coll = Coll1 โจ Coll2 โจ โฏโจ Coll๐
Pr Coll = Pr Coll1 โจ Coll2 โจ โฏโจ Coll๐ โค
๐=1
๐
Pr Coll๐
Pr Coll๐ = Pr ๐ โ + 1 โ ๐ฟ โค ๐ ๐ โค ๐ โ + ๐ฟ โ 1
Coll๐
Security of CTR$ โ proof idea
37
Coll = Coll1 โจ Coll2 โจ โฏโจ Coll๐
Pr Coll = Pr Coll1 โจ Coll2 โจ โฏโจ Coll๐ โค
๐=1
๐
Pr Coll๐
Pr Coll๐ = Pr ๐ โ + 1 โ ๐ฟ โค ๐ ๐ โค ๐ โ + ๐ฟ โ 1 โค2๐ฟ
2๐
๐ โ, ๐ โ + 1,โฆ๐ ๐ , ๐ ๐+1,โฆ๐ ๐ , ๐ ๐+1,โฆ ๐ ๐, ๐ ๐+1,โฆ
0 1 โฆ 2๐ โ 1
โค ๐ โ 2๐ฟ
2๐=2๐2
2๐
Coll๐
Security of CTR$ โ proof idea
38
Theorem: For any ๐ด โฆ there exists ๐ต such that
๐๐๐ฏCTR$ ๐นindโcpa
๐ด โค ๐๐๐ฏ๐นprf
๐ต +2๐2
2๐
๐๐ฑ๐ฉCTR$ โฐindโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$CTR$ ๐น . KeyGen
3. ๐0,๐1 โ ๐ดโฐ๐พ โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ CTR$ โฐ . Enc ๐พ,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐---------------------------------1. return CTR$ ๐น . Enc ๐พ,๐
Alg CTR ๐น . Enc ๐พ,๐---------------------------------
1. ctrโ$
0,1 ๐
2. ๐ถ0 โ ctr3. for ๐ = 1,โฆ ,๐ do4. ๐ถ๐ โ ๐น๐พ ctr + ๐ โ๐๐
5. return๐ถ0||๐ถ1||โฏ ||๐ถ๐
๐1 ๐2 ๐3 โฏ ๐๐ฟ
=
๐๐
๐ถโ ๐โ$Func[๐, ๐] โ ๐น๐พ by PRF-security
๐(๐ โ + 1) ๐(๐ โ + 2) ๐(๐ โ + 3) โฏ ๐(๐ โ + ๐ฟ)
๐ถ1โ ๐ถ2
โ ๐ถ3โ โฏ ๐ถ๐ฟ
โ
Nonce-based encryption
โข Initial value in CTR$ chosen at random
โข Not actually neccessary; sufficient that no inputs to underlying PRF/PRP
repeat
โข A simple counter works
โข More generally: any number not used more than once โ a nonce (number
used once)
โข CTR: nonce-based counter-mode
39
Nonce-based encryption โ new syntax
โข Enc is now a deterministic function
โข Non-determinism comes from varying ๐
โข Choose ๐ at random โน recover probabilistic notion
40
Enc โถ ๐ฆ ร๐ฉ รโณ โ ๐
Enc ๐พ,๐,๐ = Enc๐พ ๐,๐ = Enc๐พ๐ ๐ Enc
๐พ๐ ๐ถ
๐
Nonce-based
Enc๐พ๐ ๐ถ
$
Randomized
IND-CPA โ Indistinguishability against chosen-plaintext attacks
41
๐๐ฑ๐ฉฮฃindโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$ฮฃ. KeyGen
3. ๐0, ๐1 โ ๐ดโฐ๐พ โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ ฮฃ. Enc ๐พ,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐---------------------------------1.2.3. return ฮฃ. Enc ๐พ,๐
IND-CPA โ Indistinguishability against chosen-plaintext attacks
42
๐๐ฑ๐ฉฮฃindโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$ฮฃ. KeyGen
3. ๐,๐0, ๐1 โ ๐ดโฐ๐พ โ ,โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ ฮฃ. Enc ๐พ,๐,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ,โ ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐,๐---------------------------------1.2.3. return ฮฃ. Enc ๐พ,๐,๐
IND-CPA โ Indistinguishability against chosen-plaintext attacks
43
๐๐ฑ๐ฉฮฃindโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$ฮฃ. KeyGen
3. ๐,๐0, ๐1 โ ๐ดโฐ๐พ โ ,โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ ฮฃ. Enc ๐พ,๐,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ,โ ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐,๐---------------------------------1. if ๐ queried before:2. returnโฅ3. return ฮฃ. Enc ๐พ,๐,๐
Definition: The (nonce-based) IND-CPA-advantage
of an adversary ๐ด is
๐๐๐ฏฮฃindโcpa
๐ด = 2 โ Pr ๐๐ฑ๐ฉฮฃindโcpa
๐ด โ true โ 1
(๐1, ๐1), (๐2, ๐2), โฆ
๐ถ1, ๐ถ2, โฆ
Enc(๐พ,โ )
๐ถ1, ๐ถ2, โฆ
Enc(๐พ,โ )
Test me on ๐,๐0 , (๐,๐1)
๐ถโ
(๐1, ๐1), (๐2, ๐2), โฆ
๐ถโ was an
encryption of ๐1
Nonce-based CTR
โข Nonce value must be updated and stored by sender
โข Stateful encryption
โข Receiver doesn't need to store state
โข Alternatively: pick nonce at random
โข Gives CTR$
โข Common in practice:
โข pick some parts of N at random and let the rest be a counter
(always starting at 0)
โข e.g., 96 bits random and 32 bits counter for 128-bits N
44
Alg Enc ๐พ,๐,๐---------------------------------1. for ๐ = 1, โฆ ,๐ do2. ๐ถ๐ โ โฐ๐พ ๐ + ๐ โ๐๐
3. return ๐ถ1||๐ถ2||โฏ ||๐ถ๐
AlgDec ๐พ,๐, ๐ถ---------------------------------1. for ๐ = 1, โฆ ,๐ do2. ๐๐ โ โฐ๐พ ๐ + ๐ โ ๐ถ๐3. return๐1||๐2||โฏ ||๐๐
Nonce-based CTR โ IND-CPA security
45
Theorem: For any IND-CPA adversary ๐ด against CTR ๐น that runs in time ๐ก๐ด and asks
at most ๐๐ด queries (each of at most ๐๐-bits) โ such that no input values to ๐น are
identical โ there exists an PRF-adversary ๐ต such that
๐๐๐ฏCTR ๐นindโcpa
๐ด โค ๐๐๐ฏ๐นprf
๐ต
where ๐ต runs in time ๐ก๐ต = ๐ก๐ด + ๐(๐๐ด + ๐๐) and asks at most ๐๐ต = ๐ PRF-queries.
CBC
โข IND-CPA secure for random IV
โข Not IND-CPA secure for nonce-based IV (exercise: show this)
โข Not parallelizable; cannot precompute values
โข Inverse of block cipher โฐ needed for decryption
โข Padding needed for messages not a multiple of block length
โข โฆhistorically one of the most used modes-of-operation
47
Alternative definition I โ Left-or-Right CPA
48
๐๐ฑ๐ฉฮฃlorโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$ฮฃ. KeyGen
3. ๐โฒ โ ๐ดLR๐ โ ,โ
4. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
LR๐ ๐0, ๐1
---------------------------------1. if ๐0 โ ๐1 then2. returnโฅ3.4. return ฮฃ. Enc ๐พ,๐๐
Definition: The LOR-CPA-advantage of an
adversary ๐ด is
๐๐๐ฏฮฃlorโcpa
๐ด = 2 โ Pr ๐๐ฑ๐ฉฮฃlorโcpa
๐ด โ true โ 1
Theorem: ฮฃ is IND-CPA secure โบ ฮฃ is LOR-CPA
secure.
Alternative definition II โ Real-or-random CPA
49
๐๐ฑ๐ฉฮฃrorโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$ฮฃ. KeyGen
3. ๐โฒ โ ๐ดRoR๐ โ
4. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
RoR๐ ๐---------------------------------
1. ๐0โ$
0,1 ๐
2. ๐1 โ ๐3. return ฮฃ. Enc ๐พ,๐๐
Definition: The ROR-CPA-advantage of an
adversary ๐ด is
๐๐๐ฏฮฃrorโcpa
๐ด = 2 โ Pr ๐๐ฑ๐ฉฮฃrorโcpa
๐ด โ true โ 1
Theorem: ฮฃ is IND-CPA secure โบ ฮฃ is ROR-CPA
secure.
Alternative definition III โ Real-or-random ciphertext CPA
50
๐๐ฑ๐ฉฮฃind$โcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$ฮฃ. KeyGen
3. ๐โฒ โ ๐ด$๐ โ
4. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
$๐ ๐---------------------------------1. ๐ถ1 โ ฮฃ. Enc ๐พ,๐
2. ๐ถ0โ$
0,1 ๐ถ1
3. return ๐ถ๐
Definition: The IND$-CPA-advantage of an
adversary ๐ด is
๐๐๐ฏฮฃind$โcpa
๐ด = 2 โ Pr ๐๐ฑ๐ฉฮฃind$โcpa
๐ด โ true โ 1
Theorem:
ฮฃ is IND-CPA$ secure โน ฮฃ is IND-CPA secure.
ฮฃ is IND-CPA$ secure โธ ฮฃ is IND-CPA secure.
Relations between notions
51
LOR-CPA โบ IND-CPA โบ ROR-CPA
IND$-CPA
โน
Semantic securityโบ
When we say "IND-CPA" without
further qualification, we think of any
of these (equivalent) definitions
IND-CPA โ Indistinguishability against chosen-plaintext attacks
52
๐๐ฑ๐ฉฮฃindโcpa
๐ด
1. ๐โ$
0,1
2. ๐พโ$ฮฃ. KeyGen
3. ๐0, ๐1 โ ๐ดโฐ๐พ โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ ฮฃ. Enc ๐พ,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐---------------------------------1. return ฮฃ. Enc ๐พ,๐
IND-CCA โ Indistinguishability against chosen-ciphertext attacks
53
๐๐ฑ๐ฉฮฃindโcca ๐ด
1. ๐โ$
0,1
2. ๐พโ$ฮฃ. KeyGen
3. ๐0, ๐1 โ ๐ดโฐ๐พ โ ,๐๐พ โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ ฮฃ. Enc ๐พ,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ,๐๐พ(โ ) ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐---------------------------------1. return ฮฃ. Enc ๐พ,๐
๐๐พ ๐ถ---------------------------------1. if ๐ถ = ๐ถโ then2. returnโฅ3. return ฮฃ. Dec ๐พ,๐
๐๐ฑ๐ฉฮฃindโcca ๐ด
1. ๐โ$
0,1
2. ๐พโ$ฮฃ. KeyGen
3. ๐0, ๐1 โ ๐ดโฐ๐พ โ ,๐๐พ โ // find stage4. if ๐0 โ ๐1 then5. returnโฅ6. ๐ถโ โ ฮฃ. Enc ๐พ,๐๐
7. ๐โฒ โ ๐ดโฐ๐พ โ ,๐๐พ(โ ) ๐ถโ // guess stage
8. ๐ซ๐๐ญ๐ฎ๐ซ๐ง ๐โฒ =?๐
โฐ๐พ ๐---------------------------------1. return ฮฃ. Enc ๐พ,๐
๐๐พ ๐ถ---------------------------------1. if ๐ถ = ๐ถโ then2. returnโฅ3. return ฮฃ. Dec ๐พ,๐
IND-CCA โ Indistinguishability against chosen-ciphertext attacks
54
Definition: The IND-CCA-advantage of an
adversary ๐ด is
๐๐๐ฏฮฃindโcca ๐ด = 2 โ Pr ๐๐ฑ๐ฉฮฃ
indโcca ๐ด โ true โ 1
Test me on ๐0, ๐1
๐ถโ
๐1, ๐2, โฆ
๐ถ1, ๐ถ2, โฆ
Enc(๐พ,โ )
๐1, ๐2, โฆ
๐ถ1, ๐ถ2, โฆ
Enc(๐พ,โ )Dec(๐พ,โ )
Dec(๐พ,โ )
๐ถโ was an
encryption of ๐1