# What Is DH Parameters? Definition and Examples

> DH parameters are the prime modulus and generator that define a finite-field Diffie-Hellman group, which a TLS server needs in order to offer DHE cipher suites.

Source: https://ssl.sh/glossary/dh-parameters/
Last updated: 2026-11-10

DH parameters define the group used for finite-field [Diffie-Hellman](https://ssl.sh/glossary/diffie-hellman/): a large prime modulus p and a generator g. In TLS 1.2 the server chooses the group and sends p and g in its ServerKeyExchange message, so the parameters are part of server configuration, often loaded from a PEM file produced by `openssl dhparam`. TLS 1.3 removed arbitrary groups: finite-field DH is limited to the named groups ffdhe2048 through ffdhe8192 from RFC 7919.

## Why it matters
The [Logjam](https://ssl.sh/glossary/logjam/) attack in 2015 showed that 512-bit export-grade groups could be broken in real time and that 1024-bit groups shared by many servers were a realistic precomputation target; 2048 bits became the baseline. DH parameters matter only for DHE suites. They have no effect on [ECDHE](https://ssl.sh/glossary/ecdhe/), which uses named curves, and many current configurations do not enable DHE at all. In nginx, DHE suites are not used unless `ssl_dhparam` is set.

## Example
Generate 2048-bit parameters and load them in nginx:

```bash
openssl dhparam -out /etc/nginx/dhparam.pem 2048
```

```nginx
ssl_dhparam /etc/nginx/dhparam.pem;
```

Generation can take a while because the tool searches for a safe prime.

## Common misconceptions
- **"Every HTTPS server needs a dhparam file."** Only servers that offer DHE suites do. ECDHE-only and TLS 1.3 connections ignore it.
- **"Self-generated parameters are safer than standard groups."** The vetted RFC 7919 groups such as ffdhe2048 are fine; the Logjam lesson was about small group sizes.
- **"4096-bit parameters are always better."** Larger groups make every DHE handshake noticeably slower for little practical gain over 2048 bits.

## Related terms

- [Diffie-Hellman](https://ssl.sh/zh/glossary/diffie-hellman/): Diffie-Hellman 是 1976 年提出的密钥协商方法，让通信双方在公开信道上各自算出相同的共享秘密，而无需传输这个秘密本身。
- [ECDHE](https://ssl.sh/zh/glossary/ecdhe/): ECDHE 是椭圆曲线上的临时 Diffie-Hellman 密钥交换，TLS 双方每次握手都生成新的椭圆曲线密钥对，并据此协商出共享密钥。
- [Logjam](https://ssl.sh/zh/glossary/logjam/): Logjam 是 2015 年公布的攻击（CVE-2015-4000），可把 TLS 降级到 512 位出口级 Diffie-Hellman，并威胁使用过小或被大量共用 DH 参数的服务器。
- [密钥交换](https://ssl.sh/zh/glossary/key-exchange/): 密钥交换是 TLS 握手中客户端与服务器建立共享秘密的步骤，保护连接的对称密钥都由这个共享秘密派生而来。
- [前向保密](https://ssl.sh/zh/glossary/forward-secrecy/): 前向保密是密钥交换的一种安全属性：即使服务器的长期私钥日后泄露，过去连接的会话密钥也不会因此暴露。
- [OpenSSL](https://ssl.sh/zh/glossary/openssl/): OpenSSL 是开源密码学工具包，由 TLS 协议库 libssl、通用密码库 libcrypto 和 openssl 命令行工具组成。
