What is DIffie Hellman Algorithm ?? Definition with example. Encryption and decryption. - Cyber security & Technology

## Diffie-Hellman Algorithm

·        Whitefield Diffie and Martin Hellman developed algorithm for key exchange in 1976.

·        Diffie-Hellman system was developed to solve the problem of key distribution for private key encryption systems.

·        The idea was to allow a secure method of agreeing on a private key without the expense of sending the key through another method. Therefore, they needed a secure way of deciding on a private key using the same method of communication that they were trying to protect.

·        Diffie-Hellman cannot be used to encrypt or decrypt information.

·        The Diffie-Hellman secret key exchange mechanism works as follows:

1.      A and B select two large number p and g. p is a prime number and g <p. These numbers are not secret. A or B can select them and pass onto the other party.

2.      A and B pick individually a random number. Let us say A picks r and B picks y. These numbers are secret.

3.      A calculates SA= gx mod p and sends this to B. Similarly B calculates SB= gY mod p and sends this to A.

4.      A and B now can independently calculate the common secret key K which is equal to :-

K=(SB)X mod p= (gY mod p)X mod p g mod p... at end A

K=(SA)y mod p= (gX mod p)y mod p= gXY mod p….. at end B

5.      Note that secret key K can be calculated only if x and y are known. These random numbers are never sent across by either party. A and B exchange SA and SB and an intruder cannot calculate x and y from SA and SB.

·        Example of Diffie-Hellman algorithm

If A and B choose p=47,  g= 3 and A pick a random number x= 8 and B picks a random number y= 10. The following calculations are done by A and B to get the secret key (K) using Diffie-Hellman key exchange algorithm :

A Calculates SA and sends it to B

SA= gX mod p= 38 mod 47= 28

B calculates SB and sends it to A

SB= gY mod p= 310 mod 47= 17

A then calculates key (K) as

K= 178 mod 47=4

B calculates key (K) as

K= 2810 mod 47= 4