




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





University of Illinois, Urbana Champaign CS/ECE 498AC3/4 Applied Cryptography
Instructor: Dakshita Khurana Scribe: Jason Liu, Nikil Ravi Date: September 08, 2020
Block Ciphers (Continued), Message Authentication
Last lecture, we looked in-depth at AES, a secure block cipher, as well as ways to actually encrypt data with block ciphers. There are notable pitfalls to avoid when using a block cipher (which expects fixed-length input) on variable-length messages; for example, we can’t just na¨ıvely use the block cipher on each block in the message, since individual messages could be the same, resulting in frequency analysis attacks. We were able to produce a stream cipher from a block cipher, although we are still limited to one-time keys. In the first half of this lecture, we work on fixing this problem, so that we can potentially reuse the same key to encrypt multiple messages. As we saw in the course introduction, there is more to cryptography than secretly trans- mitting messages. Another common problem in security that we will address is integrity, which is in many ways the dual of secrecy. Rather than considering a sender entrusting only some select receivers with their message, we now consider a receiver who is deciding whether they can trust the sender. This problem is orthogonal to secrecy — knowing that nobody else could read a message doesn’t guarantee that you can trust its sender. For example, how can you be sure that a message you received is not from someone impersonating the sender? In the second half of the lecture, we will examine Message Authentication Codes (MACs), a scheme that addresses this problem.
We have seen how to encrypt arbitrarily-long inputs with smaller keys, but so far, we require a new key for every message. For some applications, it would be nice to be able to use the same key for multiple encryptions. For example, an encrypted filesystem that required a new key for each file would be inefficient and unwieldy to use. Similarly, IP connections typically involve exchanging many small packets; it would be a massive overhead (or even impossible, depending on the packet and key size) to try to constantly negotiate a new key for every encrypted packet under IPsec. In these cases, we really want to be able to reuse the same key. First, let’s formalize exactly what many-time security means. Recall our definition of one-time security block ciphers:
Definition 5.1. (^) E is CPA-secure iff
∀m 0 , m 1 ∈ { 0 , 1 }^128. (^) E k←K
(k, m 0 ) ≈ (^) E k←K
(k, m 1 ) (5.1)
where ≈ signifies indistinguishability, i.e., that an adversary cannot (within some error ) tell the difference between the two distributions. Notice that although we assume the block size to be 128 above, this is not a general requirement for one-time security. We are also sampling some key k at random from key space K in both encryptions. (One consequence of sampling k at random from K is that there is no requirement for both ks in the equation to be the same.) To extend this to many-time keys, we should be able to encrypt n pairs of (potentially different) messages with only one key k while ensuring the two distributions are still indis- tinguishable. Specifically:
Definition 5.2. E is many-time CPA-secure iff
∀ m~ 0 = (m^10 , m^20 ,... , mn 0 ) m ~ 1 = (m^11 , m^21 ,... , mn 1 ). ( E(k, m^10 ), E(k, m^20 ),... , E(k, mn 0 )
k←K ≈^
E(k, m^11 ), E(k, m^21 ),... , E(k, mn 1 )
k←K (5.2) where each vector m~ contains n messages. The distributions of n ciphertexts (as opposed to just one), each encrypted with only one key k, are indistinguishable. Just as before, both keys k are sampled at random, and are thus not required to be the same. Also note that there are no restrictions on the actual messages — it is possible for a message to repeat within a vector. We just need n arbitrary messages per vector. This definition already encodes an extra restriction we must put on many-time security: encrypting the same message m multiple times with the same key k must still result in what appears to be a randomly sampled ciphertext c. Specifically, this means that we expect to see a different output c for each encryption of m; otherwise, the frequency analysis attacks we have seen before will be possible. Notice that based on our formalization of many-time keys, this requirement already holds:
Claim 5.3. Under Definition 5.2, encrypting the same message m multiple times with the same key k will result in distinct ciphertexts.
Proof. Suppose, for the sake of contradiction, that encrypting m multiple times with the same key k resulted in the same ciphertext c. An adversary could challenge E as follows: in game 1, the adversary encrypts m~ 1 containing n copies of the same message m. In game 2, the adversary encrypts m~ 2 containing n random distinct messages. Then the ciphertexts for game 1, ~c 1 , will all be the same due to the assumption, while the ciphertexts for game 2, ~c 2 , will all be different. The adversary can trivially distinguish game 1 from game 2 by outputting whether the ciphertexts are the same or not, contradicting indistinguishability in Definition 5.2. Therefore, encrypting m multiple times with the same k must result in different ciphertexts.
Based on this, we already know that E will require at least one more input for many-time encryption, since E(k, m) given the same k and m will always produce the same output c. Next, we look at actual strategies to achieve many-time security.
Cipher block chaining also uses randomization to achieve many-time security. For a PRP (E, D) — recall that block ciphers are also PRPs — CBC allows us to create a many-time stream cipher; i.e., we can encrypt arbitrarily-sized messages and re-use the same key for multiple messages. We will need to split m into blocks, i.e., m = m[0] ‖ m[1] ‖... ‖ m[L]. For example, using AES, the block size is 128, so each chunk will be 128 bits long. For a message that is shorter than a multiple of 128 bits, the end will have to be padded somehow. If it is important to know exactly where the padding begins, one padding scheme is: add a single 1, then as many 0s as required to reach a length that is a multiple of 128. Deciding where the padding begins is done by scanning for the first 1 backwards from the end of the message. We’ll see this again for MACs later.
Definition 5.5. For encryption ECBC (k, m) = (IV, c), the ciphertext is computed as fol- lows:
c[i] =
E(k, IV ⊕ m[0]), i = 0 E(k, c[i − 1] ⊕ m[i]), L ≥ i > 0
where IV is the Initialization Vector, a fancy way of saying a random nonce, and L + 1 is the total number of message blocks. See page 9 of the lecture slides for a good pictoral version of this. Inductively, we know that each c[i] is indistinguishable from uniformly random, and so we can produce each successive c[i + 1] using something indistinguishable from random input; then only the first ciphertext, c[0], needs some random input. The benefit we gain is that rather than having to output L 128-bit random values, we only need to output one 128-bit random IV. Much like nonces earlier, we still require that each message use a different IV , as otherwise, ECBC (k, m) will end up producing the same ciphertext when given the same k and m multiple times.
Definition 5.6. Decryption DCBC (IV, k, c) = m must undo each step:
m[i] =
D(k, c[0]) ⊕ IV, i = 0 D(k, c[i]) ⊕ c[i − 1], L ≥ i > 0
Page 10 of the lecture slides has a pictoral version of this; however, notice that decryption is not sequential. In fact, decryption is actually parallelizable, unlike encryption. This is because decryption relies purely on the input c, while encryption requires the output of the previous chunk.
Theorem 5.7. For small L, if PRP E is secure over (K, X ), then ECBC is CPA-secure
over (K, X L, X L+1), and εCBC = 2εP RP + q
(^2) L 2 |X | , where^ q^ is the total number of messages encrypted and L is the number of blocks in a message.
We defer the proof of this to external sources. However, we briefly note that the squares in q^2 L^2 originate from the “birthday bound” when considering the probability that two randomly chosen values are equal. For two blocks identical blocks in different indices, i.e., i, j ∈ [0, L] where m[i] = m[j], the resulting ciphertexts should be different. The probability that c[i] and c[j] are different is at least the probability that the XOR’d uniform random inputs (i.e., c[i − 1] and c[j − 1]) are different, which scales with the squared input size due
to the “birthday bound.” In this case, the squares are not problematic to this error bound because the denominator |X | = 2block length; this exponential is asymptotically larger than any polynomial. Essentially, the block length can be considered a security parameter of CBC. We discussed before that IV must be random (and thus unpredictable). Interestingly, SSL/TLS 1.0 used the final ciphertext block of the previous message as the IV , which led to a security bug, as this is no longer CPA-secure. To see why, let us consider the indistinguishability game for CPA security.
Claim 5.8. To be CPA-secure, the IV in CBC must be unpredictable.
Proof. Suppose, for the sake of contradiction, that given one IV , the adversary could some- how predict the next IV. Consider the following adversary:
Game 1 Game 2 Challenger Adversary Challenger Adversary ← 0 ← 0 → (IV 1 , c 0 = E(k, IV 1 )) → (IV 1 , c 0 = E(k, IV 1 ))
← m 1 = IV 1 ⊕ IV 2 ← m 2 6 = m 1 → (IV 2 , c 1 = E(k, IV 1 )) → (IV 2 , c 2 = E(k, m 2 ⊕ IV 2 ))
First, the adversary passes in 0 in both games. Because the adversary can predict IV 2 after seeing IV 1 , they can pass in IV 1 ⊕ IV 2 in game 1, while picking some arbitrary message in game 2. The resulting ciphertext in game 1 is E(k, m 1 ⊕ IV 2 ) = E(k, IV 1 ⊕ IV 2 ⊕ IV 2 ) = E(k, IV 1 ), while the ciphertext in game 2 is some apparently random c 2. However, because 0 ⊕ IV 1 = IV 1 , the first ciphertext in game 1 will be equal to the second. The adversary can then trivially distinguish the two games by outputting whether c 0 = c 1 (i.e., game 1) or not (i.e., game 2, where they instead have c 0 6 = c 2 ), contradicting indistinguishability.
An interesting point is that this only breaks the encryption of IV s. That may or may not lead to breaking the underlying E; it depends on the actual underlying scheme of E. There is another version of CBC where rather than using a uniform random IV , ECBC 2 also accepts a unique nonce. This nonce is encrypted using a separate key k 1 and then used as the IV ; the nonce is then also output: ECBC 2 ((k 1 , k), m, n) = (n, ECBC (k, m) with IV = E(k 1 , n)).
Let F : K × { 0 , 1 }n^ be a PRF. Just as in CBC, break m into L blocks of size n. Sample a random IV ∈ { 0 , 1 }n.
Definition 5.9. The random-counter many-time cipher is:
ERAN DCT R(k, m) = (IV, F (k, IV + i) ⊕ m[i]) ∀i ∈ [0, L] (5.7) DRAN DCT R(IV, k, m) = F (k, IV + i) ⊕ m[i] ∀i ∈ [0, L] (5.8)
This scheme has the notable benefit of being parallelizable, and also only requiring a PRF (as opposed to the more constrained PRP required by CBC). PRFs may even be more efficient than PRPs, because they don’t need to be invertible.
We now turn to constructing a secure MAC using a secure PRF. The reason we turn to a PRF is that it prevents one from guessing the output of the PRF on any input that is different from the inputs that have already been queried. This is precisely what we need for our security condition in the definition of MAC above.
Here is the proposed construction of MAC using a PRF:
Claim 5.11. The MAC defined above satisfies the correctness property.
Proof. This follows directly from the definition of the correctness property for a MAC. V(k, m, tag) returns accept if and only if tag = PRF(k, m). Thus, this construction of the MAC satisfies the correctness property.
Claim 5.12. The MAC defined above satisfies the security property.
Proof. By PRF security, ∀ m′^ ∈ {/ m 1 , m 2 , ..., mn},
PRF(k, m′) ≈ Uniform random α-bit string r (α is the length of the PRF’s output)
Let P 1 = P r(Adv generates (m′, t′), such that t′^ = PRF(k, m′)). This probability is exactly M AC , or the error in the MAC. Let P 2 = P r(Adv generates (m′, t′), such that t′^ ← r). Note that [P 2 = 2−α] . Now,we know that P 1 ≤ P RF + P 2 where P RF is the error in the PRF. Therefore, M AC ≤ P RF + 2−α, as required.
Now that we have defined and given a construction of an MAC, let us look at some examples of MACs.
These scribe notes were prepared by editing a light modification of the template designed by Alexander Sherstov. [1] D. Boneh and V. Shoup. A Graduate Course in Applied Cryptography. Cambridge University Press, 0.5 edition, 2020.