4.3 RSA Algorithm
4.3 RSA Algorithm
3 RSA Algorithm
-Mohd Janisar
• RSA stands for Rivest, Shamir, Aldeman
• It was introduced in 1977.
• It is an asymmetric encryption algorithm.
• Asymmetric because it uses one key for encryption and one for
decryption.
• Both the public and the private keys can encrypt/decrypt a message.
• The opposite key from the one used to encrypt a message is used to
decrypt it.
• This is one reason why RSA has become the most used
asymmetric algorithm.
• It provides a method to assure the confidentiality, integrity, authenticity
and nonrepudiation of electronic communications and data storage.
Steps for the key generation in
RSA :
• Consider 2 prime numbers. Lets say p and q
• Calculate n which is product of p and q. i.e. n=p*q
• Find Euler’s Totient function Φ(n) = (p-1)*(q-1)
• Select public key e such that
1. It must be prime
2. It must be less than Φ(n)
3. Must not be factor of Φ(n) i.e. GCD(e,Φ(n))=1.
• Find private key d such that the equation (d*e)mod T=1 holds
true.
• Lets see each step in detail….
• Consider two prime numbers as p=3, q=5;
• Lets calculate n as p*q. n=3*5=15
• Calculate Totient function Φ(n) = (p-1)*(q-1)
so Φ(n) = (3-1)*(5-1)
=8
• Find public key ‘e’ such that it’s a prime number which is less than Φ(n) and
GCD(e, Φ(n) ) =1
• The meaning of GCD(e, Φ(n) ) =1 is we have to find such a prime number less
than Φ(n) , when taken with Φ(n) , the greatest common divisor for both
should be none other than 1.
• Eg: In our case, prime numbers less 8 (i.e. the value of Φ(n)) are 3,5,7.
(Though 2 is prime number less than 8, it can not be considered because,
GCD(2,8) is not 1)
• So GCD(3,8)=1
GCD(5,8)=1 So lets select 3 as public key among 3,5,7
GCD(7,8)=1
• The last and final step is to find private key with the equation
(e*d)mod Φ(n)=1
• So in our example when we substitute values the equation
becomes : (3*d) mod 8=1
• This should be product of 3*d which should be multiple of 8
plus 1
Eg: consider d=3 then 3*3=9 which is (8*1)+1
similarly, d=11 then 11*3=33 which is (8*4)+1
This way it satisfies equation (3*3) mod 8=1 and (3*11)mod 8=1
for values 3 and 11
• So we have to find such numbers and select any one as private
key.
In our case lets take d=11 as a private key
Lets try encryption and decryption
Consider plain text as 8
Given p=3, q=5,
We calculated n=15, e=3, d=11
So the plain text 8 is ciphered as 2
Then, cipher text c =(p^e)mod n
∴ c= (8^3) mod 15
= 512 mod 15
=2
Lets have decryption of plain text from cipher text
Plain text p=(c^d) mod 15
So the cipher text 2 is decrypted as 8
∴ c= (2^11) mod 15
= 2048 mod 15
=8
Problem :
if p = 13, q = 5 and e = 7, find the value of d and plain text of cipher value 6.