Diffie-Hellman Key Exchange
Diffie-Hellman Key Agreement Protocol · Also known as: DH Key Exchange, Diffie-Hellman Key Agreement
The Diffie-Hellman key exchange, invented by Whitfield Diffie and Martin Hellman in 1976, is a foundational protocol for establishing a shared secret over an insecure communication channel. Two parties who have never previously communicated can use Diffie-Hellman to agree on a symmetric encryption key that an eavesdropper cannot easily derive, even after observing all public exchanges.
Read the full method
Sign in with a free account to read this section.
Method map
The neighbourhood of related methods — select a node to explore.
When to use it
Use Diffie-Hellman (or elliptic curve variants like ECDH) as the key agreement component in protocols that need to establish symmetric encryption keys over untrusted channels. It is essential in TLS/SSL, IPsec, and secure messaging systems. Modern applications prefer elliptic curve variants (ECDH) because they offer equivalent security with smaller key sizes. Diffie-Hellman protects against passive eavesdropping but not active man-in-the-middle attacks; combine with authentication (e.g., digital signatures or certificates) to prevent impersonation.
Strengths & limitations
- Enables two parties to establish a shared secret without prior communication or secure channels
- Resists passive eavesdropping; an observer cannot derive the shared secret from public values alone
- Mathematically well-founded on discrete logarithm hardness, with no known efficient algorithm
- Flexible: can be combined with authentication methods to prevent man-in-the-middle attacks
- Vulnerable to man-in-the-middle attacks if not authenticated; requires additional signatures or certificates
- Large key sizes (2048–4096 bits) are needed for modern security, making it slower than alternatives
- Does not provide forward secrecy by itself; ephemeral variants (DHE) are needed
- Computation cost is higher than elliptic curve alternatives offering equivalent security
Frequently asked
If I see A and B on the wire, why can't I compute the shared secret?
To compute the shared secret from A and B alone, you would need to find either a such that g^a ≡ A (mod p) or b such that g^b ≡ B (mod p). This is the discrete logarithm problem. For large primes and well-chosen generators, no efficient algorithm is known, making it computationally infeasible to solve.
What is a man-in-the-middle attack on Diffie-Hellman?
An attacker intercepts and modifies the public values exchanged. The attacker can pose as Alice to Bob (establishing a shared secret with Bob) and as Bob to Alice (establishing a separate shared secret with Alice). The attacker then decrypts and re-encrypts all messages, undetected unless authentication is present.
Why do modern systems prefer elliptic curve DH (ECDH) over DH?
ECDH offers equivalent security with significantly smaller key sizes (256-bit ECDH is roughly as secure as 2048-bit DH). Smaller keys reduce computational cost, bandwidth, and storage. Both are secure against current and foreseeable classical algorithms, though quantum computers would break both.
What is ephemeral Diffie-Hellman (DHE) and why is it important?
DHE generates a new Diffie-Hellman key pair for each session instead of reusing the same pair. If a long-term private key is ever compromised, DHE ensures that past session keys remain secure—a property called forward secrecy. TLS 1.3 uses ephemeral ECDH by default.
Sources
- Diffie, W., & Hellman, M. E. (1976). New directions in cryptography. IEEE Transactions on Information Theory, 22(6), 644–654. DOI: 10.1109/TIT.1976.1055638 ↗
- Menezes, A. J., van Oorschot, P. C., & Vanstone, S. A. (1997). Handbook of Applied Cryptography. CRC Press. link ↗
- Boyd, C., & Mathuria, A. (2003). Protocols for Authentication and Key Establishment. Springer-Verlag. DOI: 10.1007/978-3-662-09527-0 ↗
How to cite this page
ScholarGate. (2026, June 3). Diffie-Hellman Key Agreement Protocol. ScholarGate. https://scholargate.app/en/cryptography/diffie-hellman-key-exchange
Which method?
Set this method beside its closest kin and read them side by side — the library lays the books on the table; the choice is yours.
- Digital Signature SchemeCryptography↔ compare
- RSA Cryptosystem AnalysisCryptography↔ compare
- Symmetric Key CryptanalysisCryptography↔ compare
- TLS Protocol AnalysisCryptography↔ compare