Sunteți pe pagina 1din 4

# RSA Algorithm RSA algorithm (named after its founders, Ron Rivest, Adi Shamir, and Leonard Adleman)

has become almost synonymous with public key cryptography. Lets first see how RSA works, and then examine why it works. Choice of Bobs public and private keys: 1. Choose two large prime numbers, p and q. (Larger the values, the more difficult it is to break RSA, and the longer it takes to encode/decode. It is recommended that the product of p and q be on the order of 1024 bits for corporate use and 768 bits for use with less valuable information. For a discussion on how to find large prime numbers, see http://www.utm.edu/research/primes/prove/). 2. Compute n = pq and z = (p-1)(q-1). 3. Choose a number, e, less than n, which has no common factors (other than 1) with z. (In this case, e and z are said to be relatively prime. The letter e is used since this value will be used in encryption). 4. Find a number, d, such that ed-1 is exactly divisible (that is, with no remainder) by z. (The letter d is used because this value will be used in decryption. Put another way, given e, we choose d such that the integer remainder when ed is divided by z is 1. The integer remainder when an integer x is divided by the integer n, is denoted as x mod n). 5. KB+ = (n, e); KB- = (n, d) RSAs Encryption/Decryption Algorithm: Suppose Alice wants to send Bob a bit pattern, or number, m such that m < n. To encrypt the message, Alice uses Bobs public key and determines the cipher text, c as: c = me mod n To decrypt the message, Bob uses Bobs private key and determines the plain text, m as: m = cd mod n.

## BA483: Class Participation Exercise: Application of RSA Algorithm Date: Name(s):

Background: Assume Bob has selected the prime numbers p and q as 5 and 7 respectively. Assume Bob has selected e to be the number 5. Assume Alice and Bob interpret each letter in the English alphabet as a number between 1 and 26. That is, a = 1, b = 2, , n = 14,, z = 26. Assume Alice wishes to send the plaintext love to Bob, after encrypting using RSA. Question: a) Compute Bobs public key using RSA. b) Determine Alices cipher text using RSA algorithm.

Example (with small values for p and q): 1. 2. 3. 4. Suppose Bob chooses p = 5, and q = 7. Compute n = pq =35, and z = (p-1)(q-1) = (4)(6) = 24 Bob chooses e = 5; Note 5 and 24 have no common factors. Bob chooses d = 29; Note (ed-1) = (5x29 -1) = (145-1) = 144 is exactly divisible by z =24 (as 24 x 6 = 144) 5. Bobs public key is given by KB+ = (n, e) = (35, 5); Bobs private key is given by KB- = (n, d) = (35, 29) Suppose Alice and Bob interpret each letter as a number between 1 and 26. That is, a = 1, b = 2, c = 3,, n = 14,, z = 26. Assume plain text is: Love Alices RSA encryption with e = 5, and n =35 is as follows: Plaintext letter l o v e Cipher text is: 17152210 Bobs decryption with d = 29, and n = 35 is as follows: Ciphertext 17 15 22 10 cd 481968572106750915091411825223071697 12783403948858939111232757568359375 85164331908653770195619449972110603059 2 100000000000000000000000000000 m = cd mod n 12 15 22 5 Plaintext letter l o v e m (numeric representation) 12 15 22 5 me 248832 759375 5153632 3125 c = me mod n 17 15 22 10

Why does RSA work? Thanks to an amazing result from number theory that states the following: If p and q are prime, and n = pq, then xy mod n = x(ymod(p-1)(q-1)) mod n

This rule implies that (me)d mod n = m because, as per number theory rule (me)d mod n = m (ed(mod(p-1)(q-1)) mod n = m1 mod n (as the integer remainder when ed is divided by z is 1) =m Similarly, (md)e mod n = m.