EMZETT.
Login

Diffie-Hellman and forward secrecy

In short: Diffie-Hellman lets two parties agree on a shared secret key over an open network without ever transmitting it. Forward secrecy ensures that keys stolen later do not open old conversations.

In more detail: Each chooses a private secret, computes a public value from it and exchanges it. From their own secret and the other’s public value the same key arises, which eavesdroppers cannot compute because the discrete logarithm problem is considered hard.

In Depth

  • Modular variant: Public: prime p and base g. Alice sends g^a mod p, Bob g^b mod p, shared key g^(ab) mod p.
  • ECDH: The same on elliptic curves, with shorter keys (for example X25519).
  • Ephemeral: New key pairs for each session (DHE/ECDHE) = forward secrecy.
  • Man-in-the-middle: DH alone does not authenticate. Hence signatures/certificates are added.
  • Use: TLS, SSH, Signal protocol (double ratchet), WireGuard.
  • Quantum computers: Shor’s algorithm breaks DH/ECDH, hence post-quantum methods.

See also: TLS handshake in detail, Elliptic curves and digital signatures