06.01.2015 Views

Cryptology - Unofficial St. Mary's College of California Web Site

Cryptology - Unofficial St. Mary's College of California Web Site

Cryptology - Unofficial St. Mary's College of California Web Site

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.

12.8. RSA 243<br />

The RSA Algorithm<br />

Setup:<br />

Pick two prime numbers P and Q, and let N = P Q.<br />

Choose e so that 1 < e < (P − 1)(Q − 1) with gcd ( e, (P − 1)(Q − 1) ) = 1.<br />

Find d such that ed ≡ 1 (mod (P −1)(Q−1)) via the Euclidean Algorithm.<br />

To encipher:<br />

Split the message into segments M each <strong>of</strong> which is smaller than N.<br />

Compute and send the numbers M e %N.<br />

To decipher:<br />

To decipher a message block E, compute E d %N.<br />

Before we do examples there are a couple comments we need to make. Notice<br />

that when converting the plaintext into numbers we need to translate letters<br />

like a into 01 rather than simply 1. This way we can tell concatenations like<br />

11 12<br />

sab = 190102 and sl = 1912 apart.<br />

Next, people tend to pick P and Q to be massively large primes, one having<br />

300 digits or a bit less, and one having 300 digits or a bit more. This makes<br />

N = P · Q to be about 600 digits long. It’s certainly not any trouble for a<br />

computer to store a 600 digit number (in a text file this is only about eight lines<br />

<strong>of</strong> numbers). Conversely, it is quite common choose P and Q so that 3 does not<br />

divide either P − 1 or Q − 1, and then simply use e = 3 for enciphering. 13<br />

Finally, the RSA code seems quite difficult to break (for reasons we will see<br />

in a moment) as long as P and Q are this large. However, RSA is very slow<br />

compared to the popular private key codes available today. So most messages<br />

are sent in two parts. The first part <strong>of</strong> the message would say something like<br />

“Use DES with key key” and be enciphered using RSA, while the second part,<br />

the much longer portion, would contain the actual message enciphered using<br />

DES with the key sent in part one.<br />

Examples:<br />

(1) Use P = 19, Q = 13, e = 23.<br />

1. Encipher code as a monographic cipher (i.e., one letter at a time).<br />

First N = P ·Q = 247. Then, performing the necessary computations<br />

(but not writing the details, such as the binary charts), we have<br />

11 This translation means that the largest two-letter block is 2626, the largest three-letter<br />

block is 262626, etc. We need to make sure to pick N so it is larger than the largest block in<br />

whatever block size we pick.<br />

12 There are more compact ways to translate letter blocks into numbers. For example,<br />

setting z=0 rather than 26, and then using (p1, p2) → 26 ∗ p1 + p2 for two-letter blocks and<br />

(p1, p2, p3) → 676 ∗ p1 + 26 ∗ p2 + p3 for three-letter blocks provides for more compact usage.<br />

But we will stick with concatenation.<br />

13 2 16 + 1 is another popular choice for e, due to its simple binary expansion.

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

Saved successfully!

Ooh no, something went wrong!