Diffie-Hellman Key Exchange Algorithm

 


  • The Diffie-Hellman algorithm is widely known as key exchange algorithm or key agreement algorithm developed by Whitfield Diffie and Martin Hellman in 1976. Diffie-Hellman is used to generate same (symmetric) private cryptographic key at sender as well as a receiver and so that there is no need to transfer this key from sender to receiver.
  • Remember that Diffie-Hellman algorithm is used only for a key agreement, not for encryption or decryption of the message. If sender and receiver want to communicate with each other they first agree on the same key generated by a Diffie-Hellman algorithm, later on, they can use this key for encryption or decryption.
Steps for Diffie-Hellman Algorithm:
  1. If A wants to communicate with B, they first must agree on two large prime numbers p and q (q < p).
  2. A selects another secret large random integer number XA, and calculate YA such that 
  3. YA = qXAmod p
  4. A sends this YA to B.
  5. B independently selects another secret large random integer number XB, and calculate YB such that,
  6. YB = qXBmod p
  7. B sends this number YB to A.
  8. Now, A is calculating his secret key by using,
  9. AK = (YB)XAmod p
  10. Similarly, B calculates his secret key YK by using,
  11. BK = (YA)XBmod p
  12. If AK = BK, then A and B can agree for future communication called as key agreement algorithm.
Fig. Diffie-Hellman Key exchange algorithm