0% found this document useful (0 votes)
4 views5 pages

RSA Encryption Algorithm

The RSA encryption algorithm is a widely used public-key encryption method that employs a pair of keys: a public key for encryption and a private key for decryption. It involves selecting two large prime numbers to generate keys, where the public key is represented as <e, n> and the private key as <d, n>. The algorithm allows secure communication, as only the intended recipient can decrypt the message using their private key.

Uploaded by

shreyains12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

RSA Encryption Algorithm

The RSA encryption algorithm is a widely used public-key encryption method that employs a pair of keys: a public key for encryption and a private key for decryption. It involves selecting two large prime numbers to generate keys, where the public key is represented as <e, n> and the private key as <d, n>. The algorithm allows secure communication, as only the intended recipient can decrypt the message using their private key.

Uploaded by

shreyains12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

RSA Encryption Algorithm

RSA encryption algorithm is a type of public-key encryption algorithm. To


better understand RSA, lets first understand what is public-key encryption
algorithm.

Public key encryption algorithm:


Public Key encryption algorithm is also called the Asymmetric algorithm.
Asymmetric algorithms are those algorithms in which sender and receiver
use different keys for encryption and decryption. Each sender is assigned a
pair of keys:

o Public key
o Private key

The Public key is used for encryption, and the Private Key is used for
decryption. Decryption cannot be done using a public key. The two keys are
linked, but the private key cannot be derived from the public key. The public
key is well known, but the private key is secret and it is known only to the
user who owns the key. It means that everybody can send a message to the
user using user's public key. But only the user can decrypt the message
using his private key.

The Public key algorithm operates in the following manner:


o The data to be sent is encrypted by sender A using the public key of
the intended receiver
o B decrypts the received ciphertext using its private key, which is
known only to B. B replies to A encrypting its message using A's public
key.
o A decrypts the received ciphertext using its private key, which is
known only to him.

RSA encryption algorithm:


RSA is the most common public-key algorithm, named after its
inventors Rivest, Shamir, and Adelman (RSA).

RSA algorithm uses the following procedure to generate public and


private keys:

o Select two large prime numbers, p and q.


o Multiply these numbers to find n = p x q, where n is called the
modulus for encryption and decryption.
o PUBLIC KEY
o Choose a number e less than n, such that e is relatively prime to φ (n),

(φ (n) = (p - 1) x (q -1).
o It means that e and (p - 1) x (q - 1) have no common factor except 1.
o Choose "e" such that 1<e < φ (n), e is prime to φ (n), gcd (e, φ (n))
=1
o Then the public key is <e, n>.
o To determine the private key, we use the following formula to
calculate the d such that:
De mod {(p - 1) x (q - 1)} = 1
Or
De mod φ (n) = 1
o The private key is <d, n>.

ENCRYPTION

o A plaintext message m is encrypted using public key <e, n>.


o To find ciphertext from the plain text following formula is used to get
ciphertext C.

C = me mod n
DECRYPTION

o A ciphertext message c is decrypted using private key <d, n>.


o To calculate plain text m from the ciphertext c following formula is
used to get plain text m.

m = cd mod n
Example
Example 2
Select two prime no's. Suppose P = 53 and Q = 59.

Now First part of the Public key : n = P*Q = 3127.

We also need a small exponent say e :

But e Must be An integer.

Not be a factor of Φ(n), 1 < e < Φ(n)

Such that Φ(n) = (P-1)(Q-1)

(Here e=3)

Our Public Key is made of n and e ( n = 3127 and e = 3)

>> Generating Private Key:

We need to calculate Φ(n) :

Such that Φ(n) = (P-1)(Q-1)

so, Φ(n) = 3016

Now calculate Private Key, d :

d = (k*Φ(n) + 1) / e for some integer k


For k = 2, value of d is 2011.
Now we are ready with our –
Public Key ( n = 3127 and e = 3) and
Private Key(d = 2011)

Now we will encrypt “HI”:

Convert letters to numbers : H = 8 and I = 9


Thus Encrypted Data c = (89 e)mod n
Thus our Encrypted Data comes out to be 1394
Now we will decrypt 1394 :
Decrypted Data = (c d)mod n
Thus our Encrypted Data comes out to be 89
8 = H and I = 9 i.e. "HI".

You might also like