Diffie Hellman

DH-Key Exchange

[Image of Alice and Bob]

Alice and Bob want to communicate securely. They use DH-Key Exchange to establish a shared secret.

  1. Alice selects a private value, , and computes her public value, .
  2. Bob selects a private value, , and computes his public value, .
  3. Alice sends her public value to Bob.
  4. Bob sends his public value to Alice.
  5. Alice computes the shared secret, .
  6. Bob computes the shared secret, .
  7. Alice and Bob can now use the shared secret to encrypt their communications.
1
2
3
4
5
6
7
8
9
10
g: 2
p: 13
a: 5
PKa: g^a = 32
b: 8
PKb: g^b = 256

Sa: (PKb ^ a) mod p = (g^b = 256) ^ 5 % 13 = 3
Sb: (PKa ^ b) mod p = 32 ^ 8 % 13 = 3
S: (2^8)^5 % 13 = 3