Docsity

Diffie-Hellman-RSA - Introduction to Cryptography - Lecture Slides, Slides of Network security

Partial preview of the text

Download Diffie-Hellman-RSA - Introduction to Cryptography - Lecture Slides and more Slides Network security in PDF only on Docsity!

Diffie-Hellman-RSA

Topics

  • Diffie-Hellman algorithm
  • D-H advantages
  • D-H drawbacks
  • RSA algorithm
  • RSA benefits
  • RSA drawbacks

Diffie-Hellman Algorithm

  • D-H model requires the concept of finite field
  • Take Z (^) p , the natural numbers modulo p
  • Recall that (Z (^) p ,+) is a group
  • Recall that Z (^) p*^ denotes all positive numbers

modulo p and (Z p ,*) is also a group

  • (Z (^) p ,+,*) is a finite field

Diffie-Hellman Algorithm

  • Z (^) p*^ is a special group, known as a cyclic group
  • All elements of Zp*^ can be written as powers of a

single element g, called the primitive element of the group

  • E.g., In Z 7 *^ , take g = 3.

Using modulo 7 arithmetic: 31 = 3 3 2 = 2 3 3 = 6 34 = 4 3 5 = 5 3 6 = 1 Thus, g = 3 is a primitive element

Diffie-Hellman Algorithm

  • D-H model’s primary contribution:
    • Take a prime p and a primitive element g
    • Publicize both g and p
    • Alice chooses some x ∈ Z (^) p*^ and sends the value of gx^ to Bob
    • Bob chooses some y ∈ Z (^) p*^ and sends the value of g y^ to Alice
    • Eve can see both gx^ and gy^ but she cannot calculate x or y. This is the basis for D-H.

Diffie-Hellman Algorithm

  • In D-H model, Alice calculates the key

k = (gy^ ) x^ and Bob similarly calculates the same key k = (gx^ ) y

  • Since Eve does not know x or y, she cannot calculate the key k
  • Diffie and Hellman developed this method to share a key using some publicly available information
  • Diffie and Hellman did not develop the concept of private key

D-H Advantages

  • Any user can choose a random x and publish

g x^ in a public database such as a phone book

  • Phone book must be maintained by a TTP
  • Other users can look up the database and get

the public key for the individual and use it to

encrypt the message

  • Ideal for use with emails

D-H Drawbacks

  • Does not protect against man-in-the-middle attacks
  • Eve can intercept all traffic between Alice and Bob and generate separate keys for communication with them. In this scenario Eve originates the communications with Alice and Bob separately. It is lot of work but not too much of a problem.
  • If Alice sends an encrypted message for Bob with his public key, Eve simply forwards it.

D-H Drawbacks

  • If g is not a primitive element, then Eve can do

an exhaustive search to find the key k since g

would generate only a subgroup of Z p*

  • One solution for the above problem is to

choose the prime p as a safe prime,

i.e., p = 2 * q + 1 where q is a prime

  • E.g., 7 = 2 * 3 + 1. Thus, 7 is a safe prime.

D-H Drawbacks

  • Does safe primes solve the problem?
  • Answer: No
  • Reason: For any prime p, among the numbers

1, 2, 3, …, (p-1), exactly half are perfect

squares and others are not

  • E.g., Take p = 7. This gives us 1,2,3,4,5,

1 = 6 2 (mod 7) 2 = 3^2 (mod 7)

4 = 2^2 (mod 7)

D-H Drawbacks

  • Way to overcome the safe prime problem in

D-H model:

  • Choose prime p = 2 * q + 1 (q is a prime)
  • Choose a random m such that 2 ≦ m ≦(p-2) and g ≡ m 2 (mod p)
  • Verify that g ≠ 1 and g ≠ p – 1
  • The resulting triple (g, p, q) would suit D-H model

RSA Algorithm

  • Rivest-Shamir-Adleman, all at MIT in 1978
  • D-H method uses a one way function
  • RSA method uses a trapdoor one way function
  • Given n and e, it is easy to calculate

m e^ (mod n).

  • If factors of n are known then the reverse

calculation is easy. The trapdoor is the

difficulty of knowing the factors of n.

RSA Algorithm

  • Recommendation:
    • Choose ‘e’ as a prime number
    • Choose a prime with low ‘ hamming weight ,’ (i.e., there are only a few 1s in the binary representation of the number)
    • E.g., prime numbers 3, 17, and 65537 have only two 1s in their bit representation
  • 5 3 15 8 11 3 (15,3) (15,11) prime p prime q n=(pq) (p-1)(q-1) m = e (prime) Calc.‘d’ Private(n, d) Public(n, e) x ed-xm
  • 7 5 35 24 11 11 (35,11) (35,11)
  • 13 17 221 192 11 35 (221,35) (221,11)
  • 17 23 391 352 5 141 (391,141) (391,5)
  • 17 23 391 352 7 151 (391,151) (391,7)
  • 17 23 391 352 13 325 (391,325) (391,13)
  • 17 23 391 352 29 85 (391,85) (391,29)
  • 17 23 391 352 31 159 (391,159) (391,31)
  • 17 23 391 352 37 333 (391,333) (391,37)
  • 17 23 391 352 19 315 (391,315) (391,19)