Public Key Encryption
Public Key Encryption
Your Name
Public Key Cryptography
• Each user has a pair of keys:
2
Public Key Cryptography
Ciphertext
Plaintext Encryption Decryption Plaintext
3
Public Key Cryptography
4
The RSA Public Key System
• Most well-known and popular public key system.
5
RSA Algorithm
• Generate two prime numbers, p and q.
• Calculate their product, n = p x q.
• Compute φ(n) = (p -1) x (q-1). Euler’s Totient
Function
• Choose a large integer, e, such that e is relatively
prime to φ(n). [gcd(e, φ(n)) is 1].
• Select a value, d, such that e x d ≡ 1 mod φ(n).
[i.e.,(e x d) – 1 is divisible by φ(n). Also e and d are
multiplicative inverse of each other under φ(n) and
gcd(d , φ(n)) is 1].
6
RSA Algorithm (contd.)
• Public key consists of the pair (e,n).
• A plaintext, M is encrypted to ciphertext, C as
follows:
e
C = M mod n
• The plaintext is recovered from the ciphertext as
follows:
d
M = C mod n
• The security of the system relies on the fact that it is
almost impossible to calculate d if only (e,n) is
known.
7
RSA Example
• Let, p = 11 and q = 13.
• Choose e = 11.
8
How to calculate d, given e and φ(n)?
• Find gcd(e, φ(n)).
• Back trace the steps so as to obtain the multiplicative
inverse of e,which is d.
• In this eg, φ(n) = 120 and e =11.
Find gcd(e,φ(n)) = gcd(11,120)
120 = 11 x 10 + 10
11 = 10 x 1 + 1
10 = 1 x 10 + 0
gcd(11,120) = 1
14
• Back trace the steps.
1 = 11 – (10 x 1)
= 11 – [120 – (11 x 10)]
= 11 – 120 + 11 x 10
= 11[1 + 10] – 120
= 11 x 11 – 120
Here d = 11.
15
Encryption is as follows,
15
Given p = 23, q = 37 and e = 5. Find the value of d and
also encrypt M = 24 using RSA. Show the decryption
of the ciphertext using fast exponentiation.
• Find gcd(5,792)
792 = 5 x 158 + 2
5=2x2+1
2=1x2+0
16
• Back tracing,
1 = 5 – (2 x 2)
= 5 – 2(792 – 5 x 158)
= 5 – 2 x 792 + 2 x 5 x 158
= 5(1 + 2 x 158) – 2 x 792
= 5 (317) – 2 x 792
Hence, d = 317.
• C = 245 mod 851 = 668.
• Decryption, P = 668317 mod 851 = 24.
17
RSA Example
• Given, p = 17, q = 11, e = 7. Encrypt P = 88. Also
decrypt the obtained cipher text using fast
exponentiation.
• We get, n = p x q = 187 and φ(n) = (p -1) x (q-1) =
160.
• Calculate d such that, e x d ≡ 1 mod φ(n).
We get, d =23.
• C = 887 mod 187 = 11.
• For decryption, P = 1123 mod 187 = 88.
8
• P=7,q=5 and e=2 Message M=11
15
• M=784, e=71, p= 97, q= 101
16
17
18