Skip to main content

Short note: Diffie-Hellman

Short answer

Diffie-Hellman enables two parties to establish a shared secret over an insecure channel without prior meeting. They agree on a large prime p and generator g, exchange public values g^a mod p and g^b mod p, then compute the shared key g^ab mod p. Security depends on the discrete logarithm problem. It lacks authentication and is vulnerable to man-in-the-middle attacks unless combined with digital signatures or certificates.

Write a short note on Diffie Hellman's algorithm.

The Diffie-Hellman (DH) algorithm (1976) lets two parties agree on a shared secret key over an insecure channel without having met before. It is a key-exchange method, not an encryption method. Its security depends on the difficulty of the discrete logarithm problem.

Steps

  1. Alice and Bob publicly agree on a large prime p and a generator (primitive root) g.
  2. Alice chooses a secret a and sends A = gᵃ mod p. Bob chooses a secret b and sends B = gᵇ mod p.
  3. Alice computes K = Bᵃ mod p; Bob computes K = Aᵇ mod p.
  4. Both get the same K = gᵃᵇ mod p, used as the symmetric session key.

Example

p = 23, g = 5, Alice's secret a = 6, Bob's secret b = 15.

StepAliceBob
Public valueA = 5⁶ mod 23 = 8B = 5¹⁵ mod 23 = 19
Exchangesends 8sends 19
Shared key19⁶ mod 23 = 28¹⁵ mod 23 = 2

Shared key K = 2. An eavesdropper sees p, g, 8 and 19, but cannot easily find a or b for large p.

Weakness

It does not authenticate the parties, so it is open to a man-in-the-middle attack; digital signatures or certificates are used to prevent it. It is used in IPsec (IKE) and SSL/TLS.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Networks and Security chapter 8 questions →