Deffie Hellman Key Exchange and RSA
Deffie Hellman Key Exchange and RSA
Cyber Security
Public-Key Cryptography
Diffie-Hellman Key Exchange
Color Mixing Example
The Problem of Key Exchange
• Alice mixed
• [(Yellow + Teal) from Bob] + Orange
• Bob mixed
• [(Yellow + Orange) from Alice] + Teal
Alice & Bob have agreed to a
shared color unknown to Eve
• How is it that Alice & Bob’s final mixture is
secret?
public ? private
key key
Alic
e Bo
b
Given: Everybody knows Bob’s public key
- How is this achieved in practice?
Only Bob knows the corresponding
private key
Goals: 1. Alice wants to send a message
that
only Bob can read
2. Bob wants to send a message slide 25
Applications of Public-Key Crypto
• Encryption for confidentiality
• Anyone can encrypt a message
• With symmetric crypto, must know the secret key to encrypt
• Only someone who knows the private key can decrypt
• Secret keys are only stored in one place
• Digital signatures for authentication
• Only someone who knows the private key can sign
• Session key establishment
• Exchange messages to create a secret session key
• Then switch to symmetric cryptography (why?)
slide 26
Public-Key Encryption
• Key generation: computationally easy to generate a pair
(public key PK, private key SK)
• Encryption: given plaintext M and public key PK, easy to
compute ciphertext C=EPK(M)
• Decryption: given ciphertext C=EPK(M) and private key
SK, easy to compute plaintext M
• Infeasible to learn anything about M from C without SK
• Trapdoor function: Decrypt(SK,Encrypt(PK,M))=M
slide 27
Some Number Theory Facts(not in syllabus)
slide 28
RSA Cryptosystem
• Key generation:
• Generate large primes p, q [Rivest, Shamir, Adleman
1977]
• At least 2048 bits each… need primality testing!
• Compute n=pq
• Note that ϕ(n)=(p-1)(q-1)
• Choose small e, relatively prime to ϕ(n)
• Typically, e=3 (may be vulnerable) or e=216+1=65537 (why?)
• Compute unique d such that ed ≡ 1 mod ϕ(n)
or, ed mod ϕ(n) = 1
• Public key = (e,n); private key = d
• Encryption of m: c = me mod n
• Decryption of c: cd mod n = (me)d mod n = m
slide 29
Why RSA Decryption Works(not
in syllabus)
• e⋅d ≡ 1 mod ϕ(n)
• Thus e⋅d = 1+k⋅ϕ(n) = 1+k(p-1)(q-1) for some k
• If gcd(m,p)=1, then by Fermat’s Little Theorem, mp-1 ≡ 1
mod p
• Raise both sides to the power k(q-1) and multiply by m,
obtaining m1+k(p-1)(q-1) ≡ m mod p
• Thus med ≡ m mod p
• By the same argument, med ≡ m mod q
• Since p and q are distinct primes and p⋅q=n,
med ≡ m mod n
slide 30
Why Is RSA Secure?
• RSA problem: given c, n=pq, and
e such that gcd(e,(p-1)(q-1))=1,
find m such that me=c mod n
• In other words, recover m from ciphertext c and public key
(n,e) by taking eth root of c modulo n
• There is no known efficient algorithm for doing this
• Factoring problem: given positive integer n, find primes
p1, …, pk such that n=p1e1p2e2…pkek
• If factoring is easy, then RSA problem is easy, but may
be possible to break RSA without factoring n
slide 31
Problems with RSA
slide 32
Problems with RSA
Assume that Bob has chosen an especially secure 4096-bit modulus for the
RSA algorithm – it is the product of two prime numbers of length 2048 bits
each. To keep the encryption efficient, he chooses 𝑒 = 17. Alice encrypts a
128-bit AES key 𝑘 with these RSA parameters and sends the cryptogram 𝑐
= 𝑘17 mod 𝑛 to Bob, with whom she then shares an AES key 𝑘.
Unfortunately, when using RSA, the chosen parameters are not secure –
an attacker who intercepts the ciphertext 𝑐 and knows Bob’s public key
(𝑒, 𝑛) can easily decrypt the message.
Why?
This is because the number 𝑘17 is a maximum of 128 · 17 = 2176 bits long
and thus much shorter than the modulus 𝑛. The modulo operation is
therefore not applied during encryption, and we have 𝑘𝑒 mod 𝑛 = 𝑘𝑒. This
reduces the problem of computing the plaintext 𝑘 from the ciphertext 𝑐 to
the problem of computing the 𝑒-th root of an integer – this is a simple
problem that any computer can quickly solve.
slide 33
References
• The whole slide is taken from the slides of Dr. Md
Saidur Rahman, CSE, BUET