How RSA Algorithm Works
The RSA algorithm is used for public key encryption and digital signature. In this algorithm data (input) is encrypted using a public key and decrypted using private key. The public key is exposed to the sender and the receiver will keep the private key. Most people knows this ability of RSA algorithm. But they don’t know how it is possible.
Here is the mathematical explanation of RSA algorithm
- Let’s assume that p and q are two large prime numbers.
- Now calculate n = p*q and (φ) phi = (p-1)(q-1).
- Choose an integer e, 1 < e < phi, such that gcd(e, phi) = 1
- Find the secret exponent d, 1 < d < phi, such that
(e*d) % phi = 1 - The public key is (n, e) and the private key is (n, d).
- The values of p, q, and phi should also be kept secret.
- Encryption : C=(I^e)%n
- Decryption: I=(C^d)%n
- n is known as the modulus.
- e is known as the public exponent or encryption exponent.
- d is known as the secret exponent or decryption exponent.
Let us examine the algorithm step by step
- Let p=7 and q=17
- n=pq=7*17=119
- phi=(p-1)*(q-1)=(7–1)*(17–1)*17=96
- Let e=5. So, gcd(5,96)=1
- Calculated d=77 as (5*77)%96=1
- So our private key is (119,77) and the public key is (119,5)
Now we can examine encrypt and decrypt method.
Let our input I is 7. So, C=(7^5)%119=16807%119=28
So, 28 is the encrypted number. We cannot find 7 from the encrypted number 28 and public key (119,5).
Let us use our private key (119,77) to decrypt 28.
I=(28^77)%119=2.6987857810871449487269638198368e+111%119=7. So, 7 is the decrypted number.
1 Comments:
I just heard the name of this algorithm while learning about digital signatures. In this article you have posted the complete working of this important algorithm. Thanks a lot for explaining it.
electronic signature software
Post a Comment
Subscribe to Post Comments [Atom]
<< Home