rsa encryption - new mexico state...

34
RSA Encryption RSA Encryption 1/34

Upload: phungtuong

Post on 26-Jul-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

RSA Encryption

RSA Encryption 1/34

Interpreting the Caesar Cipher with Modular Arithmetic

RSA Encryption 2/34

By thinking more mathematically, we can understand better theCaesar cipher, and come up with other encryption methods. All themethods we will discuss involve the idea of modular arithmetic, whichalso arose in our discussion of error detection and correction.

To discuss the Caesar cipher, we will use mod 26 arithmetic. To usethis arithmetic, we only use the numbers 0 through 25. To add ormultiply two of these mod 26, first do the original arithmetic, thenkeep the remainder after dividing the result by 26.

RSA Encryption 3/34

For example, in mod 26, if we want 20 + 11, we first computer theordinary sum, which gives 31. We then throw away multiples of 26until we get something between 0 and 25. We then throw way 26 andare left with 5. We then have

20 + 11 = 5 (mod 26)

Similarly,10 · 6 = 8 (mod 26)

because 10 · 6 = 60 and throwing away two 26’s, or 52, leaves 8.

RSA Encryption 4/34

So, a way to think about this arithmetic is to do the ordinaryarithmetic, and then add or subtract 26 enough times in order to geta number between 0 and 25. For another example, to see that

7 · 7 = 23 (mod 26),

you first compute 7 · 7 = 49 in ordinary arithmetic. Then subtract 26to get 23.

Similarly,8 · 8 = 12 (mod 26)

since in ordinary arithmetic, 8 · 8 = 64. Subtracting 26 gives64− 26 = 38. Subtracting again gives 38− 26 = 12.

RSA Encryption 5/34

Interpreting the Caesar Cipher with Modular Arithmetic

If we consider the Casesar Cipher, shifting by 3 letters, then we cando this numerically as follows. First, we assign each letter a numberin mod 26. For example, we could assign a = 0, b = 1, c = 2, and soon,until we have z = 25. We will do this.

To encrypt, we replace any letter by the corresponding letter obtainedby adding adding by 3 mod 26. For example, to encrypt y, we replacey by 24, then add 3 mod 26. Since 24 + 3 = 1 (mod 26), we thenreplace y by b.

RSA Encryption 6/34

In other words, to encrypt any letter, take its numerical value, andadd 3 in mod 26. Taking the corresponding letter would then give theencrypted letter.

Spreadsheets can handle mod arithmetic very easily. Excel uses thefunction mod. If you enter =mod(62, 26), the spreadsheet determineswhat number mod 26 represents 62 (which is 10).

RSA Encryption 7/34

Encrypting

For example, the message

you are here

would be represented numerically by

24 14 21 0 17 4 7 4 17 4

Adding 3 to each number, mod 26, results in the encrypted message

1 17 24 3 20 7 10 7 20 7

Note that 24 + 3 = 1 (mod 26). These numbers correspond to thetext

bry duh khuh

RSA Encryption 8/34

Decrypting

To decrypt using mod 26 arithmetic, we subtract 3 to each numbermod 26. For example, given the encrypted message dry duh khuh,which numerically corresponds to 1 17 24 3 20 7 10 7 20 7, wesubtract 3 from each of the numbers, mod 26. Note that1− 3 = −2 = 24 (mod 26). Doing this to all numbers gives

24 21 0 17 4 7 4 17 4

which translates into our original message you are here.

RSA Encryption 9/34

RSA Encryption

To be useful a method of encryption must be easy and quick to usebut very difficult to decrypt unless you are the intended recipient.

RSA encryption, published by Rivest, Shamir and Adleman in anarticle published in 1978, allows for data to be easily encrypted anddecrypted, yet can keep the data secure.

Data is assumed to be in numerical form; a message consists of anumber or a series of numbers. For illustrative purposes we assume amessage is a single number, for example, a credit card number.

RSA Encryption 10/34

To use RSA, you begin by choosing two prime numbers, which we willcall p and q. Prime numbers are whole numbers greater than 1 whichcannot be factored into smaller whole numbers, such as 5, 7, and 13.

We set

n = pq

m = (p − 1)(q − 1)

We choose a number e, which we will call the encoding number, andwe calculate a number d , called the decoding number, to satisfy theequation

ed ≡ 1 (mod m)

We must choose e appropriately for there to be such a d . Technically,we have to choose e be able to divide by e modulo m.

RSA Encryption 11/34

Suppose M is a message. To encrypt M we compute

Me (mod n)

To decrypt, we take the received message N, which is Me (mod n),and compute

Nd (mod n)

The amazing thing is we recover the original message!

RSA Encryption 12/34

Examples of using RSA

The following calculations are done in a computer program that canhandle both numerical and symbolic computation. Each of thecalculations we’ll see were done almost instantaneously.

RSA Encryption 13/34

RSA Encryption 14/34

RSA Encryption 15/34

So the message 17 is encrypted as 73.

RSA Encryption 16/34

The number Nd = 7337, which amounts to multiplying 73 times itself37 times.

RSA Encryption 17/34

Clicker Question

If you were to count out loud, starting at 1, until you reached

9904578032905937

and could speak 1 number per second, about how long would it takeyou?

A 1 hour

B 1 year

C 100 years

D A lot longer than 100 years

RSA Encryption 18/34

Answer

The correct answer is D.

If you could speak numbers this quickly, it would take you about 300million years to get to the number.

RSA Encryption 19/34

A little more realistic example

These are numbers with at least 200 digits!

RSA Encryption 20/34

RSA Encryption 21/34

RSA Encryption 22/34

RSA Encryption 23/34

If we could write out Me , it would have about 100 billion digits. At10 characters per inch, writing it in one long string, it would be morethan 5 times the distance between the earth and moon, or printing itwould take about 50 million pages!

RSA Encryption 24/34

RSA Encryption 25/34

Clicker Question

If a computer could count 1 billion digits per second, how long wouldyou think it would take for it to count from 1 up to a 200 digitnumber?

A 100 year

B 1 million years

C 1 trillion years

D Longer

E The computer would blow up before finishing

RSA Encryption 26/34

Answer

The answer is D; it would take much much longer than the universehas existed (which is less than 1 trillion years).

RSA Encryption 27/34

Why does RSA work?

Why does decrypting recover the original message when using RSA?

There is a result, called Fermat’s Little Theorem, which says that if pis a prime number, and a is not evenly divisible by p, then

ap−1 ≡ 1 (mod p).

A generalization, called Euler’s Theorem, says in our case that if M isnot divisible by p or q, then M(p−1)(q−1) ≡ 1 (mod n).

RSA Encryption 28/34

The choice of e and d says that ed = 1 + km for some k . Encrypting,then decrypting yields

M −→ Me −→ (Me)d = Med

Modulo n, we have

Med = M1+km = M · (Mm)k

≡ M · 1 ≡ M (mod n)

Because Mm ≡ 1 (mod n) by Euler.

RSA Encryption 29/34

In using RSA, one must keep p, q,m, d private, although n and e canbe public. Knowing any one of p, q,m, d is enough to break the code.

Why isn’t it easy to break RSA? Can’t we just factor n to get p andq, and then compute d?

RSA Encryption 30/34

Clicker Question

Suppose n = 91. Can you find the two prime factors p and q forwhich pq = 91?

If you can find p and/or q, enter one of them into your clicker andsend. If you cannot, enter 0.

RSA Encryption 31/34

An RSA Challenge

In 1977 Martin Gardner issued a challenge in his Scientific Americancolumn. He printed some encrypted text, using RSA with a 129 digitmodulus, which was the product of two unknown prime numbers, andhe challenged people to decrypt the text. The modulus was

RSA-129 = 11438162575788886766923577997614661201021829

6721242362562561842935706935245733897830597

123563958705058989075147599290026879543541

He claimed it would take millions of years to break.

RSA Encryption 32/34

Gardner was a little off.

RSA-129 was factored in April 1994 by a team led by Derek Atkins,Michael Graff, Arjen K. Lenstra and Paul Leyland, usingapproximately 1600 computers from around 600 volunteers connectedover the Internet. It only took 17 years!

RSA-129 = 3490529510847650949147849619903898

133417764638493387843990820577

× 3276913299326670954996198819083446

1413177642967992942539798288533

By using increasingly large prime numbers RSA can continue to beused even with increasingly faster computers.

RSA Encryption 33/34

Next Week and Homework

Next week we will discuss a connection between math and art. Wewill discuss the symmetry behind some of M. C. Escher’s tessellations.The mathematics behind his art was first discovered bycrystallographers, who were interested in how chemical properties ofcrystals are determined by the symmetry of the crystals.

Assignment 2 is on the course website. It is due next Friday.

RSA Encryption 34/34