Finite-field Diffie-Hellman (DH / DHE)
The original Diffie-Hellman key agreement over large prime fields, still found in TLS 1.2 DHE suites, IPsec/IKE and older VPNs.
Why it's at risk
Shor's algorithm solves discrete logarithms in finite fields efficiently, so recorded DH handshakes can be decrypted later. Groups below 2048 bits are also weak classically (the Logjam attack showed 512-bit export groups could be broken in practice, and 1024-bit groups are within reach of nation-state attackers).
Move to
- BestX25519MLKEM768The hybrid TLS 1.3 key exchange combining X25519 with ML-KEM-768 (IANA group 0x11EC), on by default in Chrome, Firefox, Safari, Cloudflare, OpenSSL 3.5+, Go 1.24+ and more.
- OrML-KEM-768The default post-quantum key encapsulation mechanism (formerly Kyber), NIST Security Category 3: 1184-byte encapsulation key, 1088-byte ciphertext, 32-byte shared secret.
- OrSecP256r1MLKEM768The hybrid TLS 1.3 key exchange combining NIST P-256 ECDH with ML-KEM-768 (IANA group 0x11EB), preferred where every component must be FIPS-approved.
- Used for
- Key exchange
- Family
- Finite field (discrete logarithm)
- Classical security
- 112 bits
- Against a quantum computer
- Broken
- Standards
- NIST SP 800-56A Rev. 3, RFC 7919, RFC 3526, NIST IR 8547
Migration guides
Concrete code changes to move off Finite-field Diffie-Hellman (DH / DHE). Pick your stack.
OpenSSL 3.5+ (libssl) · cC/C++ with OpenSSL 3.5+: hybrid post-quantum TLS groups, no oqs-provider neededProduction-ready
Why
OpenSSL 3.5 (April 2025, a long-term-support release) added native ML-KEM, ML-DSA and SLH-DSA plus the hybrid TLS groups X25519MLKEM768, SecP256r1MLKEM768 and SecP384r1MLKEM1024. Its default group list prefers the hybrid and its default client key shares are X25519MLKEM768 and X25519:
?*X25519MLKEM768 / ?*X25519:?secp256r1 / ?X448:?secp384r1:?secp521r1 / ?ffdhe2048:?ffdhe3072So any program linked against OpenSSL 3.5+ that does not override the groups is already post-quantum for key exchange. You no longer need the Open Quantum Safe oqs-provider for ML-KEM in TLS; remove it unless you need non-NIST algorithms, and note that its pre-standard Kyber group code points are obsolete.
Steps
- Check the library your binary actually loads:
openssl version -a,ldd ./app | grep -E 'ssl|crypto', orOpenSSL_version(OPENSSL_VERSION)at runtime. - Search the code for
SSL_CTX_set1_groups_list,SSL_CTX_set1_curves_list,SSL_set1_groups*,SSL_CTX_set_ecdh_auto, and config files withGroups =/Curves =. - Either remove the override or put the hybrid first. OpenSSL 3.5's syntax also lets you extend the defaults with
DEFAULT. - Keep TLS 1.3 enabled (
SSL_CTX_set_max_proto_version(ctx, 0)orTLS1_3_VERSION).
Before
SSL_CTX *ctx = SSL_CTX_new(TLS_server_method());
SSL_CTX_set1_groups_list(ctx, "P-256:P-384"); /* classical only */
SSL_CTX_set_max_proto_version(ctx, TLS1_2_VERSION); /* no TLS 1.3 = no hybrid */After
SSL_CTX *ctx = SSL_CTX_new(TLS_server_method());
SSL_CTX_set_min_proto_version(ctx, TLS1_2_VERSION);
/* Option A: don't call set1_groups at all (OpenSSL 3.5+ defaults prefer X25519MLKEM768). */
/* Option B: explicit list, hybrid first. */
if (SSL_CTX_set1_groups_list(ctx, "X25519MLKEM768:X25519:SecP256r1MLKEM768:P-256:P-384") != 1) {
/* Fails on OpenSSL < 3.5, which doesn't know the hybrid names. */
ERR_print_errors_fp(stderr);
}System-wide, in openssl.cnf:
openssl_conf = openssl_init
[openssl_init]
ssl_conf = ssl_sect
[ssl_sect]
system_default = system_default_sect
[system_default_sect]
Groups = X25519MLKEM768:X25519:SecP256r1MLKEM768:P-256:P-384Gotchas
- ClientHello size and middleboxes. The hybrid key share makes the ClientHello larger than one typical TCP segment. The OpenSSL manual notes rare failures or timeouts from firewall software; it suggests prepending
?X25519MLKEM768:without a*so the hybrid is offered only after a HelloRetryRequest, if a specific client population has this problem. - Distribution OpenSSL versions. Many LTS distributions still ship OpenSSL 3.0 or 3.2; statically linking or vendoring 3.5+ may be necessary.
- FIPS provider. Whether ML-KEM is available inside a FIPS-validated provider depends on the validated module version you deploy.
- Pure ML-KEM groups (MLKEM768, MLKEM1024) also exist; use them only if policy requires non-hybrid (for example CNSA 2.0 profiles use ML-KEM-1024).
Verify
echo | openssl s_client -connect localhost:443 2>/dev/null | grep "Negotiated TLS1.3 group"
# Negotiated TLS1.3 group: X25519MLKEM768
openssl list -tls-groups # shows which groups your OpenSSL knows (3.5+)Go crypto/tls · goGo: hybrid post-quantum TLS is on by default since Go 1.24, unless CurvePreferences turns it offProduction-ready
Why
Go's crypto/tls enables the hybrid X25519MLKEM768 key exchange by default since Go 1.24 (when Config.CurvePreferences is nil). Go 1.26 additionally enabled SecP256r1MLKEM768 and SecP384r1MLKEM1024 by default. Go 1.27 added opt-in pure MLKEM1024. That covers clients and servers, and everything built on crypto/tls: net/http, gRPC-Go, Caddy, Traefik and many more.
The most common reason a Go service is not post-quantum is an explicit CurvePreferences list copied from an old hardening guide: any non-nil list replaces the defaults, and if it does not name a hybrid, the hybrid is gone.
Steps
- Build with Go 1.24 or later (
go version; also check thego/toolchainlines ingo.modand your CI/Docker images). - Search for
CurvePreferencesandGODEBUG=tlsmlkem=0/tlssecpmlkem=0(in code,go.modgodebuglines,//go:debugdirectives, environment variables). - Prefer deleting
CurvePreferences. If policy requires an explicit list, include the hybrids. - Make sure TLS 1.3 is allowed (
MaxVersionunset ortls.VersionTLS13).
Before
cfg := &tls.Config{
MinVersion: tls.VersionTLS12,
CurvePreferences: []tls.CurveID{tls.CurveP256, tls.X25519}, // replaces the defaults: no post-quantum
}After
// Option A (recommended): leave CurvePreferences nil and get Go's defaults,
// which include X25519MLKEM768 (Go 1.24+) and the P-256/P-384 hybrids (Go 1.26+).
cfg := &tls.Config{MinVersion: tls.VersionTLS12}
// Option B: an explicit list must name the hybrids.
cfg = &tls.Config{
MinVersion: tls.VersionTLS12,
CurvePreferences: []tls.CurveID{
tls.X25519MLKEM768,
tls.SecP256r1MLKEM768, // Go 1.26+
tls.X25519,
tls.CurveP256,
},
}Since Go 1.24 the order of CurvePreferences is ignored (crypto/tls picks the order itself); only membership matters.
Gotchas
- GODEBUG switches.
tlsmlkem=0removes X25519MLKEM768 from the default set andtlssecpmlkem=0removes the P-256/P-384 hybrids. They exist as escape hatches for broken peers; check you have not inherited them. (Since Go 1.27 they no longer override an explicitCurvePreferences.) - Large ClientHello. Clients now send a ~1.2 KB key share. Go 1.24's release notes mention servers that mishandle large records and time out; if a specific peer breaks, fix the peer or scope the workaround to that one client config.
- FIPS 140-3 mode (
GOFIPS140): preferSecP256r1MLKEM768where every component must be approved. - Certificates are unaffected: hybrid key exchange works with your existing RSA/ECDSA certificates.
- Reverse proxies in front of Go services decide the client-facing handshake.
Verify
conn, err := tls.Dial("tcp", "example.com:443", &tls.Config{})
if err != nil { log.Fatal(err) }
state := conn.ConnectionState()
fmt.Println(state.CurveID) // X25519MLKEM768 (ConnectionState.CurveID was added in Go 1.25)Or from a shell: echo | openssl s_client -connect host:443 2>/dev/null | grep "Negotiated TLS1.3 group", or npx -y pqe-cli check host.
JDK (java.security / javax.crypto), JDK 24+ · javaJava: ML-KEM and ML-DSA in the JDK (JEP 496 / JEP 497, JDK 24+, LTS in JDK 25)Production-ready
Why
Since JDK 24, the JDK's built-in providers implement ML-KEM (JEP 496, FIPS 203) through the javax.crypto.KEM API and ML-DSA (JEP 497, FIPS 204) through the familiar KeyPairGenerator / Signature APIs. JDK 25 is the first long-term-support release that includes them, so most teams can adopt them without third-party libraries.
Steps
- Run on JDK 25 (LTS) or later. On JDK 21 or older, use Bouncy Castle (see that guide).
- Replace RSA-OAEP key wrapping / ECDH with ML-KEM-768 via
KEM. - Replace
SHA256withECDSA/Ed25519/SHA256withRSAsignatures withML-DSAwhere verifiers can be upgraded. Keep an algorithm identifier next to stored signatures.
Before
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(2048);
KeyPair kp = kpg.generateKeyPair();
Cipher oaep = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");
oaep.init(Cipher.WRAP_MODE, kp.getPublic());
byte[] wrapped = oaep.wrap(dataKey);
Signature s = Signature.getInstance("SHA256withECDSA");After: ML-KEM-768
import java.security.*;
import java.security.spec.NamedParameterSpec;
import javax.crypto.KEM;
import javax.crypto.SecretKey;
KeyPairGenerator g = KeyPairGenerator.getInstance("ML-KEM");
g.initialize(NamedParameterSpec.ML_KEM_768);
KeyPair kp = g.generateKeyPair(); // or KeyPairGenerator.getInstance("ML-KEM-768")
KEM kem = KEM.getInstance("ML-KEM");
// Sender
KEM.Encapsulator enc = kem.newEncapsulator(kp.getPublic());
KEM.Encapsulated e = enc.encapsulate();
SecretKey senderKey = e.key(); // 32-byte shared secret
byte[] ciphertext = e.encapsulation(); // 1088 bytes, send to the receiver
// Receiver
KEM.Decapsulator dec = kem.newDecapsulator(kp.getPrivate());
SecretKey receiverKey = dec.decapsulate(ciphertext);
// Derive an AES-256-GCM key from the secret (for example with HKDF; JDK 25 adds javax.crypto.KDF).After: ML-DSA-65
KeyPairGenerator g = KeyPairGenerator.getInstance("ML-DSA-65");
KeyPair kp = g.generateKeyPair();
Signature signer = Signature.getInstance("ML-DSA");
signer.initSign(kp.getPrivate());
signer.update(message);
byte[] sig = signer.sign(); // 3309 bytes
Signature verifier = Signature.getInstance("ML-DSA");
verifier.initVerify(kp.getPublic());
verifier.update(message);
boolean ok = verifier.verify(sig);Gotchas
- TLS is separate. These APIs do not change JSSE. Hybrid post-quantum TLS arrived in JDK 27 (JEP 527); see the Java TLS guide.
- Keystores and HSMs. PKCS#12 keystores can hold the keys, but PKCS#11 HSMs need vendor support for ML-KEM/ML-DSA mechanisms. Check before moving production signing keys.
- Sizes. ML-KEM-768 ciphertext 1,088 B, public key 1,184 B; ML-DSA-65 signature 3,309 B, public key 1,952 B. Check
VARBINARYcolumns and message formats. - Encoded keys.
getEncoded()returns X.509 SubjectPublicKeyInfo / PKCS#8 encodings using the NIST OIDs; check interoperability with other stacks (OpenSSL 3.5+, Go, .NET). - Do not confuse with pre-standard Kyber/Dilithium classes from older Bouncy Castle versions.
Verify
assert java.util.Arrays.equals(senderKey.getEncoded(), receiverKey.getEncoded());
assert ciphertext.length == 1088 && sig.length == 3309;JSSE (SunJSSE), JDK 27+ · javaJava: hybrid post-quantum TLS in JSSE (JEP 527, JDK 27+)Production-ready
Why
JEP 527 added the hybrid TLS 1.3 groups X25519MLKEM768, SecP256r1MLKEM768 and SecP384r1MLKEM1024 to the SunJSSE provider in JDK 27 (released September 2026). X25519MLKEM768 is placed first in the default named-groups list, and clients send two key shares by default (X25519MLKEM768 and x25519). Applications using javax.net.ssl (HttpClient, HttpsURLConnection, Tomcat/Jetty/Netty on JSSE) get it without code changes.
JDK 21 and JDK 25 (the current LTS releases) do not include these groups in SunJSSE; OpenJDK maintainers said new features like this go into a feature release first, so check your vendor's release notes rather than assuming a backport.
Steps
- Pick a route:
- Upgrade the services that terminate or originate TLS to JDK 27+, or wait for an LTS release that includes JEP 527.
- Terminate TLS in front of Java (nginx/Envoy/cloud load balancer with OpenSSL 3.5+, BoringSSL or AWS-LC) and keep the JVM on an LTS.
- Use a different TLS provider that supports the hybrids (for example a native OpenSSL-based engine such as netty-tcnative built against a PQ-capable library). Check that provider's documentation for current support.
- Remove any
jdk.tls.namedGroupssetting that lists only classical groups, or add the hybrid first. - Make sure TLS 1.3 is enabled (
jdk.tls.client.protocols,SSLParameters.setProtocols).
Before
# Classical-only list: disables post-quantum even on JDK 27+
java -Djdk.tls.namedGroups="secp256r1,x25519" -jar app.jarAfter
# JDK 27+: simplest is to remove the property and use the defaults.
java -jar app.jar
# Or list the hybrid explicitly, first:
java -Djdk.tls.namedGroups="X25519MLKEM768,x25519,secp256r1,secp384r1" -jar app.jarPer connection, SSLParameters.setNamedGroups(...) (JDK 20+) can set the same list programmatically.
Gotchas
- ClientHello size grows by about 1.2 KB; middleboxes that mishandle multi-packet ClientHellos may break. Test through the real path.
- FIPS deployments usually prefer
SecP256r1MLKEM768. - Third-party providers (Bouncy Castle JSSE, Conscrypt, Amazon Corretto Crypto Provider) have their own support timelines; verify, don't assume.
- Certificates keep working: this only changes key exchange.
Verify
echo | openssl s_client -connect your-java-service:443 2>/dev/null | grep "Negotiated TLS1.3 group"
# Negotiated TLS1.3 group: X25519MLKEM768
# JSSE debug logging also shows the negotiated group:
java -Djavax.net.debug=ssl:handshake -jar app.jarnode:tls / node:https · javascriptNode.js: get hybrid post-quantum TLS (X25519MLKEM768) by upgrading Node and not pinning curvesProduction-ready
Why
TLS key exchange is the part of your stack that "harvest now, decrypt later" attacks target: anyone who records your traffic today can decrypt it once a large quantum computer exists, unless the handshake used a post-quantum key exchange. The fix in TLS 1.3 is the hybrid group X25519MLKEM768 (X25519 plus ML-KEM-768, RFC 10024).
Node.js gets it from its bundled OpenSSL. OpenSSL 3.5 and later offer and prefer X25519MLKEM768 by default, so on a recent Node it is usually already on, unless your code pins ecdhCurve.
| Node.js line | Bundled OpenSSL | Hybrid PQ TLS by default |
|---|---|---|
| 26.x | 3.5.x | Yes |
| 24.x from 24.5.0 | 3.5.x | Yes |
| 22.x from 22.20.0 | 3.5.x | Yes |
| 20.x (end of life April 2026) | 3.0.x | No: OpenSSL 3.0 has no ML-KEM |
Distribution packages and custom builds that link a system OpenSSL follow the system library instead, so check rather than assume.
Steps
-
Check what you run in each environment (dev, CI, containers, serverless):
bash node -p "process.versions.node + ' / OpenSSL ' + process.versions.openssl" # want OpenSSL 3.5.0 or later -
Upgrade to Node 24.5+ / 22.20+ / 26, and update base images (
node:22,node:24and so on). -
Search for code that pins key-exchange groups (
ecdhCurve,tls.DEFAULT_ECDH_CURVE,--tls-ecdh-curve-style config) and either remove it or put the hybrid first. -
Keep TLS 1.3 enabled. Hybrid groups exist only in TLS 1.3, so a server forced to TLS 1.2 (
maxVersion: 'TLSv1.2') can never negotiate them.
Before
import https from 'node:https';
// Pinning classical curves silently disables the post-quantum hybrid.
const server = https.createServer(
{ key, cert, ecdhCurve: 'P-256:P-384', maxVersion: 'TLSv1.2' },
app,
);After
import https from 'node:https';
const server = https.createServer(
{
key,
cert,
minVersion: 'TLSv1.2',
// Option A (recommended): omit ecdhCurve. The default 'auto' uses OpenSSL's
// defaults, which prefer X25519MLKEM768 on OpenSSL 3.5+.
// Option B: list groups explicitly, hybrid first.
ecdhCurve: 'X25519MLKEM768:X25519:P-256:P-384',
},
app,
);The same applies to clients (https.request, tls.connect, undici/fetch agents): with default options on Node 24.5+/22.20+ they offer X25519MLKEM768 to servers.
Gotchas
- Unknown group name on old OpenSSL. On a Node built against OpenSSL older than 3.5, the string
X25519MLKEM768is unknown and creating the secure context throws. Prefer Option A (omitecdhCurve) if one codebase must run on several Node versions. - Bigger ClientHello. By default the client sends a 1,216-byte X25519MLKEM768 key share alongside the 32-byte X25519 one, so the ClientHello usually spans two TCP packets. Some old middleboxes, firewalls and load balancers mishandle that and the handshake stalls. Test through your real network path.
- FIPS mode. If you need every component FIPS-approved, prefer
SecP256r1MLKEM768:X25519MLKEM768:...(both are offered by OpenSSL 3.5). - Terminating proxies. If TLS ends at a load balancer, CDN or ingress controller, that component decides; see the nginx, Caddy, Cloudflare and AWS ALB guides.
- Certificates are a separate problem. Hybrid key exchange protects confidentiality now. Your RSA/ECDSA certificate still authenticates the server, which is fine until a quantum computer exists, and is migrated later.
Verify
# OpenSSL 3.5+ client: prints the negotiated group
echo | openssl s_client -connect your-host:443 2>/dev/null | grep "Negotiated TLS1.3 group"
# Negotiated TLS1.3 group: X25519MLKEM768
# Or use pqe's checker
npx -y pqe-cli check your-host.exampleany (OpenSSL, node:crypto, cryptography, JCA, Go) · otherRSA keys under 2048 bits (and DSA, small DH groups): replace them nowProduction-ready
Why
RSA-1024 gives about 80 bits of security and NIST disallowed it for signatures and key establishment back in 2013. 512-bit keys are factored routinely; 1024-bit keys are assumed breakable by well-resourced attackers. DSA is no longer approved for signing in FIPS 186-5, and Diffie-Hellman groups under 2048 bits are weak (Logjam). These are classical failures: fix them now, without waiting for post-quantum tooling.
Where to go:
- Key exchange / encryption: hybrid X25519MLKEM768 in TLS, ML-KEM-768 at the application level.
- Signatures: ML-DSA-65 where your stack supports it.
- If PQ isn't available yet in a given system: RSA-3072 (128-bit classical) or ECDSA P-256 / Ed25519 as a stopgap, accepting a second migration later.
Before
openssl genrsa -out key.pem 1024
ssh-keygen -t rsa -b 1024
ssh-keygen -t dsacrypto.generateKeyPairSync('rsa', { modulusLength: 1024 });rsa.generate_private_key(public_exponent=65537, key_size=1024)After
# Post-quantum where supported (OpenSSL 3.5+)
openssl genpkey -algorithm ML-DSA-65 -out sign.key
openssl genpkey -algorithm ML-KEM-768 -out kem.key
# Classical stopgap
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:3072 -out key.pem
ssh-keygen -t ed25519crypto.generateKeyPairSync('ml-dsa-65'); // Node 24.6+
crypto.generateKeyPairSync('rsa', { modulusLength: 3072 }); // stopgapfrom cryptography.hazmat.primitives.asymmetric.mldsa import MLDSA65PrivateKey
MLDSA65PrivateKey.generate() # cryptography 48+Gotchas
- Find them all: keys in repositories, HSMs, certificates (
openssl x509 -noout -text | grep "Public-Key"), SSHauthorized_keys, and embedded devices.npx -y pqe-cli scan .reports small RSA keys in code and PEM files. - Rotate, don't just regenerate: issue new keys, distribute public keys, re-sign/re-encrypt what depends on the old ones, then revoke.
- Data encrypted under small RSA keys should be treated as potentially exposed; re-encrypt and consider whether it was already captured.
- Legacy peers that only speak RSA-1024 or DSA are themselves a risk; isolate or replace them.
Verify
openssl pkey -in key.pem -noout -text | head -1 shows the algorithm and size; rerun npx -y pqe-cli scan . to confirm no rsa-1024/dsa findings remain.
ssl (stdlib) / OpenSSL 3.5 · pythonPython: hybrid post-quantum TLS comes from the OpenSSL your Python links againstProduction-ready
Why
Python's ssl module (and everything built on it: requests, urllib3, httpx, aiohttp, asyncio servers, Gunicorn/Uvicorn with TLS) uses the OpenSSL library Python was built against. OpenSSL 3.5 and later offer and prefer the hybrid post-quantum group X25519MLKEM768 by default. So the migration is mostly an environment change: run Python on an OpenSSL 3.5+ build and do not pin the key-exchange groups.
Steps
-
Check every environment (laptops, CI images, containers, Lambda/Cloud Run runtimes):
bash python3 -c "import ssl; print(ssl.OPENSSL_VERSION)" # want: OpenSSL 3.5.0 or later -
If it is older (OpenSSL 3.0 is still common on older LTS distributions such as Debian 12 and Ubuntu 22.04/24.04), upgrade the base image/OS to one that ships OpenSSL 3.5+, or use a Python build that bundles a newer OpenSSL. Rebuild virtualenvs afterwards.
-
Remove code that narrows the groups, for example
ctx.set_ecdh_curve("prime256v1"), unless you have a specific need. Leaving OpenSSL's defaults in place is what enables the hybrid. -
Keep TLS 1.3 allowed (
ctx.maximum_versionunset orTLSVersion.TLSv1_3). Hybrid groups exist only in TLS 1.3. -
Systems-wide policy: on Linux distributions with crypto-policies or an
openssl.cnfGroupssetting, make sure the configured list includesX25519MLKEM768.
Before
import ssl
ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ctx.load_cert_chain("cert.pem", "key.pem")
ctx.maximum_version = ssl.TLSVersion.TLSv1_2 # blocks TLS 1.3, so no hybrid
ctx.set_ecdh_curve("prime256v1") # pins a classical curveAfter
import ssl
assert ssl.OPENSSL_VERSION_INFO >= (3, 5, 0), ssl.OPENSSL_VERSION # fail fast in CI
ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ctx.load_cert_chain("cert.pem", "key.pem")
ctx.minimum_version = ssl.TLSVersion.TLSv1_2
# No maximum_version and no set_ecdh_curve(): OpenSSL 3.5+ defaults prefer X25519MLKEM768.Gotchas
ssl.OPENSSL_VERSIONis about the linked library, not aboutpip install cryptography(which bundles its own OpenSSL and does not affectssl).- Bigger ClientHello: ~1.2 KB more key share data, so it spans two packets. Old middleboxes occasionally drop such handshakes; test through your real network path.
- Reverse proxies decide. If nginx, a cloud load balancer or a CDN terminates TLS in front of your Python app, configure it there (see those guides).
- LibreSSL builds (some macOS system Pythons) follow LibreSSL's own support, not OpenSSL's; check before assuming.
Verify
echo | openssl s_client -connect your-host:443 2>/dev/null | grep "Negotiated TLS1.3 group"
# Negotiated TLS1.3 group: X25519MLKEM768
npx -y pqe-cli check your-host.examplerustls (aws-lc-rs provider) · rustRust: hybrid post-quantum TLS with rustls's default aws-lc-rs providerProduction-ready
Why
rustls supports the hybrid X25519MLKEM768 key exchange through its aws-lc-rs crypto provider. In current rustls 0.23.x the crate's default features are aws_lc_rs, prefer-post-quantum, logging, std and tls12, so a plain rustls = "0.23" dependency offers and prefers X25519MLKEM768 (Cloudflare's tracker lists it as on by default since 0.23.27). Projects that switched to the ring provider, disabled default features, or pinned an old 0.23 release usually do not get it.
Steps
- Update:
cargo update -p rustlsand checkcargo tree -i rustls -e features. - Make sure the
aws_lc_rsprovider is in use andprefer-post-quantumis enabled (both are defaults). If you buildClientConfig/ServerConfigwith an explicit provider, userustls::crypto::aws_lc_rs::default_provider(). - Check higher-level crates (reqwest, hyper-rustls, tokio-rustls, tonic) for feature flags that choose
ringinstead.
Before
[dependencies]
rustls = { version = "0.23", default-features = false, features = ["ring", "std", "tls12"] }After
[dependencies]
# Default features include aws_lc_rs + prefer-post-quantum
rustls = "0.23"use std::sync::Arc;
let provider = Arc::new(rustls::crypto::aws_lc_rs::default_provider());
let config = rustls::ClientConfig::builder_with_provider(provider)
.with_safe_default_protocol_versions()?
.with_root_certificates(roots)
.with_no_client_auth();Gotchas
- The
ringprovider has no ML-KEM. If you needringfor build reasons, you cannot get post-quantum TLS from rustls today. - aws-lc-rs needs a C toolchain (and CMake/NASM on some platforms) to build AWS-LC; prebuilt NASM objects are used on Windows by default. Plan CI images accordingly.
- Pure ML-KEM (MLKEM768) is off by default "out of conservatism"; the hybrid is what you want.
- Large ClientHello (~1.2 KB extra): test through middleboxes.
- FIPS: rustls has a
fipsfeature backed by AWS-LC's FIPS module.
Verify
// after the handshake completes
if let Some(group) = conn.negotiated_key_exchange_group() {
println!("{:?}", group.name()); // X25519MLKEM768
}Or echo | openssl s_client -connect host:443 2>/dev/null | grep "Negotiated TLS1.3 group" against a rustls server.
nginx (with OpenSSL 3.5+) · confignginx: enable hybrid post-quantum TLS (X25519MLKEM768)Production-ready
Why
nginx delegates key exchange to the TLS library it is built with. Built against OpenSSL 3.5+ (or BoringSSL / AWS-LC), nginx negotiates X25519MLKEM768 with modern browsers out of the box, because ssl_ecdh_curve defaults to auto, which uses the library's default list. The usual blockers are an old OpenSSL and an ssl_ecdh_curve line copied from an old hardening guide.
Steps
- Find the library nginx uses:
nginx -V 2>&1 | grep -i "built with"(look forOpenSSL 3.5or later; "running with" may also be printed if it differs). - If it is older, install an nginx build linked to OpenSSL 3.5+ (newer distro release, official nginx packages on a newer base, or a container image), or build with
--with-openssl=/path/to/openssl-3.5.x. - Remove or fix
ssl_ecdh_curve. - Ensure
ssl_protocolsincludesTLSv1.3. - Reload:
nginx -t && nginx -s reload.
Before
ssl_protocols TLSv1.2;
ssl_ecdh_curve secp384r1:prime256v1;After
ssl_protocols TLSv1.2 TLSv1.3;
# Either delete ssl_ecdh_curve (default "auto" = OpenSSL 3.5+ defaults, hybrid preferred) or:
ssl_ecdh_curve X25519MLKEM768:X25519:prime256v1:secp384r1;Gotchas
- Unknown group name: with an OpenSSL older than 3.5,
nginx -tfails onX25519MLKEM768. That is a useful check. - Upstream (proxy_pass) connections are separate: nginx acting as a client uses
proxy_ssl_conf_command Groups ...(nginx 1.19.4+) if you need to set groups for upstream TLS. - Stream module (
stream { ... }) has its ownssl_ecdh_curve. - Middleboxes between clients and nginx may mishandle the larger ClientHello; monitor handshake errors after rollout.
Verify
echo | openssl s_client -connect your-host:443 2>/dev/null | grep "Negotiated TLS1.3 group"
# Negotiated TLS1.3 group: X25519MLKEM768
npx -y pqe-cli check your-host.exampleIn browser DevTools (Chrome: Security panel), the connection's key exchange shows X25519MLKEM768.
OpenSSH · configOpenSSH: make sure every connection uses mlkem768x25519-sha256, then plan PQ keysProduction-ready
Why
SSH sessions carry shell commands, secrets and file transfers, and recorded sessions could be decrypted later. OpenSSH added the hybrid key exchange mlkem768x25519-sha256 (ML-KEM-768 + X25519, now RFC 10042) in 9.9 and made it the default in 10.0 (April 2025). Since 10.1, the ssh client warns when a connection negotiates a key exchange that is not post-quantum (WarnWeakCrypto, on by default), and OpenSSH 10.6 extended that option to sshd. Earlier, OpenSSH 9.0–9.9 defaulted to the hybrid sntrup761x25519-sha512, which is also post-quantum.
Authentication keys (ssh-ed25519, ECDSA, RSA) are a second, less urgent step: signatures are checked live and cannot be "harvested". OpenSSH 10.4 added experimental hybrid ssh-mldsa44-ed25519 keys and 10.6 enabled the algorithm under its final name.
Steps
-
Check versions on clients, servers, bastions and CI runners:
ssh -V(servers usually ship the same OpenSSH package; check with your package manager). -
See what a connection negotiates:
bash ssh -v user@host exit 2>&1 | grep "kex: algorithm" # debug1: kex: algorithm: mlkem768x25519-sha256 -
Remove old hardening that pins
KexAlgorithmsto classical algorithms, or put the hybrids first (serversshd_configand client~/.ssh/config//etc/ssh/ssh_config). -
Upgrade servers that cannot negotiate a PQ kex (older than 9.0) or network appliances with embedded SSH; ask vendors for timelines.
-
Later: when your whole fleet runs a release that supports it, trial
ssh-keygen -t mldsa44-ed25519keys for users and hosts.
Before
# /etc/ssh/sshd_config (old hardening guide)
KexAlgorithms curve25519-sha256,ecdh-sha2-nistp256,diffie-hellman-group16-sha512After
# /etc/ssh/sshd_config
# Simplest on OpenSSH 10+: delete the KexAlgorithms line to use the PQ-first defaults.
# If you must pin a list, put the hybrids first:
KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512,curve25519-sha256,ecdh-sha2-nistp256Apply with sshd -t && systemctl reload sshd (service name varies: ssh on Debian/Ubuntu).
Gotchas
- Both ends must support it. A 10.x client talking to an old server falls back to classical kex (and warns on 10.1+). Fix the server.
sntrup761x25519-sha512is still post-quantum; it is fine wheremlkem768x25519-sha256is unavailable. Some distributions use the@openssh.comsuffixed name.- Libraries and appliances (Go
x/crypto/ssh, Paramiko, libssh, JSch, network gear) have their own support status; check before relying on defaults. - DSA is gone: OpenSSH 10.0 removed DSA keys entirely. RSA keys still work with
rsa-sha2-256/512; the SHA-1ssh-rsasignature algorithm has been off by default since 8.8. - PQ user/host keys are new.
ssh-mldsa44-ed25519needs recent OpenSSH on both ends; keys made with the earlier experimental@openssh.comvariant must be regenerated.
Verify
ssh -v user@host exit 2>&1 | grep -E "kex: algorithm|WARNING"
ssh -Q kex | grep -E "mlkem|sntrup" # what your client supports
nmap --script ssh2-enum-algos -p 22 host # what a server offers