Crypto Week4
Crypto Week4
1
2
(i.e. one which always outputs the same ciphertext for a given plaintext), an
adversary can win the above experiment with probability 1.
We can now dene CPA security for an encryption system.
Denition 1. We say that a private-key encryption scheme Π = (Gen, Enc, Dec)
is CPA-secure if for all PPT adversaries A, there is a negligible function
negl() such that:
CP A 1
P r[P rivA,Π (n) = 1] ≤ + negl(n).
2
Recall that in a block cipher, we divide a message into blocks of xed size
and also that an encryption algorithm such as DES or AES can encrypt one
block.
We now discuss the important issue of how to encrypt a message with several
blocks using an encryption algorithm.
The most obvious way is to encrypt each block separately and then concate-
nate all the corresponding ciphertexts and is called the Electronic Cook Book
(ECB) mode. However, the ECB mode is insecure in at least two ways.
Firstly, ECB encryption is deterministic and hence cannot be CPA-
secure.
Secondly, partial information is always leaked when two message blocks
are identical. For example, if the ciphertext looks like C1 C2 C1 C3 , then
an eavesdropper can see that the rst and third blocks are the same,
and even this is information that should not be leaked. This also opens
up the possibility of tampering for an active adversary, as they may be
able to modify just some blocks and send a valid and dierent ciphertext
to the receiver.
The main conclusion is that ECB mode should never be used for block cipher
encryption.
3
We now describe the rst solution that addresses the drawbacks of ECB
mode. The Cipher Block Chaining (CBC) mode works as follows. Suppose
that the message is M = M1 M2 . . . ML , where each Mi is a n-bit block.
1. A random initialization vector (IV) is generated from {0, 1}n .
2. The rst cipherblock is computed as C1 = Enc(M1 ⊕ IV, k).
3. Each successive block is computed as Ci = Enc(Mi ⊕ Ci−1 , k).
4. The nal ciphertext is IV ||C1 || . . . ||CL .
It turns out that CBC Mode when used with a PRP as the encryption func-
tion, is CPA-secure. We do not formally prove this though, and instead give
a proof for the CTR mode (net section).
We mention a couple of drawbacks of CBC mode:
It cannot be parallelized.
When the last message block is shorter than the block size, it needs to
be padded and this can lead to padding attacks (discussed later).
The Counter Mode (also sometimes called Randomized Counter Mode) works
as follows. As before, let M = M1 . . . ML be the message.
As in CBC mode, a random IV is chosen from {0, 1}n .
The ith cipherblock is generated as Ci = Mi ⊕ Enc(IV + i − 1, k).
The IV used in CTR mode is usually called a counter (as it is incremented
for each block), hence the name of the mode.
The advantages of this mode over CBC mode are that it can be parallelized
(as each cipherblock can be generated independently of any other given the
IV) and it does not use padding.
In the next section, we show that a block cipher used in CTR mode is CPA-
secure if the encryption algorithm is a PRP.
4
1 1 1 r(n)
p1 (n) + (1 − p2 (n)) = +
2 2 2 2
which is non-negligible if r(n) is non-negligible. This contradicts the fact
that Enc is a PRP, therefore it must be the case that (1) is true.
We now prove (2). Let q = q(n). Let M1 = M1,1 || . . . ||M1,q and M2 =
M2,1 || . . . ||M2,q be the two messages chosen by the adversary, where each
Mi,j is a block. Let C = IV ||Ci,1 || . . . Ci,q be the ciphertext corresponding to
Mi , where i ∈ {1, 2}. C is the ciphertext received by the adversary.
Let Mi = Mi,1 || . . . ||Mi,q for i = 3, . . . , q + 2 be the messages queried by the
adversary and let Ci = IVi ||Ci,1 || . . . ||Ci,q be the corresponding ciphertexts.
We have for i ≥ 3:
Ci,j = Mi,j ⊕ π(IVi + j − 1, k). (3)