This algorithm is based on the difficulty of factorizing large numbers that have 2 and only 2 factors (Prime numbers). The system works on a public and private key system. The public key is made available to everyone. With this key a user can encrypt data but cannot decrypt it, the only person who can decrypt it is the one who possesses the private key. It is theoretically possible but extremely difficult to generate the private key from the public key, this makes the RSA algorithm a very popular choice in data encryption.
First of all, two large distinct prime numbers p and q must be generated. The product of these, we call n is a component of the public key. It must be large enough such that the numbers p and q cannot be extracted from it – 512 bits at least i.e. numbers greater than 10154. We then generate the encryption key e which must be co-prime to the number m = ϕ(n) = (p − 1)(q − 1).We then create the decryption key d such that de mod m = 1. We now have both the public and private keys.
1)Generate two large random primes,and , of approximately equal size such that their product is of the required bit length, e.g. 1024 bits.
3)Choose an integer, , such that .
4)Compute the secret exponent, , such that .
5)The public key isand the private key . Keep all the values d, p, q and secret. [Sometimes the private key is written as because you need the value of n when using d. Other times we might write the key pair as .]
- n is known as the modulus.
- e is known as the public exponent or encryption exponent or just the exponent.
- d is known as the secret exponent or decryption exponent.