Lecture 8 RSA Encryption 28032023 023430pm
Lecture 8 RSA Encryption 28032023 023430pm
Karachi Campus
Department of Computer Science
By : MUHAMMAD IQBAL
Assistant Professor
Department of Computer Science
BAHRIA UNIVERSITY ,Karachi Campus
Information Security
Spring 2023
Objectives
Asymmetric Cryptography
RSA working
Trapdoor Function
2
Secret Key Public Key
(Symmetric) (Asymmetric)
• 1 Key = encrypt & decrypt • Two separate keys
▫ Advantage: Fast ▫ 1 public key to encrypt
▫ Disadvantage: Not safe ▫ 1 private key to decrypt
RSA Encryption
• Rivest, Ron
Shamir, Adi
Adleman, Leonard
Easy
439 * 541 = 237499
Hard
283 * 719 = 203477
Generating Keys
Public Key Private Key
• Find Φ(n)=Φ(pq)
• Choose e such that
=Φ(p)*Φ(q)= (p-1)(q-1)
gcd(e, Φ(n))=1
• Find d such that d is
multiplicative inverse of
e(modΦ(n))
▫ de ≣ 1(mod Φ(n))
M = Plaintext C = Ciphertext
p,q = prime #’s n = p*q
e: gcd(e, Φ(n))=1 d: de ≣ 1(mod Φ(n))
Example
• Message: “Hi” = 89
• p = 11 q = 13
• n = 11 * 13 = 143
• Φ(143) = (11 – 1)(13 – 1) = 120
• Set e = 7
• d = 103
Public Key Secret Key
n = 143 p = 11 p = 13
e=7 Φ(n) = 120 d = 103
Hi = 89 D C d (mod n)
E M e (mod n) 67103 (mod143) 89
89 7 (mod143) 67 89 = Hi
89
67
Hi
67
Hi
Bob Alice
Many values of n have over 200 digits, making the RSA algorithm nearly unbreakable.
Conclusion
• Security relies on difficulty of factoring large #’s
Many values of n have over 200 digits, making the RSA algorithm nearly
unbreakable.
• Standard public key = 1024 bits…that’s 309 digits!
RSA-1024:
13506641086599522334960321627880596993888147560
56670275244851438515265106048595338339402871505
71909441798207282164471551373680419703964191743
04649658927425623934102086438320211037295872576
23585096431105640735015081875106765946292055636
85529475213500852879416377328533906109750544334
999811150056977236890927563
Find More
• https://sites.google.com/site/danzcosmos/why-
rsa-encryption-is-secure
• https://intellipaat.com/blog/what-is-rsa-algorit
hm/