Let's look at an example of RSA in action, albeit one
with numbers far too small to resist factoring. For this
example, I borrow directly from Schneier (see Resources).
Let p = 47
and q = 71
. We
calculate n = p * q = 3337
. The encryption
exponent e must have no factors in common with:
(p-1)*(q-1) = 46 * 70 = 3220
We may therefore choose e = 79
(we could
have used other values equally well). We now calculate:
d = 79^-1 mod 3220 = 1019
Publish [e, n], keep d secret, and discard p
and q. Each message we can encrypt in the example
must be a number smaller than 3337. In other words, we
might divide an actual plain text into 11-bit blocks and
encrypt each block in the same manner. The cipher text
simply concatenates the encrypted blocks (maybe padding to
12 bits to include every cipher text possible).
For example, suppose that one of our correspondent's
11-bit blocks is "01010110000"; in decimal, this is 688. Our
correspondent creates a cipher text block by calculating:
C = 688^79 mod 3337 = 1570 = "011000100010"
Our correspondent sends us the message, "011000100010,"
and we can decrypt it by calculating:
M = 1570^1019 mod 3337 = 688 = "01010110000"
Of course, factoring 3337 is
hardly an insurmountable obstacle for a determined attacker
with a couple of pages of scratch paper and a pencil. By using
keys hundreds of times this long, we set the bar higher than
even attackers with millions of MIP-years can surmount (or
so it is believed).