0% found this document useful (0 votes)
9 views24 pages

13-RSA-24-01-2025

The document outlines the RSA algorithm, a widely used public-key cryptographic technique developed by Rivest, Shamir, and Adleman in 1977. It explains the steps involved in generating keys, encrypting, and decrypting messages using RSA, including examples with calculations. Additionally, it covers the principles of asymmetric key cryptography and other related cryptographic techniques.

Uploaded by

selmon.bhoy.321
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)
9 views24 pages

13-RSA-24-01-2025

The document outlines the RSA algorithm, a widely used public-key cryptographic technique developed by Rivest, Shamir, and Adleman in 1977. It explains the steps involved in generating keys, encrypting, and decrypting messages using RSA, including examples with calculations. Additionally, it covers the principles of asymmetric key cryptography and other related cryptographic techniques.

Uploaded by

selmon.bhoy.321
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/ 24

BCSE309L - Cryptography and Network Security

Module 3 – RSA Algorithm

Dr. Somasundaram S K
Assistant Professor Senior Grade 2
School of Computer Science and
Engineering,
Vellore Institute of Technology,
Vellore – 632 014
Phone No: +91 9843665115
Mail ID: [email protected]
Location: PRP Block – 218D
Contents
CO2 : To understand concept of various cryptographic
techniques

• Asymmetric key cryptographic techniques: principles


• RSA algorithm
• ElGamal algorithm
• Elliptic Curve cryptography
• Homomorphic Encryption and Secret Sharing
• Key distribution and Key exchange protocols
• Diffie-Hellman Key Exchange
• Man-in-the-Middle Attack
Asymmetric key cryptography
• Operates on the principle of using a pair of
mathematically linked keys:
• Public key that can be shared freely

• Private key that must be kept secret

• Data encrypted with one key can only be decrypted


using the corresponding key in the pair
Key principles of asymmetric key
cryptography
• Key Pairs:
• Each user generates a unique pair of keys - a public key and a private key
• Public Key Distribution:
• The public key can be freely distributed to anyone who needs to send encrypted
messages to that user
• Private Key Confidentiality:
• The private key must be kept strictly confidential and never shared with anyone
• Encryption with Public Key:
• When sending a message, the sender encrypts it using the recipient's public key
• Decryption with Private Key:
• Only the intended recipient can decrypt the message using their corresponding
private key
Public-Key Cryptosystems
Encryption with public key
Public-Key Cryptosystems
Encryption with private key
RSA Algorithm
• One of the first successful responses to the challenge
was developed in 1977 by Ron Rivest, Adi Shamir, and
Len Adleman at MIT and first published in 1978
• The Rivest-Shamir-Adleman (RSA) scheme – most widely
accepted and implemented general-purpose approach to
public-key encryption
• Based on the mathematical fact that it is easy to find
and multiply large prime numbers together, but it is
extremely difficult to factor their product
Steps of RSA
1. Choose two large prime numbers p and q
2. Calculate n = p * q
3. Calculate ø(n) = (p - 1) * (q - 1)
The preceding relationship holds if e and d are multiplicative
inverses modulo ø(n), where ø(n) is the Euler totient function
4. Select e such that e is relatively prime to ø(n) and less than ø(n)
GCD (ø(n), e) = 1

5. Find d (private key) such that de ≡ 1 mod ø(n) and d < ø(n)
The relationship between e and d can be expressed as
ed mod ø(n) = 1
ed ≡ 1 mod ø(n)
d ≡ e-1 mod ø(n)
Cont…

6. To encrypt, find ciphertext C = Me mod n


• Public key encryption algorithm with a public key
of PU = {e, n}

7. To decrypt, find plaintext M = Cd mod n

• private key of PR = {d, n}


Example 1
Inputs are p = 17, q = 11 and M = 88
1. Two prime numbers such as p = 17, q=11
2. Calculate n = p * q
n = 17 * 11
n = 187
3. Calculate ø(n) = (p - 1) * (q - 1)
= (17 – 1) * (11 – 1)
= 16 * 10
ø(n) = 160
4. Select e such that e is relatively prime to ø(n) = 160 and less than
ø(n); we choose e = 7
GCD (ø(n), e) = 1
GCD (160, 7) = 1 ------ Possible values are, 3, 7, 11,…..
Cont…
4. Find d (private key) such that de ≡ 1 mod ø(n) and d < ø(n)
d ≡ e-1 mod ø(n)
d ≡ 7-1 mod 160
7 x ? mod 160 = 1
7 x 23 mod 160 = 1 [use Extended Euclidean algorithm]
161 mod 160 = 1
d = 23
de ≡ 1 mod ø(n)
23 x 7 ≡ 1 mod 160
161 ≡ 1 mod 160
161 mod 160 = 1 mod 160
Finding ‘d’ value using EEA
q a b r t1 t2 t

22 160 7 6 0 1 -22

1 7 6 1 1 -22 23

6 6 1 0 -22 23 160

1 0 23 -160
Cont…
5. To do encryption
C = Me mod n PU = (e, n) = (7, 187) M = 88
C = 887 mod 187,
887 mod 187 = [(884 mod 187) * (882 mod 187) * (881 mod
187)] mod 187
881 mod 187 = 88
882 mod 187 = 7744 mod 187 = 77
884 mod 187 = (882)2 mod 187
= 772 mod 187 = 5929 mod 187 = 132
887 mod 187 = (132 * 77 * 88) mod 187
= 894432 mod 187
C = 11
Cont…
6. To do Decryption
M = Cd mod n PR = (d, n) = (23, 187) C = 11
M = 1123 mod 187
1123 mod 187 = [(111 mod 187) * (112 mod 187) * (114 mod 187) * (1116
mod 187)] mod 187
1123 mod 187 = [(111 mod 187) * (112 mod 187) * (114 mod 187) * (118
mod 187) * (118 mod 187)] mod 187
111 mod 187 = 11
112 mod 187 = 121
114 mod 187 = 1212 = 14,641 mod 187 = 55
118 mod 187 = 552 = 3025 mod 187 = 33
1123 mod 187 = (11 * 121 * 55 * 33 * 33) mod 187
M = 79720245 mod 187
M = 88
Example 2
Inputs are p = 3, q = 5, e (public key) = 3 and m=2
1. Two prime numbers such as p = 3, q=5
2. Let n= p * q
n=3*5
n = 15
3. Let ø(n) = (p-1)*(q-1)
= (3 – 1) * (5 – 1)
ø(n) = 8
Cont…
4. Find d (private key) such that de =1 mod ø(n)

d = e-1 mod ø(n)

d = 3-1 mod 8

3 x d mod 8 = 1

3 x 3 mod 8 = 1 [use EEA]

9 mod 8 = 1

d=3
Cont…
5. To do encryption
C = Me mod n
C = 23 mod 15, C = 8 mod 15, C = 8
6.To do Decryption
m = Cd mod n
m = 83 mod 15, m = 512 mod 15, m = 2
Exercise
• Perform encryption and decryption using the RSA
algorithm for the following:
1. p=3; q=11; e=7; M=5
2. p=5; q=11; e=3; M=9
3. p=7; q=11; e=17; M=8
4. p=11; q=13; e=11; M=7
5. p=17; q=31; e=7; M=2
6. p=137; q=131; e=3; M=153
4. p=11; q=13; e=11; M=7
6. p=137; q=131; e=3; M=153

You might also like