12
1 Codes, Ciphers, and Cryptography-RSA Encryption Michael A. Karls Ball State University

1 Codes, Ciphers, and Cryptography-RSA Encryption Michael A. Karls Ball State University

Embed Size (px)

Citation preview

Page 1: 1 Codes, Ciphers, and Cryptography-RSA Encryption Michael A. Karls Ball State University

1

Codes, Ciphers, and Cryptography-RSA Encryption

Michael A. Karls

Ball State University

Page 2: 1 Codes, Ciphers, and Cryptography-RSA Encryption Michael A. Karls Ball State University

2

The RSA Encryption Scheme

We now look at the public key cryptography scheme developed by Rivest, Shamir, and Adleman (RSA) in 1977.

In order to understand this scheme, we need some definitions!

Page 3: 1 Codes, Ciphers, and Cryptography-RSA Encryption Michael A. Karls Ball State University

3

Definition of Divisor

Let a and b be integers, with b 0. We say that b divides a or b is a divisor of a if a = b x c for some integer c.

Notation: b|a Example 1:

3|24 since 24 = 3 x 8.

Divisors of 12 are: -12, -6, -4, -3, -2, -1, 1, 2, 3, 4, 6, 12

Page 4: 1 Codes, Ciphers, and Cryptography-RSA Encryption Michael A. Karls Ball State University

4

Definition of Greatest Common Divisor (GCD) Let a and b be integers, not both zero. The

greatest common divisor (GCD) of a and b is the largest integer that divides both a and b.

Notation: (a,b) Example 2: Divisors of 6: -6, -3, -2, -1, 1, 2, 3, 6 Divisors of 8: -8, -4, -2, -1, 1, 2, 4, 8 Thus, (6,8) = 2 Since the divisors of 7 are -7, -1, 1, 7, (7,8) = 1.

Page 5: 1 Codes, Ciphers, and Cryptography-RSA Encryption Michael A. Karls Ball State University

5

Definition of Relatively Prime

Two integers whose GCD is 1 are said to be relatively prime.

Example 3:

Since (7,8) = 1, 7 and 8 are relatively prime.

Page 6: 1 Codes, Ciphers, and Cryptography-RSA Encryption Michael A. Karls Ball State University

6

Definition of Prime Number

A positive integer p is said to be prime if p>1 and the only positive divisors of p are 1 and p.

Example 4:

2, 3, and 7 are prime.

6, 8, 10, 100 are not prime (composite).

Page 7: 1 Codes, Ciphers, and Cryptography-RSA Encryption Michael A. Karls Ball State University

7

RSA Scheme (with Alice and Bob!)

Step 1: Alice chooses two huge

prime numbers p and q. Note: Alice keeps p and

q secret!

Example 5: p = 47 and q = 59.

Page 8: 1 Codes, Ciphers, and Cryptography-RSA Encryption Michael A. Karls Ball State University

8

RSA Scheme (with Alice and Bob!) (cont.) Step 2: Alice computes

N = p x q. Then she computes k =

(p-1)(q-1). Finally, she chooses an

integer e such that 1<e<N and (e,k) =1.

Example 5 (cont.): N = 47 x 59 = 2773. k = 46 x 58 = 2668. e = 17. Choice of e is o.k., since

1<17<2773 and

(17,2668)= 1.

Page 9: 1 Codes, Ciphers, and Cryptography-RSA Encryption Michael A. Karls Ball State University

9

RSA Scheme (with Alice and Bob!) (cont.) Step 3: Alice computes

d = e-1 mod k. Alice publishes her public

key: N, e. Alice keeps secret her

private key: p, q, d, k.

Example 5 (cont.): d = 17-1 mod 2668 = 157. Alice’s public key:

N = 2773; e = 17. Alice’s private key:

p = 47; q = 59; d = 157; k = 2668.

Page 10: 1 Codes, Ciphers, and Cryptography-RSA Encryption Michael A. Karls Ball State University

10

RSA Scheme (with Alice and Bob!) (cont.) Step 4: Suppose Bob wants to

send a message to Alice. To do so, he looks up

Alice’s public key, converts the message into numbers M<N.

Example 5 (cont.): Plaintext is HELLO HELLO HE LL O_ Assign 00space;

01A; 02B, … , 26Z (or use ASCII).

Plaintext Plain #

HE 0805

LL 1212

0_ 1500

Page 11: 1 Codes, Ciphers, and Cryptography-RSA Encryption Michael A. Karls Ball State University

11

RSA Scheme (with Alice and Bob!) (cont.) Step 4 (cont.): Next Bob computes:

C = Me mod N (1)

for each plaintext number M to get ciphertext number C.

Example 5 (cont.): 080517 mod 2773 = 542. 121217 mod 2773 = 2345. 150017 mod 2773 = 2417. Encrypted message is

0542 2345 2417.

Page 12: 1 Codes, Ciphers, and Cryptography-RSA Encryption Michael A. Karls Ball State University

12

RSA Scheme (with Alice and Bob!) (cont.) Step 5: Bob emails Alice the encrypted

message. To decrypt, Alice uses her

private key and computes:

M = Cd mod N (2)

Example 5 (cont.): 0542157 mod 2773 = 805. 2345157 mod 2773 =

1212. 2417157 mod 2773 =

1500. Decrypted message is

HE LL 0_.