Course contentsShow
← Security
Lesson 155 of 3,0524. Asymmetric Cryptography and PKIFree lesson

Diffie-Hellman Parameter Selection and Groups

Choosing safe primes, generator values, and standardized groups for secure key exchange implementations.

Diffie-Hellman Parameter Selection and Groups

What you'll learn: How to choose the right mathematical parameters and standardized groups to make Diffie-Hellman key exchange actually secure in practice.

Why Parameters Matter

You already know that Diffie-Hellman relies on the discrete logarithm problem to keep shared secrets safe. But not just any numbers will do—choosing the wrong parameters is like building a vault with cardboard walls. The security of your entire key exchange depends on selecting strong mathematical values.

The Three Critical Parameters

Prime Number (p)

This is your modulus—the number that defines your arithmetic universe. It must be a safe prime: a prime where (p-1)/2 is also prime. Think of it as choosing a lock that's fundamentally difficult to pick. Weak primes can be attacked using specialized algorithms that exploit mathematical structure.

Typical sizes: 2048 bits minimum, 3072+ bits recommended today.

Generator (g)

This base value generates the public keys. While g=2 often works, what matters is that it generates a large subgroup—you want many possible values to choose from, making prediction impossible. A poor generator shrinks your keyspace, like having a combination lock with only three digits instead of ten.

Group Order

The size of the subgroup generated by g. Larger order = harder discrete logarithm problem = stronger security.

Standardized Groups Save Lives

Don't generate your own parameters! Organizations like NIST and IETF publish standardized groups (like RFC 3526's MODP groups) that have been thoroughly vetted by cryptographers. Using these pre-approved parameters prevents implementation mistakes and ensures interoperability.

Key Takeaway: Diffie-Hellman security requires carefully chosen safe primes, appropriate generators, and large group orders—always use standardized, well-tested parameter groups rather than generating your own.