YALE UNIVERSITY
DEPARTMENT OF COMPUTER SCIENCE
| CPSC 467a: Cryptography and Computer Security | Handout #13 |
Xueyuan Su | | November 4, 2008 |
|
|
|
|
Solution to Midterm Examination
Instructions:
This is a closed book examination. Answer any 5 of the following 6 questions. Write the numbers of the five
questions that you want graded on the cover of your bluebook. All questions count equally. You have 75
minutes. Remember to write your name on your bluebook and to justify your answers. Good
Luck!
___________________________________________________________________________________
Problem 1: Symmetric Cryptosystems and Information Security
Consider the encryption function for a symmetric cryptosystem described by the table below, where
=
=
= {0,1,2,3}:
- Give the corresponding decryption function.
- What does it mean for a cryptosystem to be information-theoretically secure?
- Is this cryptosystem information-theoretically secure? Why or why not?
Solution:
- From the original encryption function, we can easily derive the decryption function as:
- For the cryptosystem to have perfect secrecy (be information-theoretically secure), it means that the
random variables c and m are statistically independent, that is,
![prob[m = m0 ∧c = c0] = prob[m = m0 ]× prob[c = c0]](ho132x.png) | (1) |
for all m0 
and c0 
. An equivalent definition in terms of conditional probability
is
![prob[m = m | c = c ] = prob[m = m ]
0 0 0](ho133x.png) | (2) |
for all m0 
and c0 
such that prob[c = c0]≠0. Hence, even after Eve receives the ciphertext
c0, her opinion of the likelihood of each message m0 is the same as it was initially, so she has
learned nothing about m0.
- No, this cryptosystem is not information-theoretically secure. A simple observation is that
prob[m = 3] = 1∕4, but prob[m = 3∣c = 0] = 0. Similarly, prob[m = 2] = 1∕4, but
prob[m = 2∣c = 1] = 0. Therefore, after receiving c = 0 or c = 1, we have learned partial
information about m.
Problem 2: Attacks
We have discussed a number of different possible attacks on a cryptosystem by a passive eavesdropper
Eve, depending on what information is available to her.
- Describe the following three kinds of attack on a cryptosystem: ciphertext only, known
plaintext, chosen plaintext. For each, give a scenario in which such an attack might be
plausible for Eve to carry out.
- Consider the following simple cryptosystem: A message m = m1m2…mt is a t-bit string. A
key is a single bit k
{0,1}. The encryption function is Ek(m) = c, where c = c1c2…ct and
ci = mi ⊕ b, for i = 1,…,t. Discuss the security of this system under each of the three kinds
of attacks (from part (a) above). Where the system is insecure, describe carefully the sense
in which it insecure. Be sure to say also how the security is affected by the choice of t.
Solution:
-
-
Ciphertext-only
- Eve knows only c and tries to recover m. Eve is able to perform such attack
if she has access to the communication channel between Alice and Bob, for example, if
she controls the gateway through which Alice accesses the Internet.
-
Known plaintext
- Eve knows a sequence of plaintext-ciphertext pairs (m1,c1), …, (mr,cr).
Now she obtains a new ciphertext c ⁄
{c1,…,cr} and wants to recover the
corresponding message m. Eve is able to perform such an attack if the previous
plaintext-ciphertext pairs are revealed by Alice or Bob. Eve might also get information
about the previous plaintext-ciphertext pairs by looking into Alice’s swap files.
-
Chosen plaintext
- This is like a known plaintext attack, except that before getting c, Eve
gets to choose messages m1, …, mr and somehow get Alice (or Bob) to encrypt them for
her and supply her with the corresponding ciphertexts c1, …, cr. Eve is able to perform
such attack if Alice is a server that provides encryption service. Eve can also perform
such an attack on an asymmetric cryptosystem such as RSA where she has access to the
public encryption key.
-
-
Ciphertext-only
- When t = 1, this cryptosystem is information-theoretically secure. When
t > 1, Eve is able to get partial information about the plaintext. In particular, if the
ciphertext is c = c1…ct, she knows that the plaintext is either c or
(the complement of
c).
-
Known plaintext
- Whatever length the message is, one plaintext-ciphertext pair is sufficient
to recover the key and break the cryptosystem.
-
Chosen plaintext
- A chosen plaintext attack is stronger than a known plaintext attack, so
again, whatever length the message is, one plaintext-ciphertext pair is sufficient to
recover the key and break the cryptosystem.
Problem 3: DES
Recall that the heart of DES is a round of the form:
Consider a simplified DES-like cryptosystem consisting of n such rounds, where the function f is defined by
fK(X) = K ⊕ X. Here we assume that the key K is 32-bits long and that the same key is used at each
round, that is, Ki = K for each round i.
This system is used to encrypt a 64-bit message M as follows: L0 is the leftmost 32-bits of M and R0
is the rightmost 32-bits of M. The ciphertext EK(M) is Ln ⋅ Rn.
- Describe how to decrypt messages encrypted with EK.
- Express L1, R1, L2, R2 in terms of L0, R0, and K.
- Show why increasing the number of rounds n can actually decrease security.
Solution:
- This is a simplified DES-like cryptosystem. Like DES, decryption can be done by starting with the
left and right halves of the ciphertext, Ln and Rn respectively, and working backwards round by
round to the plaintext message M = L0 ⋅ R0. In round i of encryption, the algorithm works as
follows: To decrypt, we solve (3) to express Li and Ri in terms of Li+1 and Ri+1. This yields
Applying (4) for i = n - 1,n - 2,…,0 yields the desired plaintext.
We remark that, also like DES, the encryption and decryption functions for each round are almost the
same. Let EK(Li ⋅ Ri) = Li+1 ⋅ Ri+1 be the encryption function defined by (3). Let
DK(Li+1 ⋅Ri+1) = Li ⋅Ri be the corresponding decryption function defined by (4). One can easily
verify that
 | (5) |
Thus, if S(L⋅R) = R ⋅L is the function that swaps the left and right halves of its 64-bit argument,
then it follows from (5) that
 | (6) |
-
- If we continue the encryption to the third round, we will find that Therefore, increasing the number of rounds from 2 to 3 results in the ciphertext being identical to the
plaintext, so there is no security at all.
Problem 4: Chaining Modes
Let (E,D) be a block cipher and let m1,m2,…,mt be a sequence of t plaintext blocks. Happy
Hacker was not happy with the chaining modes he learned about in CPSC 467, so he invented his
own. He defines a sequence of t + 2 ciphertext blocks c0,c1,c2,…,ct,ct+1 which satisfies the
equation
- Describe how to reconstruct m1,…,mt given c0,…,ct+1.
- Happy was having trouble figuring out how to compute the ci’s because of the cirular
dependencies. Please help him by showing how to compute ci+1 from ci-1, ci, and mi, where
1 ≤ i ≤ t. How should he choose c0 and c1?
Solution:
- For i = 1, …, t, we have the condition
 | (10) |
Applying decryption function to both sides of (10) gives
Adding (using ⊕) the expression (⊕ci-1 ⊕ ci+1) to (11) and swapping the two sides
gives
 | (12) |
- Adding (using ⊕) (⊕ci-1 ⊕ mi) to (11) and swapping the two sides gives
 | (13) |
where 1 ≤ i ≤ t. In order to get started, we set c0 and c1 to some fixed initialization
vectors.
Problem 5: RSA
My toy RSA key is N = 187,e = 107. You observe a ciphertext c = 2. What is the plaintext? (Note:
187 = 11 * 17.)
Solution:
Given N = 187 = 11 × 17, it is easy to compute ϕ(N) = (11 - 1) × (17 - 1) = 160.
Next, given e = 107, which is relative prime to 160, we use extended Euclidean algorithm to compute d
such that ed ≡ 1 (mod 107):
i | ri | ui | vi | qi |
|
|
|
|
|
1 | 160 | 1 | 0 | |
2 | 107 | 0 | 1 | 1 |
3 | 53 | 1 | -1 | 2 |
4 | 1 | -2 | 3 | |
|
The result from the table is d = v4 = 3.
Finally we apply the decryption function of RSA to get the plaintext
 | (14) |
Problem 6: Euler’s Theorem
- Define Euler’s totient function ϕ(n), and state Euler’s theorem.
- Calculate 2549
mod 29.
(Hint: This problem is easily solved by hand using Euler’s theorem to reduce the size of the
exponents.)
Solution:
- Let Z*
n = {a
Zn∣gcd(a,n) = 1}, then Euler’s totient function ϕ(n) is the cardinality of Z*n. If
we represent an integer n by its prime factors as follows
 | (15) |
then ϕ(n) can be calculated as
 | (16) |
Euler’s theorem says, for every x that is relative prime to n,
 | (17) |
- Given n = 29, it is easy to compute ϕ(29) = 29-1 = 28, and ϕ(ϕ(29)) = (2-1)×22-1 ×(7-1) = 12.
After verifying gcd(5,28) = 1, applying Euler’s theorem gives
 | (18) |
Therefore after verifying gcd(2,29) = 1, we have
 | (19) |
which implies 2549
mod 29 = 251
mod 29 = 3.