public key cryptosystems diffie hellmangauss.ececs.uc.edu/courses/c6053/lectures/pdf/dh.pdf ·...

38
Public Key Cryptosystems - Diffie Hellman

Upload: others

Post on 04-Jun-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie Hellman

Page 2: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanGet two parties to share a secret number that no one else knows

Page 3: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanGet two parties to share a secret number that no one else knows

Receiver Sender

Page 4: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanGet two parties to share a secret number that no one else knowsCan only use an insecure communications channel for exchange

Receiver Sender

Attacker

Page 5: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanGet two parties to share a secret number that no one else knowsCan only use an insecure communications channel for exchange

Sender

Attacker

p,g

p: prime & (p­1)/2 primeg: less than p    n = gk mod p    for all 0<n<p    and some k

Receiver

(see http://gauss.ececs.uc.edu/Courses/c6053/lectures/Math/Group/group.html)

Page 6: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanA safe prime p:  p = 2q + 1 where q is also prime      Example: 479 = 2*239 + 1 

  If p is a safe prime, then p­1 has large prime factor, namely q.

  If all the factors of p­1 are less than logcp, then the problem   of solving the discrete logarithm modulo p is in P (it's easy).   Therefore, for cryptosystems based on discrete logarithm   (such as Diffie­Hellman) it is required that p­1 has at least   one large prime factor.  

Page 7: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanA strong prime p:  p is large  p­1 has large prime factors (p = aq+1 for integer a and prime q)  q­1 has large prime factors (q = br+1 for integer b, prime r)  p+1 has large prime factors.

A “large” safe prime is likely to be a strong prime.

The performance of some algorithms that factor n = p*q where p and q are prime numbers depends on how large each is ­ they are slower if one of the factors is a large prime.

Page 8: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie Hellman

Important property:

   (ga mod p)b mod p   =   (gb mod p)a mod p

p: prime & (p­1)/2 primeg: less than p    n = gk mod p    for all 0<n<p    and some k

(see http://gauss.ececs.uc.edu/Courses/c6053/lectures/Math/Modpow/modulo.html)

Page 9: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie Hellman

Important property:

   (ga mod p)b mod p   =   (gb mod p)a mod p

Example:    p = 563,  g = 5,  a = 9,  b = 14

   59 mod 563 = 1953125 mod 563 = 78

   7814 = 308549209196654470906527744         mod 563 = 117

Page 10: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie Hellman

Important property:

   (ga mod p)b mod p   =   (gb mod p)a mod p

Example:    p = 563,  g = 5,  a = 9,  b = 14

   59 mod 563 = 1953125 mod 563 = 78

   7814 = 308549209196654470906527744         mod 563 = 117

   514 mod 563 = 6103515625 mod 563 = 534

   5349 =  153312511596308814665178256828300148736           mod 563 = 117

Page 11: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanGet two parties to share a secret number that no one else knowsCan only use an insecure communications channel for exchange

Receiver Sender

Attacker

563, 5

Page 12: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanGet two parties to share a secret number that no one else knowsCan only use an insecure communications channel for exchange

Receiver Sender

Attacker

563, 5

9

Page 13: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanGet two parties to share a secret number that no one else knowsCan only use an insecure communications channel for exchange

Receiver Sender

Attacker

563, 5

914

Page 14: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanGet two parties to share a secret number that no one else knowsCan only use an insecure communications channel for exchange

Receiver Sender

Attacker

563, 5

91478

59 mod 563 = 78

Page 15: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanGet two parties to share a secret number that no one else knowsCan only use an insecure communications channel for exchange

Receiver Sender

Attacker

563, 5

914

7814  mod 563 = 117

Page 16: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanGet two parties to share a secret number that no one else knowsCan only use an insecure communications channel for exchange

Receiver Sender

Attacker

563, 5

914

117

Page 17: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanGet two parties to share a secret number that no one else knowsCan only use an insecure communications channel for exchange

Receiver Sender

Attacker

563, 5

914

534   mod 563 = 1179

534

117

514  mod 563 = 534

Page 18: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanGet two parties to share a secret number that no one else knowsCan only use an insecure communications channel for exchange

Receiver Sender

Attacker

563, 5

914

117 117

Page 19: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanVulnerability to the "Man­in­the­middle" attack

Receiver Sender

Attacker

563, 5

914

34

Page 20: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanVulnerability to the "Man­in­the­middle" attack

Receiver Sender

Attacker

563, 5

914

34

78

Page 21: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanVulnerability to the "Man­in­the­middle" attack

Receiver Sender

Attacker

563, 5

914

34 250

Page 22: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanVulnerability to the "Man­in­the­middle" attack

Receiver Sender

Attacker

563, 5

914

34

205

250

Page 23: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanVulnerability to the "Man­in­the­middle" attack

Receiver Sender

Attacker

563, 5

914

34

459

250

Page 24: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanVulnerability to the "Man­in­the­middle" attack

Receiver Sender

Attacker

563, 5

914

34

534

459

250

Page 25: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanVulnerability to the "Man­in­the­middle" attack

Receiver Sender

Attacker

563, 5

914

34

459

250

459

Page 26: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanVulnerability to the "Man­in­the­middle" attack

Receiver Sender

Attacker

563, 5

914

34

459

250

459

205

Page 27: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanVulnerability to the "Man­in­the­middle" attack

Receiver Sender

Attacker

563, 5

914

34

459

250

459

250

Page 28: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanFixing the vulnerability to the "Man­in­the­middle" attack

Receiver Sender

Attacker

563, 5

78534

205

Page 29: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanWhere is the security?

Attacker sees A=g a mod p, B=g 

b mod p but does not know a, b

Page 30: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanWhere is the security?

Attacker sees A=g a mod p, B=g 

b mod p but does not know a, b

Attacker needs to compute K=gab mod p from the above.Can be done if it is feasible to take the logp A and logp B

This is called the discrete logarithm problem.

Computing the discrete logarithm of a number modulo p takes roughly the same amount of time as factoring the product of two primes the same size as p, which is what the security of the RSA cryptosystem relies on. Thus, the Diffie­Hellman protocol is roughly as secure as RSA. 

Page 31: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanSigning a message:   Let p, q, r be primes such that      p = 2q+1, and q = 2r+1

   Let m be the message to be signed.

   Let x be a permanent secret key owned by the signer

   Let gx mod q be the public key associated with x

   

Page 32: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanSigning a message:   Let p, q, r be primes such that      p = 2q+1, and q = 2r+1

   Let m be the message to be signed.

   Let x be a permanent secret key owned by the signer

   Let gx mod q be the public key associated with x

   Generate a random secret y with public key gy mod p   Let Y = (gy mod p) mod q;    calculate the signature s:   Find a, b, c  s.t.  ax + by = c mod q   Send: a,b,c,Y   Receiver has: gx mod q, p, q

   

Page 33: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanSigning a message:   Let p, q, r be primes such that      p = 2q+1, and q = 2r+1

   Let m be the message to be signed.

   Let x be a permanent secret key owned by the signer

   Let gx mod q be the public key associated with x

   Generate a random secret y with public key gy mod p   Let Y = (gy mod p) mod q;    calculate the signature s:   Find a, b, c  s.t.  ax + by = c mod q   Send: a,b,c,Y   Receiver has: gx mod q, p, q

   Verify:  (gx mod p)a × (gy mod p)b = gc mod q

Page 34: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanSigning a message:   Let p, q, r be primes such that      p = 2q+1, and q = 2r+1

   Let m be the message to be signed.

   Let x be a permanent secret key owned by the signer

   Let gx mod q be the public key associated with x

   Generate a random secret y with public key gy mod p   Let Y = (gy mod p) mod q;    calculate the signature s:   Find a, b, c  s.t.  ax + by = c mod q      the following are possibilities for a,b,c:      a=m, b=Y, c=s ;   a=1, b=Ym, c=s ;   a=1, b=Ym, c=ms;      a=1, b=Ym, c=Ys ;   a=1, b=ms, c=Ys

   

Page 35: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanSigning a message:  Why is the y needed?

   Try this:  s = x*m mod q –  x is secret, q is public and safe          to check the signature do this (receiver knows x): 

              gs mod q = (gx mod q)m mod q 

       

Page 36: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanSigning a message:  Why is the y needed?

   Try this:  s = x*m mod q –  x is secret, q is public and safe          to check the signature do this (receiver knows x): 

              gs mod q = (gx mod q)m mod q 

   But then x = s/m mod q revealing the secret x   so that is why the extra secret y is used    

Page 37: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanSigning a message:  Why is the y needed?

   Can't do this:  s = xm mod q – to check the signature do

   this: gs mod p = (gx mod q)m mod q    But then x = s/m mod q revealing the secret x

   A different y must be chosen for each signature ­   Otherwise, if you have two sets of a, b, c for the same x, y,    you can solve for the secrets x and y!!!

   

Page 38: Public Key Cryptosystems Diffie Hellmangauss.ececs.uc.edu/Courses/c6053/lectures/PDF/dh.pdf · Public Key Cryptosystems Diffie Hellman A safe prime p: p = 2q + 1 where q is also prime

Public Key Cryptosystems ­ Diffie HellmanSigning a message:  Why is the y needed?

   A different y must be chosen for each signature ­   Otherwise, if you have two sets of a, b, c for the same x, y,    you can solve for the secrets x and y.

   El Gamal and DSA have  a = 1, b = Ym, c = Ys