YALE UNIVERSITY
DEPARTMENT OF COMPUTER SCIENCE

 CPSC 467a: Cryptography and Computer SecurityHandout #11 (rev. 2)
Xueyuan Su   October 27, 2008



 

Solution to Problem Set 3

Due on Wednesday, October 22, 2008.

In the problems below, “textbook” refers to Douglas R. Stinson, Cryptography: Theory and Practice, Third Edition, Chapman & Hall/CRC, 2006.

Problem 1: Feistel Network

Textbook, problem 3.2.

 
Solution:

In each stage of the Feistel netowrk, it works as follows:

Li+1  =  Ri                                       (1)
Ri+1  =  Li ⊕ f(Ri,Ki )                           (2)
After applying n stages of the Feistel network to the plaintext L0 and R0 with the key schedule K0,⋅⋅⋅,Kn-1, we get the ciphertext Ln and Rn.

Now we show that the decryption can be done by applying the same encryption algorithm to Ln and Rn, with the reversed key schedule Kn-1,⋅⋅⋅,K0. Switching the two sides of (1) and applying (f(Ri,Ki)) to both sides of (2), we get

Ri  =  Li+1                                       (3)
Li  =  Ri+1 ⊕ f(Ri,Ki )                           (4)
Therefore, after applying the algorithm to Ln and Rn with key Kn-1, we get Ln-1 and Rn-1. Then applying the algorithm to Ln-1 and Rn-1 with key Kn-2, we get Ln-2 and Rn-2. Repeating the same procedure for n times with the key schedule Kn-1,⋅⋅⋅,K0, we get L0 and R0 at the end.

Problem 2: DES Complementation Property

Textbook, problem 3.3.

 
Solution:

y = DES(x,K) and y = DES(c(x),c(K)). The heart of DES is the Feistel network, whose one stage algorithm is described by (1) and (2). For DES(L0R0,K), define L0 = c(L0), R0 = c(R0) and Ki = c(Ki), which leads to another instance DES(L0R0,K). We will show that for any stage of the Feistel network, Li = c(Li) and Ri = c(Ri).

Therefore, after 16 stages of Feistel network, we can get L16 = c(L16) and R16 = c(R16). Concatenating L16 and R16, we conclude

y′ = L′16R ′16 = c(L16R16) = c(y)
(15)

Problem 3: DES S-box S4

Textbook, problem 3.11(a). [Omit part (b).]

 
Solution:

Each S-box Si maps an input of six bits to an output of four bits, i.e., Si : {0,1}6 →{0,1}4. Si can be depicted by a 4 × 16 array whose entries are integers in the range [0,15]. Given a six-bit input B = b0b1b2b3b4b5, we compute Si(B) as follows. The two bits b0b5 determine the binary representation of a row r of Si, where 0 r 3, while the four bits b1b2b3b4 determine the binary representation of a column c of Si, where 0 c 15. Then we find the entry corresponding to row r and column c of the 4 × 16 array, and use it binary representation as the four-bit output.

For the special property of S4, we need to check the binary representation of each entry one by one. For example, the first entry of the second row is (13)10 = (1101)2, and the first entry of the first row is (7)10 = (0111)2. Applying the mapping, we have

(0,1,1,1) ↦→ (1,0,1,1)⊕  (0,1,1,0) = (1,1,0,1)
(16)

We put the results for all the 16 entries in the table below.

c first row mapping second row




0 (7)10 = (0111)2 (0,1,1,1)↦→(1,0,1,1) (0,1,1,0) = (1,1,0,1)(13)10 = (1101)2
1 (13)10 = (1101)2(1,1,0,1)↦→(1,1,1,0) (0,1,1,0) = (1,0,0,0) (8)10 = (1000)2
2 (14)10 = (1110)2(1,1,1,0)↦→(1,1,0,1) (0,1,1,0) = (1,0,1,1)(11)10 = (1011)2
3 (3)10 = (0011)2 (0,0,1,1)↦→(0,0,1,1) (0,1,1,0) = (0,1,0,1) (5)10 = (0101)2
4 (0)10 = (0000)2 (0,0,0,0)↦→(0,0,0,0) (0,1,1,0) = (0,1,1,0) (6)10 = (0110)2
5 (6)10 = (0110)2 (0,1,1,0)↦→(1,0,0,1) (0,1,1,0) = (1,1,1,1)(15)10 = (1111)2
6 (9)10 = (1001)2 (1,0,0,1)↦→(0,1,1,0) (0,1,1,0) = (0,0,0,0) (0)10 = (0000)2
7 (10)10 = (1010)2(1,0,1,0)↦→(0,1,0,1) (0,1,1,0) = (0,0,1,1) (3)10 = (0011)2
8 (1)10 = (0001)2 (0,0,0,1)↦→(0,0,1,0) (0,1,1,0) = (0,1,0,0) (4)10 = (0100)2
9 (2)10 = (0010)2 (0,0,1,0)↦→(0,0,0,1) (0,1,1,0) = (0,1,1,1) (7)10 = (0111)2
10 (8)10 = (1000)2 (1,0,0,0)↦→(0,1,0,0) (0,1,1,0) = (0,0,1,0) (2)10 = (0010)2
11 (5)10 = (0101)2 (0,1,0,1)↦→(1,0,1,0) (0,1,1,0) = (1,1,0,0)(12)10 = (1100)2
12(11)10 = (1011)2(1,0,1,1)↦→(0,1,1,1) (0,1,1,0) = (0,0,0,1) (1)10 = (0001)2
13(12)10 = (1100)2(1,1,0,0)↦→(1,1,0,0) (0,1,1,0) = (1,0,1,0)(10)10 = (1010)2
14 (4)10 = (0100)2 (0,1,0,0)↦→(1,0,0,0) (0,1,1,0) = (1,1,1,0)(14)10 = (1110)2
15(15)10 = (1111)2(1,1,1,1)↦→(1,1,1,1) (0,1,1,0) = (1,0,0,1) (9)10 = (1001)2

Problem 4: Practice with mod

Read pages 3–4 of textbook and then work the following:

  1. Textbook, problem 1.1.
  2. Textbook, problem 1.2.
  3. Textbook, problem 1.3.
  4. Textbook, problem 1.4.

 
Solution:

Problem 5: Extended Euclidean Algorithm

Textbook, problem 5.3. Show your work.

 
Solution:

a) 17-1 mod 101 = 6

i ri uiviqi





1101 1 0
2 17 0 1 5
3 16 1 -5 1
4 1 -1 6 16

b) 357-1 mod 1234 = 1234 - 159 = 1075

i ri ui vi qi





11234 1 0
2 357 0 1 3
3 163 1 -3 2
4 31 -2 7 5
5 8 11 -38 3
6 7 -35 121 1
7 1 46 -159

c) 3125-1 mod 9987 = 1844

i ri ui vi qi





19987 1 0
23125 0 1 3
3 612 1 -3 5
4 65 -5 16 9
5 27 46 -147 2
6 11 -97 310 2
7 5 240 -767 2
8 1 -5771844

Problem 6: Linear Diophantine Equations

Textbook, problem 5.4. Show your work.

 
Solution:

gcd(57,93) = 3

a b


9357
5736
3621
2115
15 6
6 3
3 0

s = -13, t = 8

iri ui viqi





119 1 0
231 0 1 0
319 1 0 1
412 1 0 1
5 7 2 -1 1
6 5 -3 2 1
7 2 5 -3 2
8 1 -13 8

Problem 7: RSA Encryption

[This is problem 6.8.2 from Trapp & Washington, “Introduction to Cryptography with Coding Theory, Second Edition”, Pearson Prentice Hall, 2006.]

Suppose your RSA modulus is n = 55 = 5 × 11 and your encryption exponent is e = 3.

  1. Find the decryption modulus d.
  2. Assume that gcd(m,55) = 1. Show that if c m3 (mod 55) is the ciphertext, then the plaintext is m cd (mod 55). Do not quote the fact that RSA decryption works. That is what you are showing in this specific case.

 
Solution:

(a) Since n = 55 = 5 × 11, we have ϕ(n) = (5 - 1) × (11 - 1) = 40. Now we apply the Extended Euclidean algorithm to find d given that e = 3.

iriui vi qi





140 1 0
2 3 0 1 13
3 1 1 -13

Therefore, we have d = 40 - 13 = 27.

(b) The question asks us to prove m c27 (mod 55), given c m3 (mod 55) and gcd(m,55) = 1. Starting from the first condition, we have

c ≡ m3 (mod 55) ⇒  c27 ≡ (m3)27 ≡ (m40)2 × m (mod  55)
(26)

Euler’s theorem says, if gcd(x,n) = 1, then

 ϕ(n)
x    ≡ 1 (mod n )
(27)

Since ϕ(55) = 40 and gcd(m,55) = 1, combining (26) and (27) gives

c27 ≡ (m40 )2 × m ≡ m  (mod  55)
(28)

Because congruence is commutative, (28) implies

     27
m ≡ c   (mod 55 )
(29)