36
RSA RSA Prepared by: Prepared by: SITI ZAINAH ADNAN SITI ZAINAH ADNAN If you do have any feedback or comment, If you do have any feedback or comment, please feel free to email me at please feel free to email me at [email protected] [email protected] Your cooperation is very much appreciated ! Your cooperation is very much appreciated !

RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at [email protected] Your cooperation is very

Embed Size (px)

Citation preview

Page 1: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSARSA

Prepared by: Prepared by: SITI ZAINAH ADNANSITI ZAINAH ADNAN

If you do have any feedback or comment,If you do have any feedback or comment,please feel free to email me atplease feel free to email me at

[email protected]@hotmail.comYour cooperation is very much appreciated !Your cooperation is very much appreciated !

Page 2: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSARSAIs a famous implementation of public key protocol.Is a famous implementation of public key protocol.

Deviced by Deviced by RRonald Rivest, Adi onald Rivest, Adi SShamir and Lenhamir and Len AAdleman of MIT in 1977.dleman of MIT in 1977.

Algorithm involves multiplication of large (100 Algorithm involves multiplication of large (100 digits) prime numbers to produce keys.digits) prime numbers to produce keys.

Difficult to break the product of two large primes Difficult to break the product of two large primes into its two prime factors, hence very secure.into its two prime factors, hence very secure.

Page 3: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

Number Theory Number Theory

A number of concepts from number theory are essential A number of concepts from number theory are essential in the design of public key cryptographyin the design of public key cryptography

DivisorsDivisorsPrime NumberPrime NumberRelatively Prime NumberRelatively Prime NumberModular Arithmetic Modular Arithmetic

Page 4: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

DivisorsDivisorsWe say that We say that bb =/ 0 divides =/ 0 divides aa if if aa = = mbmb for some for some mm, where , where a, a, b,b, and and mm are integers are integers

That is, That is, b b divides divides aa if there is no remainder on division if there is no remainder on division

The notation The notation b|ab|a is commonly used to mean is commonly used to mean bb divides divides aa

Also, if Also, if b|ab|a, we say that , we say that dd is a divisor of is a divisor of aa

eg. The positive divisor of 24 are 1, 2, 3, 4, 6, 8, 12, and 24eg. The positive divisor of 24 are 1, 2, 3, 4, 6, 8, 12, and 24

Page 5: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

Prime NumberPrime NumberAn integer An integer p p > 1 is a prime number if its only divisors > 1 is a prime number if its only divisors are 1 and itselfare 1 and itself

eg. 2 3 5 7 1 13 17 19 23 29 31 37 41 43 47 53…eg. 2 3 5 7 1 13 17 19 23 29 31 37 41 43 47 53…

Any integer Any integer a a > 1 can be factored in a unique way as > 1 can be factored in a unique way as

a = p1a = p1mm p2 p2mm….pn….pnmm

where where p1 p1 > > p2 p2 > …..pn are prime numbers and > …..pn are prime numbers and where each m > 0where each m > 0

eg. 91 = 7 x 13 11011 = 7 x 11eg. 91 = 7 x 13 11011 = 7 x 112 2 x 13 x 13

Page 6: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

Prime NumberPrime NumberTherefore, if P is the set of all prime numbers, then any Therefore, if P is the set of all prime numbers, then any positive integer can be written uniquely as the product positive integer can be written uniquely as the product of all possible prime numbersof all possible prime numbers

eg. 216 = 12 x 18eg. 216 = 12 x 18

= (2 x 6) x (2 x 9)= (2 x 6) x (2 x 9)

= (2 x 2 x 3) x (2 x 3 x 3)= (2 x 2 x 3) x (2 x 3 x 3)

= 2= 233 x 3 x 322

Page 7: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

Relative Prime NumbersRelative Prime NumbersWe will use the notation gcd(We will use the notation gcd(a, ba, b) to mean the greatest ) to mean the greatest common divisor of common divisor of a a and and bb

The positive integer is said to be the greatest common The positive integer is said to be the greatest common divisor of divisor of a a and and bb if if

c c is a divisor of is a divisor of a a and of and of bbany divisor of any divisor of aa and and bb is a divisor of c is a divisor of c

An equivalent definition is the following:An equivalent definition is the following:

gcd(gcd(a, ba, b) = max[ ) = max[ k, k, such that such that k|a k|a and and k|bk|b]]

Page 8: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

Relative Prime NumbersRelative Prime NumbersWe always take the positive value as the greatest We always take the positive value as the greatest common divisorcommon divisor

It is easy to determine the greatest common divisor of It is easy to determine the greatest common divisor of two positive integers if we express each integer as the two positive integers if we express each integer as the product of primesproduct of primes

eg. 300 = 2eg. 300 = 222 x 3 x 311 x 5 x 522

18 = 218 = 211 x 3 x 322

Therefore, gcd(18, 300) = 2Therefore, gcd(18, 300) = 21 1 x 3x 311 x 5 x 500 = 6 = 6

Page 9: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

Relative Prime NumbersRelative Prime NumbersThe integers The integers a a and and bb are relatively prime if they have no are relatively prime if they have no prime factors in common, that is, if their only common prime factors in common, that is, if their only common factors is 1.factors is 1.

This is equivalent to saying that This is equivalent to saying that a a and and b b are relatively are relatively prime if gcd(prime if gcd(aa, , bb) = 1) = 1

eg. 8 and 15 are relatively prime because the divisors eg. 8 and 15 are relatively prime because the divisors of 8 are 1, 2, 4, and 8, and the divisors of 15 are 1, 3, 5, of 8 are 1, 2, 4, and 8, and the divisors of 15 are 1, 3, 5, and 15. So 1 is the only number on both listsand 15. So 1 is the only number on both lists

Page 10: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

Modular ArithmeticModular ArithmeticGiven any positive integer Given any positive integer n n and any integer and any integer a, a, we get we get a quotient a quotient q q and and aa remainder remainder r r that obey the following that obey the following relationship:relationship:

a = qn + r 0 < r < n; q = [a/n]a = qn + r 0 < r < n; q = [a/n]

where [x] is the largest integer less than or equal to xwhere [x] is the largest integer less than or equal to x

eg. eg. a = a = 11; 11; n n = 7; 11 = 1 x 7 + 4; = 7; 11 = 1 x 7 + 4; r r = 4= 4

Therefore we can say that 11 = 1 x 7 + 4Therefore we can say that 11 = 1 x 7 + 4

Page 11: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - key generation RSA - key generation

Select Select p, qp, q pp and and q q both large primeboth large primeCalculate Calculate n = p x qn = p x qCalculate Calculate m = (p-1)(q-1)m = (p-1)(q-1)Select integer Select integer ee gcd(e,m) = 1, 1 < e < mgcd(e,m) = 1, 1 < e < mCalculate Calculate dd dede mod mod m = 1m = 1Public key = { e, n }Public key = { e, n }Private key = { d, n }Private key = { d, n }

Keep Keep p, q, mp, q, m, and , and dd secret secretMake Make ee and and nn public public

Page 12: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA ImplementationRSA Implementation

RSA encryptRSA encrypt RSA decryptRSA decrypt

C = PC = Pee mod n mod n P = CP = Cdd mod n mod n

Page 13: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 1RSA - example 1Steps of RSA implementation:Steps of RSA implementation:1. Select two prime numbers, 1. Select two prime numbers, p = 7p = 7 and and q = 17q = 172. Calculate 2. Calculate n = pq = 7 x 17 = 119n = pq = 7 x 17 = 1193. Calculate 3. Calculate m = (7- 1)(17 - 1) = 6 x 16 = 96m = (7- 1)(17 - 1) = 6 x 16 = 964. Select 4. Select ee such that such that e e is relatively prime to is relatively prime to m = 96 m = 96 and less and less than than m, 1 < e < 96m, 1 < e < 96gcd (e, 96) = 1gcd (e, 96) = 196 = 1 x 6 x 1696 = 1 x 6 x 16 = 1 x 2 x 3 x 8= 1 x 2 x 3 x 8 = 1 x 2 x 3 x 2= 1 x 2 x 3 x 233

= 1 x 2= 1 x 244 x 3 x 3Assume that we take the smallest prime number in between of 3 Assume that we take the smallest prime number in between of 3 to 96, so to 96, so e = 5e = 5You also can take other value as long as it fulfils the conditions – You also can take other value as long as it fulfils the conditions – it must be relatively prime with 96 and it is less than 96it must be relatively prime with 96 and it is less than 96

Page 14: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 1RSA - example 15. Determine 5. Determine dd such that such that de = 1 mod 96 de = 1 mod 96 and and d < 96d < 96. .

de de modmod m = 1 m = 1

d x 5 = ( ? X 96) + 1d x 5 = ( ? X 96) + 1

1 x 96 + 1 = 96 + 1 = 971 x 96 + 1 = 96 + 1 = 97 97/5 = 19.497/5 = 19.4

2 x 96 + 1 = 192 + 1 = 193 2 x 96 + 1 = 192 + 1 = 193 193/5 = 38.6193/5 = 38.6

3 x 96 + 1 = 288 + 1 = 2893 x 96 + 1 = 288 + 1 = 289 289/5 = 57.8289/5 = 57.8

4 x 96 + 1 = 388 + 1 = 3854 x 96 + 1 = 388 + 1 = 385 385/5 = 77385/5 = 77

Find the value which when the results mod 5 with no remainderFind the value which when the results mod 5 with no remainder

The correct value is The correct value is d = 77d = 77, because , because

77 x 5 = 385 = 4 x 96 + 177 x 5 = 385 = 4 x 96 + 1

You also can take other value as long as it is a positive integer You also can take other value as long as it is a positive integer

Page 15: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 1RSA - example 1Therefore, n = 119, m = 96, e = 5, d = 77Therefore, n = 119, m = 96, e = 5, d = 77

The resulting keys are: The resulting keys are:

Public key = { e, n } Public key = { e, n } and and Private key = { d, n}Private key = { d, n}

Public key = {5, 119}Public key = {5, 119} and and Private key = {77, 119}Private key = {77, 119}

Assume that Assume that P P is the plaintext and is the plaintext and CC is the ciphertext is the ciphertext

The encryption is The encryption is C = PC = P55 mod 119 mod 119

The decryption is The decryption is P = CP = C7777 mod 119 mod 119

Page 16: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 1RSA - example 1Public key = { e, n } Public key = { e, n } and and Private key = { d, n}Private key = { d, n}Public key = {5, 119}Public key = {5, 119} and and Private key = {77, 119}Private key = {77, 119}

Given Given P = 4P = 4

The encryption is The encryption is C = PC = P55 mod 119 mod 119C = 4C = 455 mod 119 mod 119 = 1024 mod 119= 1024 mod 119 = 72= 72

The decryption is The decryption is P = CP = C7777 mod 119 mod 119P = 72P = 722727 mod 119 mod 119 = 4= 4

Page 17: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 2RSA - example 2Steps of RSA implementation:Steps of RSA implementation:1. Select two prime numbers, 1. Select two prime numbers, p = 7p = 7 and and q = 11q = 112. Calculate 2. Calculate n = pq = 7 x 11 = 77n = pq = 7 x 11 = 773. Calculate 3. Calculate m = (7- 1)(11 - 1) = 6 x 10 = 60m = (7- 1)(11 - 1) = 6 x 10 = 604. Select 4. Select ee such that such that e e is relatively prime to is relatively prime to m = 60m = 60 and less and less than than m, 1 < e < 60m, 1 < e < 60gcd (e, 60) = 1gcd (e, 60) = 1

60 = 1 x 10 x 660 = 1 x 10 x 6 = 1 x 2 x 5 x 2 x 3= 1 x 2 x 5 x 2 x 3 = 1 x 2= 1 x 222 x 3 x 5 x 3 x 5Assume that we take any prime number in between of 7 to 60, Assume that we take any prime number in between of 7 to 60, so so e = 37e = 37You also can take other value as long as it fulfils the conditions You also can take other value as long as it fulfils the conditions – it must be relatively prime with 60 and it is less than 60– it must be relatively prime with 60 and it is less than 60

Page 18: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 2RSA - example 25. Determine 5. Determine dd such that such that de = 1 mod 60 de = 1 mod 60 and and d < 60d < 60

de de modmod m = 1 m = 1

d x 37 = ( ? X 60) + 1d x 37 = ( ? X 60) + 1

1 x 60 + 1 = 60 + 1 = 611 x 60 + 1 = 60 + 1 = 61 61/37 = 1.661/37 = 1.6

2 x 60 + 1 = 120 + 1 = 121 2 x 60 + 1 = 120 + 1 = 121 121/37 = 3.2121/37 = 3.2

3 x 60 + 1 = 180 + 1 = 1813 x 60 + 1 = 180 + 1 = 181 181/37 = 4.8 181/37 = 4.8

4 x 60 + 1 = 240 + 1 = 2414 x 60 + 1 = 240 + 1 = 241 241/37 = 6.5241/37 = 6.5

5 x 60 + 1 = 300 + 1 = 3015 x 60 + 1 = 300 + 1 = 301 301/37 = 8.1301/37 = 8.1

6 x 60 + 1 = 360 + 1 = 3616 x 60 + 1 = 360 + 1 = 361 361/37 = 9.7361/37 = 9.7

7 x 60 + 1 = 420 + 1 = 4217 x 60 + 1 = 420 + 1 = 421 421/37 = 11.3421/37 = 11.3

8 x 60 + 1 = 480 + 1 = 481 8 x 60 + 1 = 480 + 1 = 481 481/37 = 13481/37 = 13

Page 19: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 2RSA - example 2Find the value which when the results mod 5 with no Find the value which when the results mod 5 with no remainderremainder

The correct value is The correct value is d = 13d = 13, because , because

13 x 37 = 481 = 8 x 60 + 113 x 37 = 481 = 8 x 60 + 1

You also can take other value as long as it is a positive You also can take other value as long as it is a positive integer integer

Page 20: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 2RSA - example 2Therefore, n = 77, m = 60, e = 37, d = 13Therefore, n = 77, m = 60, e = 37, d = 13

The resulting keys are: The resulting keys are:

Public key = { e, n } Public key = { e, n } and and Private key = { d, n}Private key = { d, n}

Public key = {37, 77}Public key = {37, 77} and and Private key = {13, 77}Private key = {13, 77}

Assume that Assume that P P is the plaintext and is the plaintext and CC is the ciphertext is the ciphertext

The encryption is The encryption is C = PC = P3737 mod 77 mod 77

The decryption is The decryption is P = CP = C1313 mod 77 mod 77

Page 21: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 2RSA - example 2Public key = { e, n } Public key = { e, n } and and Private key = { d, n}Private key = { d, n}Public key = {37, 77}Public key = {37, 77} and and Private key = {13, 77}Private key = {13, 77}

Given Given P = 5P = 5

The encryption is The encryption is C = PC = P3737 mod 77 mod 77C = 5C = 53737 mod 77 mod 77 = 1024 mod 77= 1024 mod 77 = 47= 47

The decryption is The decryption is P = CP = C7777 mod 119 mod 119P = 47P = 471313 mod 77 mod 77 = 5= 5

Page 22: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 3RSA - example 3Steps of RSA implementation:Steps of RSA implementation:1. Select two prime numbers, 1. Select two prime numbers, p = 3p = 3 and and q = 11q = 112. Calculate 2. Calculate n = pq = 3 x 11 = 33n = pq = 3 x 11 = 333. Calculate 3. Calculate m = (3- 1)(11 - 1) = 2 x 10 = 20m = (3- 1)(11 - 1) = 2 x 10 = 204. Select 4. Select ee such that such that e e is relatively prime to is relatively prime to m = 20m = 20 and less and less than than m, 1 < e < 20m, 1 < e < 20gcd (e, 20) = 1gcd (e, 20) = 1

20 = 1 x 2 x 10 20 = 1 x 2 x 10 = 1 x 2 x 2 x 5 = 1 x 2 x 2 x 5 = 1 x 2= 1 x 222 x 5 x 5Assume that we take the smallest prime number in between of Assume that we take the smallest prime number in between of 2, 5 to 20, so 2, 5 to 20, so e = 3e = 3You also can take other value as long as it fulfils the conditions You also can take other value as long as it fulfils the conditions – it must be relatively prime with 20 and it is less than 20– it must be relatively prime with 20 and it is less than 20

Page 23: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 3RSA - example 35. Determine 5. Determine dd such that such that de = 1 mod 20 de = 1 mod 20 and and d < 20d < 20 de de modmod m = 1 m = 1d x 3 = ( ? X 20) + 1d x 3 = ( ? X 20) + 1

1 x 20 + 1 = 20 + 1 = 211 x 20 + 1 = 20 + 1 = 21 21/3 = 721/3 = 72 x 20 + 1 = 40 + 1 = 41 2 x 20 + 1 = 40 + 1 = 41 41/3 = 13.641/3 = 13.6

Find the value which when the results mod 3 with no Find the value which when the results mod 3 with no remainderremainderThe correct value is The correct value is d = 7d = 7, because , because

7 x 3 = 21 = 1 x 20 + 17 x 3 = 21 = 1 x 20 + 1

You also can take other value as long as it is a positive You also can take other value as long as it is a positive integer integer

Page 24: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 3RSA - example 3Therefore, n = 33, m = 20, e = 3, d = 7Therefore, n = 33, m = 20, e = 3, d = 7

The resulting keys are: The resulting keys are:

Public key = { e, n } Public key = { e, n } and and Private key = { d, n}Private key = { d, n}

Public key = {3, 33}Public key = {3, 33} and and Private key = {7, 33}Private key = {7, 33}

Assume that Assume that P P is the plaintext and is the plaintext and CC is the ciphertext is the ciphertext

The encryption is The encryption is C = PC = P33 mod 33 mod 33

The decryption is The decryption is P = CP = C77 mod 33 mod 33

Page 25: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 3RSA - example 3Public key = { e, n } Public key = { e, n } and and Private key = { d, n}Private key = { d, n}Public key = {3, 33}Public key = {3, 33} and and Private key = {7, 33}Private key = {7, 33}

Given Given P = 6P = 6

The encryption is The encryption is C = PC = P33 mod 33 mod 33C = 6C = 633 mod 33 mod 33 = 216 mod 33= 216 mod 33 = 18= 18

The decryption is The decryption is P = CP = C77 mod 33 mod 33P = 18P = 1877 mod 33 mod 33 = 6= 6

Page 26: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 4RSA - example 4Steps of RSA implementation:Steps of RSA implementation:1. Select two prime numbers, 1. Select two prime numbers, p = 5p = 5 and and q = 11q = 112. Calculate 2. Calculate n = pq = 5 x 11 = 55n = pq = 5 x 11 = 553. Calculate 3. Calculate m = (5- 1)(11 - 1) = 4 x 10 = 40m = (5- 1)(11 - 1) = 4 x 10 = 404. Select 4. Select ee such that such that e e is relatively prime to is relatively prime to m = 40m = 40 and less and less than than m, 1 < e < 40m, 1 < e < 40gcd (e,40) = 1gcd (e,40) = 1

40 = 1 x 4 x 10 40 = 1 x 4 x 10 = 1 x 2 x 2 x 2 x 5 = 1 x 2 x 2 x 2 x 5 = 1 x 2= 1 x 233 x 5 x 5Assume that we take the smallest prime number in between of Assume that we take the smallest prime number in between of 2, 5 to 40, so 2, 5 to 40, so e = 3e = 3You also can take other value as long as it fulfils the conditions You also can take other value as long as it fulfils the conditions – it must be relatively prime with 40 and it is less than 40– it must be relatively prime with 40 and it is less than 40

Page 27: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 4RSA - example 45. Determine 5. Determine dd such that such that de = 1 mod 40 de = 1 mod 40 and and d < 40d < 40 de de modmod m = 1 m = 1d x 3 = ( ? X 40) + 1d x 3 = ( ? X 40) + 1

1 x 40 + 1 = 40 + 1 = 411 x 40 + 1 = 40 + 1 = 41 41/3 = 13.641/3 = 13.62 x 40 + 1 = 80 + 1 = 81 2 x 40 + 1 = 80 + 1 = 81 121/3 = 27121/3 = 27

Find the value which when the results mod 3 with no Find the value which when the results mod 3 with no remainderremainderThe correct value is The correct value is d = 27d = 27, because , because 27 x 3 = 81 = 2 x 40 + 127 x 3 = 81 = 2 x 40 + 1

You also can take other value as long as it is a positive You also can take other value as long as it is a positive integer integer

Page 28: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 4RSA - example 4Therefore, n = 55, m = 40, e = 3, d = 27Therefore, n = 55, m = 40, e = 3, d = 27

The resulting keys are: The resulting keys are:

Public key = { e, n } Public key = { e, n } and and Private key = { d, n}Private key = { d, n}

Public key = {3, 55}Public key = {3, 55} and and Private key = {27, 55}Private key = {27, 55}

Assume that Assume that P P is the plaintext and is the plaintext and CC is the ciphertext is the ciphertext

The encryption is The encryption is C = PC = P33 mod 55 mod 55

The decryption is The decryption is P = CP = C2727 mod 55 mod 55

Page 29: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 4RSA - example 4Public key = { e, n } Public key = { e, n } and and Private key = { d, n}Private key = { d, n}Public key = {3, 55}Public key = {3, 55} and and Private key = {27, 55}Private key = {27, 55}

Given Given P = 4P = 4

The encryption is The encryption is C = PC = P33 mod 55 mod 55C = 4C = 433 mod 55 mod 55 = 64 mod 55= 64 mod 55 = 9= 9

The decryption is The decryption is P = CP = C2727 mod 55 mod 55P = 9P = 92727 mod 55 mod 55 = 4= 4

Page 30: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 5RSA - example 5Steps of RSA implementation:Steps of RSA implementation:1. Select two prime numbers, 1. Select two prime numbers, p = 11p = 11 and and q = 17q = 172. Calculate 2. Calculate n = pq = 11 x 17 = 187n = pq = 11 x 17 = 1873. Calculate 3. Calculate m = (11- 1)(17 - 1) = 10 x 16 = 160m = (11- 1)(17 - 1) = 10 x 16 = 1604. Select 4. Select ee such that such that e e is relatively prime to is relatively prime to m = 160m = 160 and less and less than than m, 1 < e < 160m, 1 < e < 160gcd (e,160) = 1gcd (e,160) = 1160 = 1 x 10 x 16 160 = 1 x 10 x 16 = 1 x 2 x 10 x 2 x 8 = 1 x 2 x 10 x 2 x 8 = 1 x 2 x 2 x 5 x 2 x 2 x 2= 1 x 2 x 2 x 5 x 2 x 2 x 2 = 1 x 2= 1 x 266 x 5 x 5Assume that we take the smallest prime number in between of Assume that we take the smallest prime number in between of 2, 5 to 160, so 2, 5 to 160, so e = 3e = 3You also can take other value as long as it fulfils the conditions You also can take other value as long as it fulfils the conditions – it must be relatively prime with 160 and it is less than 160– it must be relatively prime with 160 and it is less than 160

Page 31: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 5RSA - example 55. Determine 5. Determine dd such that such that de = 1 mod 160 de = 1 mod 160 and and d < 160d < 160 de de modmod m = 1 m = 1d x 3 = ( ? X 160) + 1d x 3 = ( ? X 160) + 1

1 x 160 + 1 = 160 + 1 = 1611 x 160 + 1 = 160 + 1 = 161 161/3 = 53.6161/3 = 53.62 x 160 + 1 = 320 + 1 = 321 2 x 160 + 1 = 320 + 1 = 321 321/3 = 107321/3 = 107

Find the value which when the results mod 3 with no Find the value which when the results mod 3 with no remainderremainderThe correct value is The correct value is d = 107d = 107, because , because 107 x 3 = 321 = 2 x 160 + 1107 x 3 = 321 = 2 x 160 + 1

You also can take other value as long as it is a positive You also can take other value as long as it is a positive integer integer

Page 32: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 5RSA - example 5Therefore, n = 187, m = 160, e = 3, d = 107Therefore, n = 187, m = 160, e = 3, d = 107

The resulting keys are: The resulting keys are:

Public key = { e, n } Public key = { e, n } and and Private key = { d, n}Private key = { d, n}

Public key = {3, 187}Public key = {3, 187} and and Private key = {107, 187}Private key = {107, 187}

Assume that Assume that P P is the plaintext and is the plaintext and CC is the ciphertext is the ciphertext

The encryption is The encryption is C = PC = P33 mod 187 mod 187

The decryption is The decryption is P = CP = C107107 mod 187 mod 187

Page 33: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA - example 5RSA - example 5Public key = {3, 187}Public key = {3, 187} and and Private key = {107, 187}Private key = {107, 187}

Given P = 7Given P = 7

The encryption is The encryption is C = PC = P33 mod 187 mod 187

C = 7C = 733 mod 187 mod 187

= 343 mod 187= 343 mod 187

= 156= 156

The decryption is The decryption is P = CP = C107107 mod 187 mod 187

P = 156P = 156107107 mod 187 mod 187

= 7= 7

Page 34: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

RSA of RSA of trap-door trap-door functionfunctionA trap-door function is a function that is easy to compute A trap-door function is a function that is easy to compute ‘forwards’ but hard to compute ‘backwards’ ‘forwards’ but hard to compute ‘backwards’

Specifically, it should be fairly cheap to compute the output Specifically, it should be fairly cheap to compute the output given the input, but computationally infeasible to recover the given the input, but computationally infeasible to recover the input given the output input given the output

It is also called as a It is also called as a one-way-functionone-way-function is one that maps a is one that maps a domain into a range such that every function value has a domain into a range such that every function value has a unique inverse, with the condition that the calculation of the unique inverse, with the condition that the calculation of the function is easy whereas the calculation of the inverse is function is easy whereas the calculation of the inverse is infeasible infeasible

Page 35: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

How secure is your RSA ?How secure is your RSA ?With the knowledge ofWith the knowledge of Public key = {3, 187} Public key = {3, 187} andand ciphertext, C = 156, ciphertext, C = 156, how to recover thehow to recover the plaintext, P ? plaintext, P ?

The decryption is The decryption is P = CP = Cdd mod 187 mod 187

P = 156P = 156dd mod 187 mod 187

Actually there are infinite possibility of Actually there are infinite possibility of dd that we can try to that we can try to recover the plaintext. Such condition make RSA very secure recover the plaintext. Such condition make RSA very secure because the it is computationally expensive to do brute-force because the it is computationally expensive to do brute-force analysis (trying all the possible key)analysis (trying all the possible key)

Page 36: RSA Prepared by: SITI ZAINAH ADNAN If you do have any feedback or comment, please feel free to email me at sitizai@hotmail.com Your cooperation is very

How secure is your RSA ?How secure is your RSA ?In 1977, RSA inventors offered a $100 reward for the In 1977, RSA inventors offered a $100 reward for the return of a plaintext sentences, an event they predicted return of a plaintext sentences, an event they predicted might not occur for some 40 quadrillion years with the public might not occur for some 40 quadrillion years with the public key length of 129 decimal digits or around 428 bitskey length of 129 decimal digits or around 428 bits

In April 1994, a group working over the Internet claimed the In April 1994, a group working over the Internet claimed the prize after only eight months of workprize after only eight months of work