RSA's summmary

RSA encryption for the cluefully bereft

To create an RSA key pair, start with the following five numbers: And now, a message m (0 £ m £ n) can be enciphered (to c) and deciphered (back to m) as follows: c = me mod n
m = cd mod n

Examples 1

Lets pick some very small values, and follow the process: p=2, q=5, n = pq = 10

e (<n) must be relatively prime to (p-1)(q-1) = 4 = 22
hence e = 3, 7, or 9.

taking e = 3

ed mod (p-1)(q-1) = 1 or 3d mod 4 = 1

by looping through possible values of d that satisfy this relationsship we find

d = 3 7 11 ...

and now, c = me mod n. If we want to encrypt an arbitrary message, m (m <n), say 7 then

c = me mod n = 73 mod 10 = 343 mod 10 = 3

To get the message back, use d as follows:

m = cd mod n = 33 mod 10 = 27 mod 10 = 7

If we actually apply this to all possible values of message, m, we get:

m c m
0 0 0
1 1 1
2 8 2
3 7 3
4 4 4
5 5 5
6 6 6
7 3 7
8 2 8
9 9 9

example: 123 456 78910 111213 14151617 181920 21222324 252627
p 2 2 2 2 3 3 3 3
q 5 7 11 13 5 7 11 13
n = pq 10 14 22 26 15 21 33 39
factors of (p-1)(q-1) 22 2 3 2 5 22 3 23 22 3 22 5 22 3
e 357 5711 37911 5711 35711 5711 37911 5711
d 353 757 5739 5711 3573 5711 37911 5711

example: 282930 313233 34353637 383940 414243 444546 474849
p 3 5 5 5 7 7 11
q 13 7 11 13 11 13 13
n = pq 39 35 55 65 77 91 143
factors of (p-1)(q-1) 22 3 23 3 22 3 24 3 22 3 5 23 32 23 3 5
e 5711 5711 37911 5711 71113 5711 71113
d 5711 5711 2723911 29735 431137 293159 1031137
arbitrarily pick m
(0 £ m £ n)
7 10 18 61
c =75 mod 9 = 477 mod 15 = 13183 mod 25 = 7617 mod 143 = 74
m =45 mod 9 = 7137 mod 15 = 7711 mod 25 = 1874103 mod 143 = 61


7d-1
(11-1)(13-1)

  1. High-Speed Cryptography with the RSA Algorithm, Michael J. Wiener, Dr Dobbs Journal February 2000.
  2. RSA Laboratory FAQ 4.0, Question 3.1.1 What is RSA?
  3. The Code Book, Simon Singh, 1998, Appendix J.