Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

DATA NETWORKING: EXAMPLE SHEET 9

Based on lectures 16 and 17

QUESTION 1
One method of breaking a cryptographic cipher is to have access to a plaintext document and its
ciphertext equivalent and then to test all possible keys, i.e. an exhaustive search of the key space.
Suppose that a set of machines can generate ciphertext from plaintext in i) 1 millisecond, ii) 1
microsecond, iii) 1 nanosecond iv) 1 picosecond v) 1 femtosecond; how long does it take for an
exhaustive search of the key space for keys with the following lengths?
a) 32 bits
b) 56 bits (DES)
c) 112 bits (Triple DES using EDE)

QUESTION 2
(Adapted from Tanenbaum p831)
Using the RSA public key system
a) If p = 7 and q = 11, find 5 legal values for e
b) If p = 13, q = 31 and e = 7, find d
c) If p = 5, q = 11 and e = 27, find d and the message M = 8, show how 8 is encrypted and
decrypted

QUESTION 3
(Taken from Stallings p743)
Perform encryption and decryption using the RSA algorithm for the following
a) p = 3, q = 11, d = 7, M = 5
b) p = 5, q = 11, e = 3, M = 9
c) p = 7, q = 11, e = 17, M = 8

QUESTION 4
Using the RSA public key system with p = 13 and q = 5 show how the message with the decimal value
33 is encrypted and decrypted.

QUESTION 5
(Taken from Stallings p743)
In a public-key system using RSA, you intercept the cipher text C = 10 send to a user with a public key
e = 5, n = 35. What is the plaintext M?

QUESTION 6
(Taken from Stallings p743)
In an RSA system, the public key of a given user is e = 31, n = 3599, what is the private key of this
user?
DATA NETWORKING: ANSWER SHEET 9
QUESTION 1
Key space = 2n, where n is the number of bits in the key. Time to search key space is thus 2n x time
unit.
Times give below are approximate (rounded to the nearest unit where appropriate)
ms μs ns ps fs
32 bits 50 days 1 hour 12 mins 4.3 secs 4.3 msecs 4.3 μsecs
56 bits 2.3x106 yrs 2,300 yrs 2 yrs 3.4 mths 20 hours 1 min 12 secs
112 bits 1.64x1023 yrs 1.64x1020 yrs 1.64x1017 yrs 1.64x1014 yrs 1.64x1011 yrs

QUESTION 2
a) With p = 7 and q = 11, e must be relatively prime with respect to z = (p – 1) x (q – 1) = 60.
Relatively prime means sharing no common factors. 60 has factors of 2, 3, 4, 5, 6, 10, 12, 15 etc. So
avoiding these we have 7, 11, 13, 17 and 19.
b) With p = 13, q = 31 and e = 7, z = (p – 1) x (q – 1) = 12 x 30 = 360
de mod z = 1
de mod z = 1
7d mod 360 = 1
Need an integer d such that 7d mod 360 = 1. There are algorithms to find this, but this can be done
quite simply by finding some of the values of x where x mod 360 = 1, i.e. 361, 721, 1081, 1441 and
dividing these by 7 until an integer value results. 721/7 = 103. This is a value of d since 7 x 103 = 721.
Note that this is not the only value that can be used for d, for example 463 can also be used as 7 x 463 =
3241 and 3241 mod 360 = 1. Other examples include 823 and 1183. However, they will all yield the
same result when used since d mod 360 yields 103 in each case.
c) With p = 5, q = 11 and e = 27, z = (p – 1) x (q – 1) = 4 x 10 = 40
de mod z = 1
27d mod 40 = 1, when d = 3 (reasoning as part b, 27 x 3 = 81, 81 mod 40 = 1)
n = p x q = 5 x 11 = 55
Thus the public key (used for encryption) is (n, e) (55, 27) and the private key (used for decryption) is
(n, d) (55, 3)
To encode the message (M) having the value 8, use C = Me mod n = 827 mod 55 = 2
With a calculator that does not provide a mod operator (unlike the Windows calculator, which works
well for these problems) this calculation is difficult because 827. To address this problem the mod can
be simplified by noting that
x a +b + c mod y = ( x a mod y × x b mod y × x c mod y ) mod y
Thus the power can be broken into smaller, more manageable portions. For example
827 mod 55 = (88 mod 55 x 88 mod 55 x 88 mod 55 x 82 mod 55 x 81 mod 55) mod 55
(note this could be written as ((88 mod 55)2 x 82 mod 55 x 81 mod 55) mod 55, this style is adopted in
later examples)
= (16 x 16 x 16 x 9 x 8) mod 55 (see footnote α )
= (294912) mod 55 = 2 = C
To decode the message use M = Cd mod n = 23 mod 55 = 8 (the value encoded earlier)

α
To use a calculator to find 88 mod 55, calculate 88/55 = 305040.2909, take the fractional part (0.2909)
and multiply this by 55 (gives 15.9995 ≈ 16). This process will work when the fractional part of the
quotient can be displayed
QUESTION 3
a) p = 3, q = 11, d = 7, M = 5
So n = p x q = 3 x 11 = 33
and z = (p – 1) x (q – 1) = (3 – 1) x (11 – 1) = 2 x 10 =20
de mod n = 1, so 7e mod 20 = 1, thus e = 3 since 21 mod 20 = 1
public key = (n, e) = (33, 3), private key = (n, d) = (33, 7)
C = Me mod n = 53 mod 33 = 125 mod 33 = 26
M = Cd mod n = 267 mod 33 = (264 mod 33 x 263 mod 33) mod 33
= (456976 mod 33 x 17576 mod 33) mod 33
= (25 x 20) mod 33 = 500 mod 33 = 5
b) p = 5, q = 11, e = 3, M = 9
So n = p x q = 5 x 11 = 55
and z = (p – 1) x (q – 1) = (5 – 1) x (11 – 1) = 4 x 10 =40
de mod n = 1, so 3d mod 40 = 1, thus d = 27 since 81 mod 40 = 1
public key = (n, e) = (55, 3), private key = (n, d) = (55, 27)
C = Me mod n = 93 mod 55 = 729 mod 55 = 14 = C
M = Cd mod n = 1427 mod 55
(148 mod 55 x 148 mod 55 x 148 mod 55 x 143 mod 55) mod 55 = ((148 mod 55)3 x 14 mod 55) mod 55
= ((1475789056 mod 55)3 x 2744 mod 55) mod 55
= (163 x 49) mod 55 = 200704 mod 55 = 9 = M
c) p = 7, q = 11, e = 17, M = 8
So n = p x q = 7 x 11 = 77
and z = (p – 1) x (q – 1) = (7 – 1) x (11 – 1) = 6 x 10 =60
de mod n = 1, so 17d mod 60 = 1, thus d = 53 since 901 mod 60 = 1
public key = (n, e) = (77, 17), private key = (n, d) = (77, 53)
C = Me mod n = 817 mod 77 = (88 mod 77 x 88 mod 77 x 81 mod 77) mod 77
= (16777216 mod 77 x 16777216 mod 77 x 8 mod 77)
= (71 x 71 x 8) mod 77 = 40328 mod 77 = 57 = C
M = Cd mod n = 5753mod 77 = ((575 mod 77)10 x 573 mod 77) mod 77
= ((601692057 mod 77)10 x 185193 mod 77) mod 77
= (4310 x 8) mod 77
Because (a x b) mod c = (a mod c x b mod c) mod c, this can be written as
(4310 mod 77 x 8 mod 77) mod 77 = (((433 mod 77)3 x 431 mod 77) mod 77 x 8) mod 77
= ((79507 mod 77)3 x 43) mod 77 x 8) mod 77
= ((433 x 43) mod 77 x 8) mod 77 = (34178801 mod 77 x 8) mod 77 = (1 x 8) mod 77 = 8 = M

QUESTION 4
This question is similar to Question 3, except it requires that both d and e be chosen
p = 13, q = 5, so n = p x q = 65 and z = (p – 1) x (q – 1) = (12 x 4) = 48
Need to choose e, this needs to be relatively prime with respect to z, so it should not share factors. 5
would be a suitable value for e (although other values could be used, e.g. 7, 11, etc).
Now de mod n = 1, so 5d mod 48 = 1. d = 29 since 5 x 29 = 145 and 145 mod 48 = 1 (as 3 x 48 = 144).
Public key = (n, e) = (65, 5), private key = (n, d) = (65, 29)
C = Me mod n = 335 mod 65 = 39135393 mod 65 = 63 = C
M = Cd mod n = 6329 mod 65 = ((634 mod 65)7 x 631 mod 65) mod 65
= ((15752961 mod 65)7 x 63 mod 65) mod 65 = (167 x 63) mod 65
Because a x b mod c = (a mod c x b mod c) mod c, this can be written as
(((163 mod 65)2 x 161 mod 65) mod 65 x 63) mod 65
= (((4096 mod 65)2 x 16) mod 65 x 63) mod 65
= ((12 x 16) mod 65) x 63) mod 65 = (16 mod 65 x 63) mod 65 = (16 x 63) mod 65
= 1008 mod 65 = 33 = M

QUESTION 5
This question requires the breaking of the code. The way to do this is to break n into its factors. We
know that the factors of n (p and q) are primes. Given that n is 35 we can see the factors must be 5 and
7 (it doesn’t matter which is p and which is q). We can then get z from z = (1 – p) x (1 – q) = 4 x 6 =
24.
e is known from the public key, so we can get values for d
5d mod 24 = 1, thus d could have the value 5, 29, 53, 77 etc …, but these will all yield the same result
because they yield the same result mod 24 (i.e. 5)
Applying the decoding M = Cdmod 35 = 105 mod 35 = 5
Real RSA could be broken in this way, the problem is factoring the 124-bit value of n into primes – not
as easy as spotting the factors of 35.

QUESTION 6
As Question 5, if the value of n can be factored into p and q the problem is solved. Simply divide 3599
by ascending primes until an integer result is found, the divisor and quotient are p and q. 3599/59 = 61.
z = (p – 1) x (q – 1) = 60 x 58 = 3480
de mod z = 1 so 31d mod 3480 = 1, d = 3031 because 31 x 3031 = 93961 and 93961 mod 3480 = 1
Note finding the values of p, q, and d can be done using spreadsheets.
Again, n is so small that factorization is relatively easy

You might also like