



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!




Euclid’s Algorithm and the RSA Encryption Scheme
(a) 90 and 56 (b) 91 and 89 (c) 711 and 75 (d) 815 and 75 (e) 112 and 196 (f) 366 and 150
(a) p = 7, q = 13, e = 5 (b) p = 5, q = 11, e = 3 (c) p = 7, q = 17, e = 7
(a) 12 (b) 9 (c) 27 (d) 84
Solution:
ExtendedEuclidGCD(a, b) Input: Nonnegative integers a and b (not both zero). Output: d = gcd(a, b), integers j, k where d = j · a + k · b. 1 if b = 0 then 2 return (a, 1 , 0) 3 r ← a mod b 4 Let q be the integer such that a = q · b + r (that is, q = ⌊ ab ⌋). 5 (d, j, k) ← ExtendedEuclidGCD(b, r) 6 return (d, k, j − kq)
We can use this algorithm for each pair of numbers in Question 1. As this is a recursive procedure, we fill in the table below from left to right for the rows involving a, b, q, and r, and then we fill it in from right to left for the rows involving j and k. We will assume that a ≥ b (as will always be the case after the first step of the algorithm, so let’s just assume this is the case).
(a)
a 90 56 34 22 12 10 2 b 56 34 22 12 10 2 0 q 1 1 1 1 1 5 - r 34 22 12 10 2 0 - j 1 k 0 We’re first established that gcd(90, 56) = 2. Having made the recursive function calls, we’re now able to fill in the values of j and k from right to left. The last column (as shown)will always be 1 and 0 (assuming that a and b are not both 0, of course). To get the values of j and k in a column, we use the values of j and k from the previous column (the one to its right, as we’re filling in the table from right to left) and the value of q that is in the same column that we’re currently filling in. So the final table looks like this: a 90 56 34 22 12 10 2 b 56 34 22 12 10 2 0 q 1 1 1 1 1 5 - r 34 22 12 10 2 0 - j 5 -3 2 -1 1 0 1 k -8 5 -3 2 -1 1 0 Thus we have gcd(90, 56) = 2 and 2 = (5) · 90 + (−8) · 56. You can double check your work at each step, as for each column, using those values of a, b, j, and k, you should always get a linear combination that equals the GCD. For example, we have
2 = (−1) · 22 + (2) · 10
and also 2 = (2) · 34 + (−3)22.
For the remainder of the pairs, we’ll only give the final table.
(b)
a 91 89 2 1 b 89 2 1 0 q 1 44 2 - r 2 1 0 - j -44 1 0 1 k 45 -44 1 0
Thus we conclude that k · e ≡ 1 (mod ϕ(n)).
Now if k > 0 then we can take d = k for the RSA decryption method. However, if k < 0, then we will add a multiple of ϕ(n) to k until we obtain a positive number and this will be the value of d that we use. Some examples should help to clear this up.
(a) p = 7, q = 13, e = 5 In this case we have n = p · q = 91 and ϕ(91) = (p − 1)(q − 1) = 72. Then we use the Extended Euclidean algorithm. a 72 5 2 1 b 5 2 1 0 q 14 2 2 - r 2 1 0 - j -2 1 0 1 k 29 -2 1 0 So we have (−2) · 72 + (29) · 5 = 1 implying that 29 · 5 ≡ 1 (mod 72). In this case we can take d = 29. Then we want to compute 25^5 mod 91 to encode the given message. First we find that 25^2 mod 91 = 625 mod 91 = 79. Then
254 mod 91 = 79^2 mod 91 = 6241 mod 91 = 53.
Finally 25^5 mod 91 = 53 · 25 mod 91 = 1325 mod 91 = 51. So the ciphertext message that corresponds to M = 25 is C = 51. (You could check that 51^29 mod 91 = 25 but you’d want to use the “fast exponentiation algorithm” that we talked about in class to do this by hand.) (b) p = 5, q = 11, e = 3 We do the same as before, with n = 55 and ϕ(55) = 40. a 40 3 1 b 3 1 0 q 13 3 - r 1 0 - j 1 0 1 k -13 1 0 This time we have that (1) · 40 + (−13) · 3 = 1. This means that (−13) · 3 ≡ 1 (mod 40). Using what we said earlier, to get our value of d, we will add a multiple of 40 to the number −13 until we get a positive number. Namely, we take d = −13 + 40 = 27. Note that we still have the true congruence 27 · 3 ≡ 1 (mod 40) since 27 · 3 − 1 = 80 is a multiple of 40. To encode the message M = 25 we want to find 25^3 mod 55. Then 252 mod 55 = 20, and so 25^3 mod 55 = 25 · 20 mod 55 = 5.
The message M = 25 is encoded as the ciphertext C = 5 in this case. (c) p = 7, q = 17, e = 7 The procedure is clear now (I hope!). With n = 7 · 17 = 119 and ϕ(119) = 6 · 16 = 96, we first find d. a 96 7 5 2 1 b 7 5 2 1 0 q 13 1 2 2 - r 5 2 1 0 - j 3 -2 1 0 1 k -41 3 -2 1 0 So as usual we have (3) · 96 + (−41) · 7 = 1. Thus (−41) · 7 ≡ 1 (mod 96). So we take d = −41 + 96 = 55. The message M = 25 is encrypted as C = 25^7 mod 119 = 32.
Using this decryption key, we can decode the messages that we’re given by finding Cd^ mod 85 = C^5 mod 85.
(a) 12^5 mod 85 = 37. (b) 9^5 mod 85 = 59. (c) 27^5 mod 85 = 57. (d) 84^5 mod 85 = 84. (So 84 is “decoded” as the number 84, and hence, 84 is also encoded as 84.) For all of these numbers, we can also check that M 13 mod 85 = C. For example, we have 37^13 mod 85 = 12 (a small verification that the RSA scheme works as intended).