12.07.2015 Views

Solution to Problem Set 3 - Zoo - Yale University

Solution to Problem Set 3 - Zoo - Yale University

Solution to Problem Set 3 - Zoo - Yale University

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

YALE UNIVERSITYDEPARTMENT OF COMPUTER SCIENCECPSC 467a: Cryp<strong>to</strong>graphy and Computer Security Handout #11 (rev. 2)Xueyuan Su Oc<strong>to</strong>ber 27, 2008<strong>Solution</strong> <strong>to</strong> <strong>Problem</strong> <strong>Set</strong> 3Due on Wednesday, Oc<strong>to</strong>ber 22, 2008.In the problems below, “textbook” refers <strong>to</strong> Douglas R. Stinson, Cryp<strong>to</strong>graphy: Theory and Practice,Third Edition, Chapman & Hall/CRC, 2006.<strong>Problem</strong> 1: Feistel NetworkTextbook, problem 3.2.<strong>Solution</strong>:In each stage of the Feistel ne<strong>to</strong>wrk, it works as follows:L i+1 = R i (1)R i+1 = L i ⊕ f(R i , K i ) (2)After applying n stages of the Feistel network <strong>to</strong> the plaintext L 0 and R 0 with the key scheduleK 0 , · · · , K n−1 , we get the ciphertext L n and R n .Now we show that the decryption can be done by applying the same encryption algorithm <strong>to</strong> L nand R n , with the reversed key schedule K n−1 , · · · , K 0 . Switching the two sides of (1) and applying(⊕f(R i , K i )) <strong>to</strong> both sides of (2), we getR i = L i+1 (3)L i = R i+1 ⊕ f(R i , K i ) (4)Therefore, after applying the algorithm <strong>to</strong> L n and R n with key K n−1 , we get L n−1 and R n−1 . Thenapplying the algorithm <strong>to</strong> L n−1 and R n−1 with key K n−2 , we get L n−2 and R n−2 . Repeating thesame procedure for n times with the key schedule K n−1 , · · · , K 0 , we get L 0 and R 0 at the end.<strong>Problem</strong> 2: DES Complementation PropertyTextbook, problem 3.3.<strong>Solution</strong>:y = DES(x, K) and y ′ = DES(c(x), c(K)). The heart of DES is the Feistel network, whoseone stage algorithm is described by (1) and (2). For DES(L 0 R 0 , K), define L ′ 0 = c(L 0), R ′ 0 =c(R 0 ) and K ′ i = c(K i), which leads <strong>to</strong> another instance DES(L ′ 0 R′ 0 , K′ ). We will show that forany stage of the Feistel network, L ′ i = c(L i) and R ′ i = c(R i).• Base: the case when i = 1.For instance DES(L 0 R 0 , K),L 1 = R 0 (5)R 1 = L 0 ⊕ f(R 0 , K 0 ) (6)


2 <strong>Solution</strong> <strong>to</strong> <strong>Problem</strong> <strong>Set</strong> 3For instance DES(L ′ 0 R′ 0 , K′ ),L ′ 1 = R ′ 0 = c(R 0 ) = c(L 0 ) (7)R ′ 1 = L ′ 0 ⊕ f(R ′ 0, K ′ 0)= c(L 0 ) ⊕ f(c(R 0 ), c(K 0 )) (8)Since f(R i , K i ) uses the bitwise ⊕ operation <strong>to</strong> combine input bits of R i (after expansion)and K i before the permutation in S-boxes, and ⊕ operation is associative and commutative,Combining (8) and (9) givesc(r) ⊕ c(k) = r ⊕ k (9)R ′ 1 = c(L 0 ⊕ f(R 0 , K 0 )) = c(R 1 ) (10)• Induction: Assume the claim holds for all i < n, consider the case when i = n.For instance DES(L 0 R 0 , K),For instance DES(L ′ 0 R′ 0 , K′ ),L n = R n−1 (11)R n = L n−1 ⊕ f(R n−1 , K n−1 ) (12)L ′ n = R ′ n−1 = c(R n−1 ) (13)R ′ n = L ′ n−1 ⊕ f(R ′ n−1, K ′ n−1)= c(L n−1 ) ⊕ f(c(R n−1 ), c(K n−1 ))= c(L n−1 ⊕ f(R n−1 , K n−1 )) (14)Therefore, after 16 stages of Feistel network, we can get L ′ 16 = c(L 16) and R 16 ′ = c(R 16).Concatenating L ′ 16 and R′ 16 , we concludey ′ = L ′ 16R ′ 16 = c(L 16 R 16 ) = c(y) (15)<strong>Problem</strong> 3: DES S-box S 4Textbook, problem 3.11(a). [Omit part (b).]<strong>Solution</strong>:Each S-box S i maps an input of six bits <strong>to</strong> an output of four bits, i.e., S i : {0, 1} 6 → {0, 1} 4 .S i can be depicted by a 4 × 16 array whose entries are integers in the range [0, 15]. Given a six-bitinput B = b 0 b 1 b 2 b 3 b 4 b 5 , we compute S i (B) as follows. The two bits b 0 b 5 determine the binaryrepresentation of a row r of S i , where 0 ≤ r ≤ 3, while the four bits b 1 b 2 b 3 b 4 determine the binaryrepresentation of a column c of S i , where 0 ≤ c ≤ 15. Then we find the entry corresponding <strong>to</strong> rowr and column c of the 4 × 16 array, and use it binary representation as the four-bit output.For the special property of S 4 , we need <strong>to</strong> check the binary representation of each entry one byone. For example, the first entry of the second row is (13) 10 = (1101) 2 , and the first entry of thefirst 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.


Handout #11 (rev. 2)—Oc<strong>to</strong>ber 27, 2008 3c first row mapping second row0 (7) 10 = (0111) 2 (0, 1, 1, 1) ↦→ (1, 0, 1, 1) ⊕ (0, 1, 1, 0) = (1, 1, 0, 1) (13) 10 = (1101) 21 (13) 10 = (1101) 2 (1, 1, 0, 1) ↦→ (1, 1, 1, 0) ⊕ (0, 1, 1, 0) = (1, 0, 0, 0) (8) 10 = (1000) 22 (14) 10 = (1110) 2 (1, 1, 1, 0) ↦→ (1, 1, 0, 1) ⊕ (0, 1, 1, 0) = (1, 0, 1, 1) (11) 10 = (1011) 23 (3) 10 = (0011) 2 (0, 0, 1, 1) ↦→ (0, 0, 1, 1) ⊕ (0, 1, 1, 0) = (0, 1, 0, 1) (5) 10 = (0101) 24 (0) 10 = (0000) 2 (0, 0, 0, 0) ↦→ (0, 0, 0, 0) ⊕ (0, 1, 1, 0) = (0, 1, 1, 0) (6) 10 = (0110) 25 (6) 10 = (0110) 2 (0, 1, 1, 0) ↦→ (1, 0, 0, 1) ⊕ (0, 1, 1, 0) = (1, 1, 1, 1) (15) 10 = (1111) 26 (9) 10 = (1001) 2 (1, 0, 0, 1) ↦→ (0, 1, 1, 0) ⊕ (0, 1, 1, 0) = (0, 0, 0, 0) (0) 10 = (0000) 27 (10) 10 = (1010) 2 (1, 0, 1, 0) ↦→ (0, 1, 0, 1) ⊕ (0, 1, 1, 0) = (0, 0, 1, 1) (3) 10 = (0011) 28 (1) 10 = (0001) 2 (0, 0, 0, 1) ↦→ (0, 0, 1, 0) ⊕ (0, 1, 1, 0) = (0, 1, 0, 0) (4) 10 = (0100) 29 (2) 10 = (0010) 2 (0, 0, 1, 0) ↦→ (0, 0, 0, 1) ⊕ (0, 1, 1, 0) = (0, 1, 1, 1) (7) 10 = (0111) 210 (8) 10 = (1000) 2 (1, 0, 0, 0) ↦→ (0, 1, 0, 0) ⊕ (0, 1, 1, 0) = (0, 0, 1, 0) (2) 10 = (0010) 211 (5) 10 = (0101) 2 (0, 1, 0, 1) ↦→ (1, 0, 1, 0) ⊕ (0, 1, 1, 0) = (1, 1, 0, 0) (12) 10 = (1100) 212 (11) 10 = (1011) 2 (1, 0, 1, 1) ↦→ (0, 1, 1, 1) ⊕ (0, 1, 1, 0) = (0, 0, 0, 1) (1) 10 = (0001) 213 (12) 10 = (1100) 2 (1, 1, 0, 0) ↦→ (1, 1, 0, 0) ⊕ (0, 1, 1, 0) = (1, 0, 1, 0) (10) 10 = (1010) 214 (4) 10 = (0100) 2 (0, 1, 0, 0) ↦→ (1, 0, 0, 0) ⊕ (0, 1, 1, 0) = (1, 1, 1, 0) (14) 10 = (1110) 215 (15) 10 = (1111) 2 (1, 1, 1, 1) ↦→ (1, 1, 1, 1) ⊕ (0, 1, 1, 0) = (1, 0, 0, 1) (9) 10 = (1001) 2<strong>Problem</strong> 4: Practice with modRead pages 3–4 of textbook and then work the following:(a) Textbook, problem 1.1.(b) Textbook, problem 1.2.(c) Textbook, problem 1.3.(d) Textbook, problem 1.4.<strong>Solution</strong>:• <strong>Problem</strong> 1.1(a) By the division theorem, 7503 = 92 × 81 + 51, so 7503 mod 81 = 51.(b) By the division theorem, −7503 = −93 × 81 + 30, so (−7503) mod 81 = 30.(c) By the division theorem, 81 = 0 × 7503 + 81, so 81 mod 7503 = 81.(d) By the division theorem, −81 = −1 × 7503 + 7422, so (−81) mod 7503 = 7422• <strong>Problem</strong> 1.2By the division theorem, a = m ⌊ am⌋ + (a mod m). Therefore, we have(−a) mod m =( ⌊ )a−m − (a mod m)m⌋= (−(a mod m)) mod mmod m= (m − (a mod m)) mod m (17)


4 <strong>Solution</strong> <strong>to</strong> <strong>Problem</strong> <strong>Set</strong> 3Because a ≢ 0 (mod m), it is easy <strong>to</strong> see that 0 < a mod m < m, which implies 0


Handout #11 (rev. 2)—Oc<strong>to</strong>ber 27, 2008 5b) 357 −1 mod 1234 = 1234 − 159 = 1075c) 3125 −1 mod 9987 = 1844i r i u i v i q i1 1234 1 02 357 0 1 33 163 1 -3 24 31 -2 7 55 8 11 -38 36 7 -35 121 17 1 46 -159i r i u i v i q i1 9987 1 02 3125 0 1 33 612 1 -3 54 65 -5 16 95 27 46 -147 26 11 -97 310 27 5 240 -767 28 1 -577 1844<strong>Problem</strong> 6: Linear Diophantine EquationsTextbook, problem 5.4. Show your work.<strong>Solution</strong>:gcd(57, 93) = 3s = −13, t = 8a b93 5757 3636 2121 1515 66 33 0i r i u i v i q i1 19 1 02 31 0 1 03 19 1 0 14 12 1 0 15 7 2 -1 16 5 -3 2 17 2 5 -3 28 1 -13 8


6 <strong>Solution</strong> <strong>to</strong> <strong>Problem</strong> <strong>Set</strong> 3<strong>Problem</strong> 7: RSA Encryption[This is problem 6.8.2 from Trapp & Washing<strong>to</strong>n, “Introduction <strong>to</strong> Cryp<strong>to</strong>graphy 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.(a) Find the decryption modulus d.(b) Assume that gcd(m, 55) = 1. Show that if c ≡ m 3 (mod 55) is the ciphertext, then theplaintext is m ≡ c d (mod 55). Do not quote the fact that RSA decryption works. That iswhat you are showing in this specific case.<strong>Solution</strong>:(a) Since n = 55 = 5 × 11, we have φ(n) = (5 − 1) × (11 − 1) = 40. Now we apply theExtended Euclidean algorithm <strong>to</strong> find d given that e = 3.Therefore, we have d = 40 − 13 = 27.i r i u i v i q i1 40 1 02 3 0 1 133 1 1 -13(b) The question asks us <strong>to</strong> prove m ≡ c 27 (mod 55), given c ≡ m 3 (mod 55) andgcd(m, 55) = 1. Starting from the first condition, we havec ≡ m 3 (mod 55) ⇒ c 27 ≡ (m 3 ) 27 ≡ (m 40 ) 2 × m (mod 55) (26)Euler’s theorem says, if gcd(x, n) = 1, thenx φ(n) ≡ 1 (mod n) (27)Since φ(55) = 40 and gcd(m, 55) = 1, combining (26) and (27) givesBecause congruence is commutative, (28) impliesc 27 ≡ (m 40 ) 2 × m ≡ m (mod 55) (28)m ≡ c 27 (mod 55) (29)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!