§7 CPA Secure Encryption and Block Cipher Modes of Operation
CPA Secure Encryption
CPA-secure Encryption from Pseudorandom Functions
- Construction of CPA-secure encryption scheme Π from any pseudorandom function. Let F be a pseudorandom function. Define a private-key encryption scheme Π for messages of length n as:
- Gen : given input 1n, output uniform key k←{0,1}n.
- Enc : given inputs a key k∈{0,1}n and a message m∈{0,1}n, choose a uniform r∈{0,1}n and output the ciphertext c:=⟨r,Fk(r)⊕m⟩.
- Dec : given inputs a key k∈{0,1}n and a ciphertext c=⟨r,s⟩, output the plaintext message m:=Fk(r)⊕s.
Security of the CPA-secure encryption scheme
- Theorem. If F is a pseudorandom function, then the construction Π is a CPA-secure private-key encryption scheme for messages of length n.
Block Cipher Modes of Operation
Cipher Block Chaining (CBC) mode
- Gen: On input 1n, output a uniformly chosen key of length n, i.e., k←{0,1}n.
- Enc: To encrypt message m=m1m2…ml where each block mi∈{0,1}n, we do the following:
- Choose random initialization vector (IV) of length n, i.e., set c0=IV←{0,1}n.
- For i=1 to l, set ci=Fk(ci−1⊕mi).
- Output ⟨c0,c1,…,cl⟩.
- Dec: Given inputs ⟨c0,c1,…,cl⟩ and k∈{0,1}n, compute mi:=Fk−1(ci)⊕ci−1 for i=1 to l. Output ⟨m1,…,ml⟩.
- Theorem. If F is a pseudorandom function, then the construction Π is a CPA-secure private-key encryption scheme for messages of length l⋅n.
Electronic Code Book (ECB) mode
- Gen: On input 1n, output a uniformly chosen key of length n, i.e., k←{0,1}n.
- Enc: To encrypt message m=m1m2…ml where each block mi∈{0,1}n, we do the following:
- For i=1 to l, set ci=Fk(mi).
- Output ⟨c1,…,cl⟩.
- Dec: Given inputs ⟨c1,…,cl⟩ and k∈{0,1}n, compute mi:=Fk−1(ci) for i=1 to l. Output ⟨m1,…,ml⟩.
Counter (CTR) mode
- Gen: On input 1n, output a uniformly chosen key of length n, i.e., k←{0,1}n.
- Enc: To encrypt message m=m1m2…ml where each block mi∈{0,1}n, we do the following:
- Choose a uniform value ctr∈{0,1}n. Generate the pseudorandom stream yi:=Fk(ctr+i) where ctr and i are viewed as integers and addition is done modulo 2n.
- For i=1 to l, set ci:=yi⊕mi.
- Output ⟨ctr,c1,…,cl⟩.
- Dec: Given inputs ⟨c0,c1,…,cl⟩ and k∈{0,1}n, compute mi:=Fk(c0+i)⊕ci for i=1 to l. Output ⟨m1,…,ml⟩.
- Theorem. If F is a pseudorandom function, then CTR mode is CPA-secure.
— Feb 14, 2023