0% found this document useful (0 votes)
18 views9 pages

Rsa Algorithm

Uploaded by

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

Rsa Algorithm

Uploaded by

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

Experiment 2: Implementation of Cryptanalysis using RSA.

RSA ALGORITHM
RSA algorithm (Rivest-Shamir-Adleman)

• RSA algorithm is an asymmetric cryptography


algorithm. Asymmetric actually means that it works on
two different keys i.e. Public Key and Private Key.
• Public Key is given to everyone
• Private key is kept private.
RSA algorithm uses the following procedure to generate
public and private keys:

1. select two large prime numbers, p and q.


2. Multiply these numbers to find n = p x q, where n is called the modulus for encryption and decryption.
3. Choose a number e less than n, such that n is relatively prime to (p - 1) x (q -1). It means that e and (p - 1) x (q -
1) have no common factor except 1. Choose "e" such that 1<e < φ (n), e is prime to φ (n),
gcd (e,d(n)) =1
4. If n = p x q, then the public key is <e, n>. A plaintext message m is encrypted using public key <e, n>. To find
ciphertext from the plain text following formula is used to get ciphertext C.
C = me mod n
Here, m must be less than n. A larger message (>n) is treated as a concatenation of messages, each of which is
encrypted separately.
5. 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
6. The private key is <d, n>. A ciphertext message c is decrypted using private key <d, n>. To calculate plain
text m from the ciphertext c following formula is used to get plain text m.
m = cd mod n
Example 1:

• This example shows how we can encrypt plaintext 9 using the RSA public-key encryption
algorithm. This example uses prime numbers 7 and 11 to generate the public and private
keys.
• Step 1: Select two large prime numbers, p, and q.
• p=3
• q=5
• step 2: Multiply these numbers to find n = p x q, where n is called the modulus for
encryption and decryption.
• First, we calculate
• n=pxq
• n=3x5
• n = 15
• Step 3: Choose a number e less that n, such that n is relatively prime to (p - 1) x (q -1). It
means that e and (p - 1) x (q - 1) have no common factor except 1. Choose "e" such that
1<e < φ (n), e is prime to φ (n),

• gcd (e, φ (n)) =1.


• Second, we calculate
• φ (n) = (p - 1) x (q-1)
• φ (n) = (3 - 1) x (5 - 1)
• φ (n) = 2 x 4
• φ (n) = 8
• Let us now choose relative prime e of 8 as 3.
• Thus the public key is <e, n> = (3, 15)
• Step 4: A plaintext message m is encrypted using public key <e, n>. To
find ciphertext from the plain text following formula is used to get
ciphertext C.
• To find ciphertext from the plain text following formula is used to get
ciphertext C.
• C = me mod n Note: m<n here m=4
• C = 43 mod 15
• C = 64 mod 15
• C=4
• Step 5: The private key is <d, n>. To determine the private key, we use the following
formula d such that:

• d*e mod {(p - 1) x (q - 1)} = 1


• => d*e mod φ (n)=1
• d*3 mod 8= 1, which gives d = 3
• The private key is <d, n> = (3, 15)
• Step 6: A ciphertext message c is decrypted using private key <d, n>. To calculate plain
text m from the ciphertext c following formula is used to get plain text m.
• m = cd mod n
• m = 43 mod 15
• m=4

You might also like