Docsity

Understanding Public Key Cryptography: RSA and Diffie-Hellman, Slides of Computer Science

Partial preview of the text

Download Understanding Public Key Cryptography: RSA and Diffie-Hellman and more Slides Computer Science in PDF only on Docsity!

Part 1  Cryptography 1

Public Key Cryptography

Part 1  Cryptography 2

Public Key Cryptography

 Two keys

o Sender uses recipient’s public key to encrypt o Receiver uses his private key to decrypt

 Based on trap door, one way function o Easy to compute in one direction o Hard to compute in other direction o “Trap door” used to create keys o Example: Given p and q, product N=pq is easy to compute, but given N, it is hard to find p and q

Part 1  Cryptography 4

RSA

 Invented by Cocks (GCHQ), independently, by Rivest, Shamir and Adleman (MIT)  Let p and q be two large prime numbers  Let N = pq be the modulus  Totient(N) or (N) = (p-1)(q-1) o Number of positive integers ≤ N that are relatively prime to N  Choose e relatively prime to (p1)(q1)  Find d s.t. ed mod (p1)(q1) = 1  Public key is (N,e)  Private key is d

Part 1  Cryptography 5

RSA

 To encrypt message M<N compute

o C = Me^ mod N

 To decrypt C compute

o M = Cd^ mod N

 Recall that e and N are public

 If attacker can factor N, he can use e to easily find d since ed mod (p1)(q1) = 1

 Factoring the modulus breaks RSA

 It is not known whether factoring is the only way to break RSA

How many forbidden

messages?

 Facts:

o M < N; that is M can be at most pq o M needs to be relatively prime to N

 Number of possible M values:

(N)=(p-1)(q-1)

 Number of forbidden M values:

o pq-(p-1)(q-1) = pq-pq+p+q-1=p+q- o A diminishing value as n (i.e. pq) increases Part 1  Cryptography 7

Part 1  Cryptography 8

Simple RSA Example

 Example of RSA

o Select “large” primes p = 11, q = 3 o Then N = pq = 33 and (p1)(q1) = 20 o Choose e = 3 (relatively prime to 20) o Find d such that ed mod 20 = 1, we find that d = 7 works

 Public key: (N, e) = (33, 3)

 Private key: d = 7

Part 1  Cryptography 10

Diffie-Hellman

Part 1  Cryptography 11

Diffie-Hellman

 Invented by Williamson (GCHQ) and,

independently, by D and H (Stanford)

 A “key exchange” algorithm

o Used to establish a shared symmetric key

 Not for encrypting or signing

 Security rests on difficulty of discrete log

problem: given g, p, and gk^ mod p find k

Part 1  Cryptography 13

Diffie-Hellman

 Suppose that Bob and Alice use gab^ mod p as a symmetric key

 Trudy can see ga^ mod p and gb^ mod p

 Note ga^ gb^ mod p = ga+b^ mod p  gab^ mod p

 If Trudy can find a or b, system is broken

 If Trudy can solve discrete log problem, then she can find a or b

Part 1  Cryptography 14

Diffie-Hellman

Public: g and p

Secret: Alice’s exponent a, Bob’s exponent b

Alice, a Bob, b

ga^ mod p gb^ mod p

 Alice computes (gb)a^ = gba^ = gab^ mod p  Bob computes (ga)b^ = gab^ mod p  Could use K = gab^ mod p as symmetric key

Part 1  Cryptography 16

Diffie-Hellman

 How to prevent MiM attack?

o Encrypt DH exchange with symmetric key o Encrypt DH exchange with public key o Sign DH values with private key o Other?

 You MUST be aware of MiM attack on

Diffie-Hellman

Part 1  Cryptography 17

Notation

 Public key notation o Sign message M with Alice’s private key  [M]Alice o Encrypt message M with Alice’s public key  {M}Alice o Then {[M]Alice}Alice = M and [{M}Alice]Alice = M  Symmetric key notation o Encrypt plaintext P with symmetric key K  C = E(P,K) o Decrypt ciphertext C with symmetric key K  P = D(C,K)