- 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:
- If A wants to communicate with B, they first must agree on two large prime numbers p and q (q < p).
- A selects another secret large random integer number XA, and calculate YA such that
- A sends this YA to B.
- B independently selects another secret large random integer number XB, and calculate YB such that,
- B sends this number YB to A.
- Now, A is calculating his secret key by using,
- Similarly, B calculates his secret key YK by using,
- If AK = BK, then A and B can agree for future communication called as key agreement algorithm.
YA = qXAmod p
YB = qXBmod p
AK = (YB)XAmod p
BK = (YA)XBmod p
Fig. Diffie-Hellman Key exchange algorithm