0% found this document useful (0 votes)
63 views

Public Key Encryption

The document discusses public key cryptography and the RSA algorithm. It explains that in RSA, each user has a public key and private key pair. The public key is used to encrypt messages, while only the private key can decrypt messages intended for that user. It then describes how the RSA algorithm works, generating the keys from two prime numbers and using modular exponentiation for encryption and decryption. Several examples are provided to illustrate the RSA process.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

Public Key Encryption

The document discusses public key cryptography and the RSA algorithm. It explains that in RSA, each user has a public key and private key pair. The public key is used to encrypt messages, while only the private key can decrypt messages intended for that user. It then describes how the RSA algorithm works, generating the keys from two prime numbers and using modular exponentiation for encryption and decryption. Several examples are provided to illustrate the RSA process.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Public Key Cryptography

Your Name
Public Key Cryptography
• Each user has a pair of keys:

i. Public key - Known to all and is used to encrypt


messages.
ii. Private key – Known only to the owner and is
used to decrypt messages.

• Also known as Asymmetric cryptography.

2
Public Key Cryptography

• Encryption – Sender encrypts the message by the


public key of the receiver.

• Decryption – Only the intended receiver can decrypt


the message by his/her private key.

Public Key Private Key

Ciphertext
Plaintext Encryption Decryption Plaintext

3
Public Key Cryptography

4
The RSA Public Key System
• Most well-known and popular public key system.

• Introduced in 1978 by Rivest, Shamir, Adleman.

• Based on the fact that it is relatively easy to calculate


the product of two prime numbers, but determining
the original prime numbers, given the product, is
more complicated.

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.

• So, n = p x q = 143 and φ(n) = (p -1) x (q-1) = 120.

• Choose e = 11.

• Calculate d such that, e x d ≡ 1 mod φ(n).

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,

• Let M = 7 be the plaintext.

• Ciphertext, C = 711 mod 143


= 106.

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.

• n = 851 and φ(n) = 792.

• 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

You might also like