0
3.1kviews
Diffie Hellman Key Exchange
1 Answer
0
66views

Key management: (Diffie Hellman key exchange)

  • It is an algorithm for generating a shared secret between two parties in such a way that the secret cant be seen by observing the communication.

enter image description here

Algorithm:

  1. A and B agree on a modulus p and base g which is a primitive root of modulus p.

  2. A chooses a private key say 'x' and B chooses a private key say 'y'. Both of them will not share these keys with anyone.

  3. Now A calculates his public key with the help of his private key which is given as

    $\hspace{1.5cm} A = g^{x} mod \ p$

  4. B calculates his public key with the help of his private key which is given as

    $\hspace{1.5cm} B = g^{y} mod \ p$

  5. A sends his public key to B and B sends his public key to A

  6. Now A calculates shared secret key as

    $\hspace{1.5cm} S_{A}=B^{x} mod \ p = g^{(y)x} mod \ p$

  7. B also calculates shared secret key as

    $\hspace{1.5cm} S_{B}=A^{y} mod \ p = g^{(x)y} mod \ p$

Thus $g^{(y)x} mod \ p = g^{(x)y} mod \ p = g^{xy} mod \ p$


Example 1:

Given p=23 and g=5,

The private key of A is 4 and the private key of B is 3

Calculate the shared secret key


Solution:

  1. A & B agree to use Modulus p=23 & base g=5

  2. A chooses a secret unit a=4 & sends it to B, i.e $A = g^x\ mod\ p=5^4\ mod\ 23=4 $

  3. B chooses a secret unit b=3 & sends it to A, i.e $B = g^y\ mod\ p=5^3\ mod\ 23=10 $

  4. A computes S (secret key) = $B^x\ mod\ p=10^4\ mod\ 23=18$

  5. B computes S (secret key) = $A^y\ mod\ p=4^3\ mod\ 23=18$

Now they share a secret no. 18

$A^x\ mod\ p=B^y\ mod\ p=g^{xy}\ mod\ p$

Example 2:

Given p=11 and g=2,

The private key of A is 9 and the private key of B is 3

Calculate the shared secret key


Solution:

  1. A & B agree to use Modulus p=11 & base g=2

  2. A chooses a secret unit a=9 & sends it to B, i.e $A = g^x\ mod\ p=2^9\ mod\ 11=6 $

  3. B chooses a secret unit b=3 & sends it to A, i.e $B = g^y\ mod\ p=2^3\ mod\ 11=8 $

  4. A computes S (secret key) = $B^x\ mod\ p=8^9\ mod\ 11=7$

  5. B computes S (secret key) = $A^y\ mod\ p=6^3\ mod\ 11=7$

Now they share a secret no. 7

Please log in to add an answer.