Cryptography
Cryptography
RSA Algorithm in Cryptography: The system was invented by three scholars Ron Rivest, Adi Shamir,
and Len Adleman and hence, it is termed as RSA cryptosystem. RSA algorithm is an asymmetric
cryptography algorithm. Asymmetric actually means that it works on two different keys i.e. Public Key
and Private Key. As the name describes that the Public Key is given to everyone and the Private Key is
kept private.
The idea of RSA is based on the fact that it is difficult to factorize a large integer. The public key
consists of two numbers where one number is a multiplication of two large prime numbers. And private
key is also derived from the same two prime numbers. So if somebody can factorize the large number, the
private key is compromised. Therefore encryption strength totally lies on the key size and if we double or
triple the key size, the strength of encryption increases exponentially.
Algorithm: Each person or a party who desires to participate in communication using encryption needs
to generate a pair of keys, namely public key and private key.
Generate the RSA modulus (n)
STEP 1: Select two large prime numbers p and q and they should not be equal
STEP 2: Generate the RSA modulus (n) by multiplying p and q. For strong unbreakable encryption,
let n be a large number, typically a minimum of 512 bits.
n = p*q
Find Derived Number (e)
STEP 3: ɸ(n) = (p-1) * (q-1)
STEP 4: Derived Number (e) will be selected such that e is relatively prime to ɸ(n)
i.e. gcd (e, ɸ(n)) =1 and 1<e<ɸ(n)
Form the public key and private key
STEP 5: calculate ed = 1 mod ɸ(n)
STEP 6: public key = {e,n}, private key ={d,n}
RSA Encryption
Suppose the sender wish to send some text message to someone whose public key is (n, e).
The sender then represents the plaintext as a series of numbers less than n.
To encrypt the first plaintext P, which is a number modulo n. The encryption process is simple
mathematical step as:
STEP 7: Find the cipher text using the formula
C = Pe mod n, where P<n
Where, C = Cipher text, P = plain text, e = Encryption key or public key, n=block size
In other words, the cipher text C is equal to the plaintext P multiplied by itself e times and then
reduced modulo n. This means that C is also a number less than n.
RSA Decryption
STEP 8: Find the plain text from the cipher text using the formula
P = Cd mod n, where d = Decryption key or private key.
Numerical example: In a RSA cryptosystem A uses two prime numbers p=13 and q=17 to generate his
public and private keys. If the public key of A is 35 then determine what will be the private key of A.
Solution: RSA Modulus:
n = p*q = 13 * 17 = 221
Now ɸ(n)=(p-1) *(q-1) = 12*16= 192
Value of public key (e) of A is given as = 35
So, according to RSA algorithm,
ed = 1 mod ɸ(n)
so, d = [(ɸ(n)*i)+1]/e
= (192+1)/35 = 5.5 (for i =1)
we have to increment the value of i until we get the integer value of d.
so for i=2,
d = [(192*2)+1]/35 =11
It only requires a single key for both encryption and It requires two keys, a public key and a private key, one
decryption. to encrypt and the other one to decrypt.
The size of cipher text is the same or smaller than The size of cipher text is the same or larger than the
the original plain text. original plain text.
It is used when a large amount of data is required to It is used to transfer small amounts of data.
transfer.
In symmetric key encryption, resource utilization is In asymmetric key encryption, resource utilization is
low as compared to asymmetric key encryption. high.
Security is less as only one key is used for both It is more secure as two keys are used here- one for
encryption and decryption purposes. encryption and the other for decryption.
Symmetric key cryptography is also known as Asymmetric key cryptography is also known as public-
secret-key cryptography or private key key cryptography or a conventional cryptographic
cryptography. system.