written 6.1 years ago by |
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.
Algorithm:
A and B agree on a modulus p and base g which is a primitive root of modulus p.
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.
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$
B calculates his public key with the help of his private key which is given as
$\hspace{1.5cm} B = g^{y} mod \ p$
A sends his public key to B and B sends his public key to A
Now A calculates shared secret key as
$\hspace{1.5cm} S_{A}=B^{x} mod \ p = g^{(y)x} mod \ p$
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:
A & B agree to use Modulus p=23 & base g=5
A chooses a secret unit a=4 & sends it to B, i.e $A = g^x\ mod\ p=5^4\ mod\ 23=4 $
B chooses a secret unit b=3 & sends it to A, i.e $B = g^y\ mod\ p=5^3\ mod\ 23=10 $
A computes S (secret key) = $B^x\ mod\ p=10^4\ mod\ 23=18$
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:
A & B agree to use Modulus p=11 & base g=2
A chooses a secret unit a=9 & sends it to B, i.e $A = g^x\ mod\ p=2^9\ mod\ 11=6 $
B chooses a secret unit b=3 & sends it to A, i.e $B = g^y\ mod\ p=2^3\ mod\ 11=8 $
A computes S (secret key) = $B^x\ mod\ p=8^9\ mod\ 11=7$
B computes S (secret key) = $A^y\ mod\ p=6^3\ mod\ 11=7$
Now they share a secret no. 7