X25519
Diffie-Hellman key agreement on Curve25519, the most common key exchange in TLS 1.3, SSH, WireGuard and Signal.
Why it's at risk
X25519 is broken by Shor's algorithm like every elliptic-curve scheme, and because it protects session keys it is exposed to harvest-now-decrypt-later. You rarely need to remove it: the recommended fix is to pair it with ML-KEM in a hybrid such as X25519MLKEM768, which stays secure as long as either half holds.
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.
- Used for
- Key exchange
- Family
- Elliptic curve (Montgomery, discrete logarithm)
- Classical security
- 128 bits
- Against a quantum computer
- Broken
- Standards
- RFC 7748, RFC 8446 (TLS 1.3), NIST SP 800-186
Migration guides
Concrete code changes to move off X25519. 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.
Go crypto/mlkem (1.24+), crypto/mldsa (1.27+) · goGo: application-level ML-KEM (crypto/mlkem) and ML-DSA (crypto/mldsa) in the standard libraryProduction-ready
Why
Go ships post-quantum primitives in the standard library: crypto/mlkem (ML-KEM-768 and ML-KEM-1024, FIPS 203) since Go 1.24, and crypto/mldsa (ML-DSA-44/65/87, FIPS 204) since Go 1.27, which also taught crypto/x509 and crypto/tls about ML-DSA. Go 1.24 also added crypto/hkdf, which you need to turn shared secrets into keys. Go 1.26 added crypto/hpke with post-quantum hybrid KEMs, which is the best choice if you need public-key encryption of messages.
Steps
- Upgrade the toolchain (
go 1.24for ML-KEM,go 1.27for ML-DSA ingo.mod). - Replace RSA-OAEP / ECDH key wrapping with ML-KEM (ideally hybrid with X25519, or use
crypto/hpke). - Replace ECDSA/Ed25519 signing with ML-DSA where verifiers can be upgraded; keep an algorithm identifier with every signature.
Before
priv, _ := ecdh.X25519().GenerateKey(rand.Reader)
peer, _ := ecdh.X25519().GenerateKey(rand.Reader)
shared, _ := priv.ECDH(peer.PublicKey()) // quantum-vulnerable
sk, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
sig, _ := ecdsa.SignASN1(rand.Reader, sk, digest[:])After: ML-KEM-768 key encapsulation
import (
"crypto/hkdf"
"crypto/mlkem"
"crypto/sha256"
)
// Receiver
dk, err := mlkem.GenerateKey768()
if err != nil { return err }
ekBytes := dk.EncapsulationKey().Bytes() // 1184 bytes, send to the sender
// Sender
ek, err := mlkem.NewEncapsulationKey768(ekBytes)
if err != nil { return err }
sharedKey, ciphertext := ek.Encapsulate() // 32-byte secret, 1088-byte ciphertext
// Receiver
recovered, err := dk.Decapsulate(ciphertext)
if err != nil { return err }
// Derive the actual AES-256-GCM key from the secret
aesKey, err := hkdf.Key(sha256.New, recovered, nil, "myapp/seal/v1", 32)
_ = sharedKeyAfter: ML-DSA-65 signatures (Go 1.27+)
import "crypto/mldsa"
sk, err := mldsa.GenerateKey(mldsa.MLDSA65())
if err != nil { return err }
pubBytes := sk.PublicKey().Bytes() // 1952 bytes
opts := &mldsa.Options{Context: "myapp/release/v1"}
sig, err := sk.Sign(nil, msg, opts) // 3309 bytes
if err != nil { return err }
pk, err := mldsa.NewPublicKey(mldsa.MLDSA65(), pubBytes)
if err != nil { return err }
if err := mldsa.Verify(pk, msg, sig, opts); err != nil { return err }Gotchas
- Store the seed.
dk.Bytes()returns the 64-byte seed form of an ML-KEM decapsulation key; recreate it withmlkem.NewDecapsulationKey768(seed). ML-DSAPrivateKey.Bytes()/mldsa.NewPrivateKey(params, seed)work the same way with a 32-byte seed. - Context strings must match between
SignandVerify. - Hybrid. Plain ML-KEM is standard-compliant, but for new protocols during the transition a hybrid (X25519 + ML-KEM, e.g. via
crypto/hpke) is the conservative choice. - FIPS module versions.
crypto/mldsais unavailable when Go is pinned to the FIPS 140-3 Go Cryptographic Module v1.0.0; it works with module v1.26.0 or later. - Sizes (ML-KEM-768 ciphertext 1,088 B; ML-DSA-65 signature 3,309 B) affect wire formats and storage.
- Older Go?
github.com/cloudflare/circlprovides ML-KEM and ML-DSA for toolchains before 1.24/1.27.
Verify
if !bytes.Equal(sharedKey, recovered) { log.Fatal("ML-KEM mismatch") }
fmt.Println(len(ciphertext), len(sig)) // 1088 3309JSSE (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.examplenode:crypto · javascriptNode.js: replace RSA/ECDH key wrapping with ML-KEM-768 using node:crypto (Node 24.7+)Production-ready
Why
If your application encrypts data to someone's public key (RSA-OAEP key wrapping, ECIES, "sealed boxes", ECDH followed by AES), anyone who stores the ciphertext can decrypt it once a large quantum computer exists. ML-KEM (FIPS 203) is the standard replacement: it is a key encapsulation mechanism. Instead of encrypting your data key with the public key, you ask ML-KEM for a fresh 32-byte shared secret plus a ciphertext that only the private-key holder can open. You then derive a symmetric key from that secret and encrypt the data with AES-256-GCM.
Node.js has native, OpenSSL-backed ML-KEM in node:crypto: key generation since 24.7.0, plus crypto.encapsulate() / crypto.decapsulate() added in 24.7.0. It requires a Node built with OpenSSL 3.5 or later (all official Node 24 and 26 builds). Node 22 does not have these APIs; use the @noble/post-quantum guide there.
Steps
- Require Node 24.7+ (check
node -v) and OpenSSL 3.5+ (process.versions.openssl). - Generate an ML-KEM-768 key pair for each recipient; publish the public key (SPKI DER or PEM).
- Sender:
encapsulate(publicKey)gives{ sharedKey, ciphertext }. Derive an AES key fromsharedKeywith HKDF and encrypt the payload with AES-256-GCM. Sendciphertext, the IV, the GCM tag and the encrypted payload. - Recipient:
decapsulate(privateKey, ciphertext)gives the samesharedKey; derive the same AES key and decrypt. - During the transition, consider a hybrid: also run X25519 and feed both secrets into HKDF (see the @noble/post-quantum guide for a worked example), so security never drops below today's.
Before (RSA-OAEP key wrapping)
import { generateKeyPairSync, publicEncrypt, privateDecrypt, randomBytes, constants } from 'node:crypto';
const { publicKey, privateKey } = generateKeyPairSync('rsa', { modulusLength: 2048 });
const dataKey = randomBytes(32);
const wrapped = publicEncrypt({ key: publicKey, padding: constants.RSA_PKCS1_OAEP_PADDING, oaepHash: 'sha256' }, dataKey);
const unwrapped = privateDecrypt({ key: privateKey, padding: constants.RSA_PKCS1_OAEP_PADDING, oaepHash: 'sha256' }, wrapped);After (ML-KEM-768 + HKDF + AES-256-GCM)
import {
generateKeyPairSync, encapsulate, decapsulate, hkdfSync,
createCipheriv, createDecipheriv, randomBytes,
} from 'node:crypto';
// Recipient, once: generate and publish the public key.
const { publicKey, privateKey } = generateKeyPairSync('ml-kem-768');
const publicPem = publicKey.export({ type: 'spki', format: 'pem' });
// Sender
function seal(recipientPublicKey, plaintext, aad = Buffer.alloc(0)) {
const { sharedKey, ciphertext: kemCt } = encapsulate(recipientPublicKey);
const key = Buffer.from(hkdfSync('sha256', sharedKey, Buffer.alloc(0), 'myapp/seal/v1', 32));
const iv = randomBytes(12);
const c = createCipheriv('aes-256-gcm', key, iv);
c.setAAD(aad);
const body = Buffer.concat([c.update(plaintext), c.final()]);
return { kemCt, iv, tag: c.getAuthTag(), body };
}
// Recipient
function open(privateKey, { kemCt, iv, tag, body }, aad = Buffer.alloc(0)) {
const sharedKey = decapsulate(privateKey, kemCt);
const key = Buffer.from(hkdfSync('sha256', sharedKey, Buffer.alloc(0), 'myapp/seal/v1', 32));
const d = createDecipheriv('aes-256-gcm', key, iv);
d.setAAD(aad);
d.setAuthTag(tag);
return Buffer.concat([d.update(body), d.final()]);
}Gotchas
- Sizes. ML-KEM-768 encapsulation (public) key: 1,184 bytes. Ciphertext: 1,088 bytes (versus 256 for RSA-2048 OAEP). Shared secret: 32 bytes. Check database columns, message size limits, QR codes and URL parameters.
- A KEM is not "encrypt with the public key". You cannot choose the secret; you get one. Wrap your existing data keys by encrypting them with the KEM-derived key if you need to keep them.
- Decapsulation never throws on a wrong ciphertext. ML-KEM uses implicit rejection: a tampered or mismatched ciphertext yields a random-looking secret, so the failure shows up as an AES-GCM authentication error. That is by design.
- Bind context. Put a protocol label (and ideally the recipient key ID) in the HKDF
infoor the AES-GCM AAD so ciphertexts cannot be replayed into another context. - Private key storage.
privateKey.export({ type: 'pkcs8', format: 'pem' })works. Node 26.0+ also supports a 64-byteraw-seedexport and writes seed-only PKCS#8 by default when a seed is available; Node 24 does not haveraw-seed. Most HSMs and cloud KMSs are still adding ML-KEM; check before designing around them. - Runtime mismatch. Code that must also run on Node 22, Deno, Bun or browsers should use
@noble/post-quantumor WebCrypto where available.
Verify
import assert from 'node:assert';
const msg = Buffer.from('hello');
assert.deepEqual(open(privateKey, seal(publicKey, msg)), msg);
console.log(encapsulate(publicKey).ciphertext.length); // 1088Run npx -y pqe-cli scan . afterwards: remaining publicEncrypt/RSA-OAEP call sites are listed as findings.
@noble/post-quantum · typescriptJavaScript/TypeScript (any runtime): hybrid X25519 + ML-KEM-768 with @noble/post-quantumExperimental
Why
@noble/post-quantum is a small pure-JavaScript implementation of ML-KEM (FIPS 203), ML-DSA (FIPS 204) and SLH-DSA (FIPS 205). It runs anywhere JavaScript runs: Node 20/22, Deno, Bun, browsers and edge workers, which makes it the easiest option when you cannot rely on Node 24's native node:crypto support.
During the transition the recommended pattern is hybrid: combine a classical X25519 exchange with ML-KEM-768 so the result is secure if either holds. You can use the library's ready-made X-Wing construction, or build the combiner yourself with HKDF.
Maturity: the library is widely used and carefully written, but its README states it has not been independently audited. Prefer an OpenSSL/AWS-LC-backed API (Node 24.7+ node:crypto, WebCrypto where available) for high-assurance server code.
Steps
npm install @noble/post-quantum @noble/curves @noble/hashes- Decide between X-Wing (option A, a fixed, specified combiner; recommended) and a custom HKDF combiner (option B, if you must interoperate with an existing protocol).
- Store the recipient's private key as securely as any other private key; publish its public key.
- Use the 32-byte shared secret only as input to a KDF, then encrypt with AES-256-GCM or ChaCha20-Poly1305.
Before (X25519 / ECIES-style)
import { x25519 } from '@noble/curves/ed25519.js';
const recipient = x25519.keygen();
const eph = x25519.keygen();
const shared = x25519.getSharedSecret(eph.secretKey, recipient.publicKey); // quantum-vulnerableAfter, option A: X-Wing (X25519 + ML-KEM-768)
import { XWing } from '@noble/post-quantum/hybrid.js';
const recipient = XWing.keygen(); // publicKey: 1216 bytes
const { cipherText, sharedSecret } = XWing.encapsulate(recipient.publicKey); // cipherText: 1120 bytes
const recovered = XWing.decapsulate(cipherText, recipient.secretKey);
// sharedSecret and recovered are equal 32-byte keysX-Wing is specified in the IETF CFRG draft draft-connolly-cfrg-xwing-kem. Record the draft/library version you deployed so the other side can match it.
After, option B: explicit HKDF combiner
import { ml_kem768 } from '@noble/post-quantum/ml-kem.js';
import { x25519 } from '@noble/curves/ed25519.js';
import { hkdf } from '@noble/hashes/hkdf.js';
import { sha256 } from '@noble/hashes/sha2.js';
import { concatBytes, utf8ToBytes } from '@noble/hashes/utils.js';
// Recipient long-term keys
const pq = ml_kem768.keygen(); // publicKey 1184 B, secretKey 2400 B
const ec = x25519.keygen();
// Sender
const { cipherText, sharedSecret: ssPq } = ml_kem768.encapsulate(pq.publicKey);
const eph = x25519.keygen();
const ssEc = x25519.getSharedSecret(eph.secretKey, ec.publicKey);
// Bind every public value into the derivation (domain separation + transcript)
const info = concatBytes(utf8ToBytes('myapp/hybrid-kem/v1'), eph.publicKey, ec.publicKey, cipherText, pq.publicKey);
const key = hkdf(sha256, concatBytes(ssPq, ssEc), undefined, info, 32);
// send: eph.publicKey (32 B) + cipherText (1088 B)
// Recipient
const ssPq2 = ml_kem768.decapsulate(cipherText, pq.secretKey);
const ssEc2 = x25519.getSharedSecret(ec.secretKey, eph.publicKey);
const key2 = hkdf(sha256, concatBytes(ssPq2, ssEc2), undefined, info, 32);Gotchas
- API versions. Code above is for
@noble/post-quantum0.5.x and@noble/curves/@noble/hashes2.x (note the.jssubpath imports). Argument orders and names have changed between major releases; check the README of the version you install. - Do not just XOR or concatenate secrets without a KDF, and include the ciphertext and public keys in the KDF input. Hand-made combiners are a classic source of subtle bugs, which is why option A exists.
- Implicit rejection.
decapsulatereturns a pseudo-random secret instead of throwing on a bad ciphertext; you detect tampering when the AEAD fails. - Sizes. Hybrid ciphertext ≈ 1.1 KB and public key ≈ 1.2 KB, versus 32 bytes for X25519 alone.
- Constant time. JavaScript engines give weaker side-channel guarantees than native code. That is fine for most client-side and server-side uses, but HSM-grade requirements need a native or hardware implementation.
- Pre-standard Kyber is not ML-KEM. Libraries or data created with "Kyber768" round-3 code are not interoperable with FIPS 203 ML-KEM.
Verify
console.assert(Buffer.from(key).equals(Buffer.from(key2)));
console.assert(cipherText.length === 1088 && pq.publicKey.length === 1184);any (design pattern) · typescriptCrypto-agility: put cryptography behind an interface so the post-quantum swap is a config changeProduction-ready
Why
Most of the cost of a cryptographic migration is not the new algorithm, it is finding and changing every place that hard-codes the old one: RSA.generate(2048) in five services, signatures stored without saying which algorithm made them, database columns sized for 256-byte signatures. Crypto-agility means you can change algorithms through configuration and a rollout, not a rewrite. NIST's guidance on the post-quantum transition (NIST IR 8547, and its crypto-agility work in CSWP 39) treats it as a core requirement because more transitions will follow.
The pattern
- One module owns cryptography. Application code calls
seal(),open(),sign(),verify(), never a library primitive directly. - Every output is self-describing. Ciphertexts, signatures and keys carry an algorithm identifier (and key ID) in a versioned envelope.
- Verifiers/decryptors accept a set; producers use one. Readers support old and new algorithms during the transition; writers switch by configuration.
- Keys are looked up by ID from a key store or KMS, so rotating keys and algorithms is the same operation.
- Sizes are not assumed. Storage and protocols allow kilobyte-sized keys, ciphertexts and signatures.
Before
import { sign as edSign, createPrivateKey } from 'node:crypto';
// Algorithm and key format hard-coded at every call site; signature stored bare.
const sig = edSign(null, payload, createPrivateKey(process.env.SIGNING_KEY!));
await db.insert({ payload, sig: sig.toString('base64') });After
// crypto/signer.ts: the only file that knows algorithms.
import { sign, verify, KeyObject } from 'node:crypto';
export type SigAlg = 'Ed25519' | 'ML-DSA-65';
export interface SignedEnvelope { v: 1; alg: SigAlg; kid: string; sig: string } // base64
interface KeyRecord { kid: string; alg: SigAlg; privateKey?: KeyObject; publicKey: KeyObject }
export class Signer {
constructor(
private readonly keys: Map<string, KeyRecord>,
private readonly activeKid: string, // from configuration
private readonly acceptAlgs: Set<SigAlg>, // from configuration
) {}
sign(data: Buffer): SignedEnvelope {
const k = this.keys.get(this.activeKid)!;
// Ed25519 and ML-DSA both take a null digest in node:crypto (ML-DSA: Node 24.6+)
return { v: 1, alg: k.alg, kid: k.kid, sig: sign(null, data, k.privateKey!).toString('base64') };
}
verify(data: Buffer, env: SignedEnvelope): boolean {
if (!this.acceptAlgs.has(env.alg)) return false;
const k = this.keys.get(env.kid);
if (!k || k.alg !== env.alg) return false; // never trust alg without the key's own record
return verify(null, data, k.publicKey, Buffer.from(env.sig, 'base64'));
}
}
// Call sites never mention an algorithm:
const env = signer.sign(payload);
await db.insert({ payload, signature: JSON.stringify(env) }); // TEXT/JSONB column, not VARCHAR(100)Migration then becomes: deploy verifiers with acceptAlgs = {Ed25519, ML-DSA-65} → add an ML-DSA key → switch activeKid → re-sign or expire old data → drop Ed25519 from acceptAlgs.
Gotchas
- Do not let the message choose the algorithm. The verifier must check that the key ID's registered algorithm matches the envelope (JWT "alg confusion" bugs come from skipping this).
- Downgrade protection. Once everything supports the new algorithm, remove the old one from the accept list; otherwise attackers who can forge the old one still win.
- Hybrid/dual signatures (both classical and PQ) fit the same envelope:
alg: 'Ed25519+ML-DSA-65'with two signatures, verified with AND semantics. - Inventory first. You can't wrap what you haven't found:
npx -y pqe-cli scan . --cbom -o cbom.jsonproduces a CycloneDX cryptography bill of materials to track progress. - Sizes: ML-DSA-65 signatures are 3,309 bytes; ML-KEM-768 ciphertexts 1,088 bytes. Use TEXT/BLOB/JSONB columns, and test message-size limits (queues, headers, cookies, MTU-sensitive UDP protocols).
Verify
Write a test that signs with one algorithm and verifies after flipping activeKid, and a test that an envelope claiming an algorithm not registered for its kid is rejected. Re-run npx -y pqe-cli scan . and confirm crypto primitives appear only in the crypto module.
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.examplecryptography (pyca) · pythonPython: replace RSA-OAEP / ECDH key wrapping with ML-KEM-768 in pyca/cryptography (48+)Production-ready
Why
Data encrypted to an RSA or elliptic-curve public key can be stored now and decrypted once a large quantum computer exists. ML-KEM (FIPS 203) replaces that step. cryptography (pyca) added an ML-KEM module in 47.0.0 (AWS-LC and BoringSSL backends) and extended it to the regular OpenSSL backend (OpenSSL 3.5.0 or later) in 48.0.0. The PyPI wheels bundle a recent OpenSSL, so pip install "cryptography>=48" gives you ML-KEM-768 and ML-KEM-1024 on Linux, macOS and Windows.
Steps
pip install -U "cryptography>=48"and pin it.- Recipient:
MLKEM768PrivateKey.generate(); publishpublic_key().public_bytes_raw()(1,184 bytes) or the SPKI encoding. - Sender:
shared_secret, ciphertext = public_key.encapsulate(); derive an AES key with HKDF; encrypt with AES-256-GCM. - Recipient:
private_key.decapsulate(ciphertext)gives the same secret. - For a hybrid (recommended during the transition), also do an X25519 exchange and feed both secrets into HKDF, as below.
Before
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import hashes
import os
priv = rsa.generate_private_key(public_exponent=65537, key_size=2048)
data_key = os.urandom(32)
oaep = padding.OAEP(mgf=padding.MGF1(hashes.SHA256()), algorithm=hashes.SHA256(), label=None)
wrapped = priv.public_key().encrypt(data_key, oaep)
assert priv.decrypt(wrapped, oaep) == data_keyAfter (hybrid ML-KEM-768 + X25519 → HKDF → AES-256-GCM)
import os
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric.mlkem import MLKEM768PrivateKey
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey, X25519PublicKey
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
# Recipient key pairs (store the private keys like any other secret)
pq_priv = MLKEM768PrivateKey.generate()
ec_priv = X25519PrivateKey.generate()
pq_pub, ec_pub = pq_priv.public_key(), ec_priv.public_key()
def derive(ss_pq: bytes, ss_ec: bytes, transcript: bytes) -> bytes:
return HKDF(algorithm=hashes.SHA256(), length=32, salt=None,
info=b"myapp/hybrid-seal/v1" + transcript).derive(ss_pq + ss_ec)
def seal(plaintext: bytes, aad: bytes = b"") -> dict:
ss_pq, kem_ct = pq_pub.encapsulate() # (shared_secret, ciphertext)
eph = X25519PrivateKey.generate()
eph_pub = eph.public_key().public_bytes_raw()
ss_ec = eph.exchange(ec_pub)
key = derive(ss_pq, ss_ec, eph_pub + kem_ct)
nonce = os.urandom(12)
return {"kem_ct": kem_ct, "eph_pub": eph_pub, "nonce": nonce,
"body": AESGCM(key).encrypt(nonce, plaintext, aad)}
def open_(msg: dict, aad: bytes = b"") -> bytes:
ss_pq = pq_priv.decapsulate(msg["kem_ct"])
ss_ec = ec_priv.exchange(X25519PublicKey.from_public_bytes(msg["eph_pub"]))
key = derive(ss_pq, ss_ec, msg["eph_pub"] + msg["kem_ct"])
return AESGCM(key).decrypt(msg["nonce"], msg["body"], aad)
assert open_(seal(b"hello")) == b"hello"Gotchas
- Return order.
encapsulate()returns(shared_secret, ciphertext); mixing them up gives silently wrong keys. - Implicit rejection.
decapsulate()does not raise on a tampered ciphertext; you find out when AES-GCM raisesInvalidTag. - Sizes. ML-KEM-768 ciphertext 1,088 bytes, public key 1,184 bytes; ML-KEM-1024: 1,568 and 1,568. Private keys serialise as a 64-byte seed (
private_bytes_raw()). - Backend support. If your
cryptographyis built against a system OpenSSL older than 3.5 (some distro packages),generate()raisesUnsupportedAlgorithm. Check in CI. - Hazmat. These are low-level primitives; the HKDF
infolabel and transcript binding above matter. Prefer a reviewed higher-level protocol (HPKE, TLS) when one fits. - No ML-KEM-512 class in this module; use 768 (recommended) or 1024 (CNSA 2.0).
Verify
from cryptography.hazmat.primitives.asymmetric.mlkem import MLKEM768PrivateKey
k = MLKEM768PrivateKey.generate()
ss, ct = k.public_key().encapsulate()
assert k.decapsulate(ct) == ss and len(ct) == 1088liboqs-python (Open Quantum Safe) · pythonPython: prototype post-quantum algorithms with liboqs-pythonExperimental
Why
liboqs-python wraps liboqs from the Open Quantum Safe project. It exposes many algorithms (ML-KEM, ML-DSA, SLH-DSA, Falcon, HQC, Classic McEliece, ...) behind one API, which makes it useful for experiments, benchmarks and interoperability tests. The OQS project itself describes liboqs as intended for research and prototyping, not production. For production Python code prefer pyca/cryptography 48+ (ML-KEM, ML-DSA).
Steps
- Install liboqs (the C library) and then
pip install liboqs-python, following the project's README; the wrapper needs a matching liboqs shared library. - List what your build supports:
oqs.get_enabled_kem_mechanisms(),oqs.get_enabled_sig_mechanisms(). - Use the FIPS names (
"ML-KEM-768","ML-DSA-65"), not the pre-standard"Kyber768"/"Dilithium3".
Before
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey
a, b = X25519PrivateKey.generate(), X25519PrivateKey.generate()
shared = a.exchange(b.public_key())After
import oqs
# Key encapsulation
with oqs.KeyEncapsulation("ML-KEM-768") as receiver, oqs.KeyEncapsulation("ML-KEM-768") as sender:
public_key = receiver.generate_keypair()
ciphertext, ss_sender = sender.encap_secret(public_key)
ss_receiver = receiver.decap_secret(ciphertext)
assert ss_sender == ss_receiver
# Signatures
message = b"hello"
with oqs.Signature("ML-DSA-65") as signer, oqs.Signature("ML-DSA-65") as verifier:
signer_public_key = signer.generate_keypair()
signature = signer.sign(message)
assert verifier.verify(message, signature, signer_public_key)Gotchas
- Not for production according to its maintainers; no FIPS validation.
- Algorithm availability depends on build flags; check the enabled lists rather than assuming.
- Secret key export:
export_secret_key()returns raw bytes that you must protect yourself. - Use it to test sizes and speed, then move the real implementation to a maintained library.
Verify
import oqs
print("ML-KEM-768" in oqs.get_enabled_kem_mechanisms(), "ML-DSA-65" in oqs.get_enabled_sig_mechanisms())rustls (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.
aws-lc-rs (kem) / RustCrypto ml-kem · rustRust: application-level ML-KEM-768 with aws-lc-rs or the RustCrypto ml-kem crateProduction-ready
Why
To replace ECDH- or RSA-based key wrapping in your own protocol, use ML-KEM (FIPS 203). Two common choices:
aws-lc-rs(aws_lc_rs::kem): bindings to AWS-LC, which also has a FIPS-validated mode. Recommended for production.ml-kem(RustCrypto): pure Rust,no_std-friendly. Its README warns it has never been independently audited; fine for many uses, but weigh that for high-assurance code.
Steps
- Add the crate, generate a decapsulation key, publish the encapsulation key bytes (1,184 bytes for ML-KEM-768).
- Sender encapsulates to get
(ciphertext, shared_secret); receiver decapsulates. - Feed the secret (optionally together with an X25519 secret for a hybrid) into HKDF and encrypt with AES-256-GCM or ChaCha20-Poly1305.
Before
use x25519_dalek::{EphemeralSecret, PublicKey};
let secret = EphemeralSecret::random();
let shared = secret.diffie_hellman(&peer_public); // quantum-vulnerableAfter: aws-lc-rs
use aws_lc_rs::kem::{Ciphertext, DecapsulationKey, EncapsulationKey, ML_KEM_768};
// Receiver
let dk = DecapsulationKey::generate(&ML_KEM_768)?;
let ek_bytes = dk.encapsulation_key()?.key_bytes()?; // send ek_bytes.as_ref() (1184 bytes)
// Sender
let ek = EncapsulationKey::new(&ML_KEM_768, ek_bytes.as_ref())?;
let (ciphertext, sender_secret) = ek.encapsulate()?;
// Receiver
let receiver_secret = dk.decapsulate(Ciphertext::from(ciphertext.as_ref()))?;
assert_eq!(sender_secret.as_ref(), receiver_secret.as_ref());After: RustCrypto ml-kem (0.3.x, getrandom feature enabled)
use ml_kem::{MlKem768, kem::{Decapsulate, Encapsulate, Kem}};
let (dk, ek) = MlKem768::generate_keypair();
let (ct, k_send) = ek.encapsulate();
let k_recv = dk.decapsulate(&ct);
assert_eq!(k_send, k_recv);Gotchas
- API churn. The RustCrypto
ml-kemAPI changed between 0.2 and 0.3; copy examples from the docs of the exact version you depend on. - Implicit rejection: decapsulating a wrong ciphertext returns a pseudo-random secret, not an error. Authenticate the payload with an AEAD.
- Do not use the raw secret directly as a long-term key; run it through HKDF with a protocol label.
- Hybrid with X25519 is recommended during the transition (combine both secrets in HKDF, binding the ciphertext and public keys).
Verify
Unit-test a round trip and assert sizes: ciphertext 1,088 bytes, encapsulation key 1,184 bytes, secret 32 bytes.
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.
Caddy 2.10+ · configCaddy: hybrid post-quantum TLS is the default since 2.10; keep it that wayProduction-ready
Why
Caddy is written in Go and uses crypto/tls, which enables X25519MLKEM768 by default since Go 1.24. Caddy 2.10.0+ ships with it on by default. Caddy's documentation recommends not changing the curves defaults.
Steps
caddy version→ 2.10.0 or later; upgrade if not.- Search your Caddyfile / JSON config for
curves(Caddyfiletls { curves ... }, JSON"curves"). Remove it, or includex25519mlkem768. - Do not restrict
protocolsto TLS 1.2.
Before
example.com {
tls {
protocols tls1.2 tls1.2
curves x25519 secp256r1
}
}After
example.com {
# Simplest: no tls curves override at all.
# If you must list them, include the hybrid:
tls {
curves x25519mlkem768 x25519 secp256r1
}
}Gotchas
- Custom Caddy builds (xcaddy) inherit the Go version used to build them; build with Go 1.24+.
reverse_proxyto HTTPS upstreams uses Caddy as a TLS client; it also gets the Go defaults unless the transport's TLS settings override curves.- Certificates (automatic ACME RSA/ECDSA) are unaffected.
Verify
echo | openssl s_client -connect example.com:443 2>/dev/null | grep "Negotiated TLS1.3 group"
npx -y pqe-cli check example.comCloudflare (edge and origin) · configCloudflare: hybrid post-quantum TLS to visitors is automatic; check the origin leg tooProduction-ready
Why
If your site is proxied through Cloudflare, connections from browsers that support X25519MLKEM768 (Chrome/Edge 131+, Firefox 132+ desktop, Safari 26+) to Cloudflare's edge already use hybrid post-quantum key agreement; there is nothing to enable. The remaining leg is Cloudflare → your origin, which is protected only if your origin server supports the hybrid.
Steps
- Edge: nothing to do. Confirm with
npx -y pqe-cli check yourdomain.comor Cloudflare Radar's post-quantum browser check. - Origin: Cloudflare's Automatic key exchange (on by default for existing and new zones) probes your origin and prefers post-quantum key agreement when the origin supports it. Make your origin support it: OpenSSL 3.5+ / BoringSSL / AWS-LC, Go 1.24+, rustls with aws-lc-rs, Caddy 2.10+, and so on (see the server guides).
- Optionally set the Post-quantum hybrid compliance requirement in the zone's Automatic key exchange settings if every origin supports it. Origins that don't will then fail with HTTP 525, including
fetch()from Workers in that zone, so roll out carefully. - Using Cloudflare Tunnel (
cloudflared)? Its connection to Cloudflare uses post-quantum key agreement.
Before
Origin on OpenSSL 3.0 (or Go < 1.24): visitor ↔ edge is post-quantum, edge ↔ origin is classical X25519/P-256.
After
Origin upgraded (for example nginx linked against OpenSSL 3.5+ with default ssl_ecdh_curve), so both legs negotiate X25519MLKEM768.
Gotchas
- The older Origin Post-Quantum Encryption API is now a no-op, according to Cloudflare's docs; use Automatic key exchange settings instead.
- Split ClientHello: Cloudflare's ClientHello to your origin spans two packets with ML-KEM. Some origin-side load balancers or firewalls mishandle this; Automatic key exchange falls back gracefully unless you enforce the compliance requirement.
- Post-quantum signatures to origin: since mid-2026 Cloudflare supports ML-DSA certificates for Authenticated Origin Pulls and Custom Origin Trust Store; this requires TLS 1.3 and an ML-DSA-capable origin (for example OpenSSL 3.5+), and ML-DSA keys uploaded in seed-only encoding.
- Other providers (CDNs, WAFs, load balancers) in front of or behind Cloudflare each need their own check.
Verify
# Edge
echo | openssl s_client -connect yourdomain.com:443 -servername yourdomain.com 2>/dev/null | grep "Negotiated TLS1.3 group"
# Origin (directly, bypassing Cloudflare)
echo | openssl s_client -connect ORIGIN_IP:443 -servername yourdomain.com 2>/dev/null | grep "Negotiated TLS1.3 group"AWS Application / Network Load Balancer · configAWS ALB/NLB: switch HTTPS/TLS listeners to a PQ security policyProduction-ready
Why
Since November 2025, AWS Application Load Balancers and Network Load Balancers offer TLS security policies with hybrid post-quantum key exchange. Policies with PQ in their name support X25519MLKEM768, SecP256r1MLKEM768 and SecP384r1MLKEM1024 (TLS 1.3 only) alongside classical groups. Existing listeners keep their old policy until you change it.
At the time of writing the PQ policies include:
| Policy | Notes |
|---|---|
ELBSecurityPolicy-TLS13-1-2-Res-PQ-2025-09 | Recommended by AWS; console default for new listeners |
ELBSecurityPolicy-TLS13-1-2-PQ-2025-09 | TLS 1.2 + 1.3, broader cipher list |
ELBSecurityPolicy-TLS13-1-3-PQ-2025-09 | TLS 1.3 only |
...-FIPS-PQ-2025-09 variants | FIPS |
Check the "Security policies" page of the ELB documentation for the current list before applying.
Steps
-
List listeners and their policies:
bash aws elbv2 describe-listeners --load-balancer-arn "$LB_ARN" \ --query 'Listeners[].{Port:Port,Protocol:Protocol,Policy:SslPolicy,Arn:ListenerArn}' -
Update each HTTPS/TLS listener:
bash aws elbv2 modify-listener --listener-arn "$LISTENER_ARN" \ --ssl-policy ELBSecurityPolicy-TLS13-1-2-Res-PQ-2025-09 -
Infrastructure as code: change the policy there too (CloudFormation
SslPolicy, Terraformaws_lb_listener.ssl_policy), or the next deploy reverts it. -
Watch ALB connection logs, which record the negotiated key exchange, to see what share of clients is post-quantum.
Before
resource "aws_lb_listener" "https" {
ssl_policy = "ELBSecurityPolicy-TLS13-1-2-2021-06"
# ...
}After
resource "aws_lb_listener" "https" {
ssl_policy = "ELBSecurityPolicy-TLS13-1-2-Res-PQ-2025-09"
# ...
}Gotchas
- Clients must also support it. Clients without ML-KEM (or on TLS 1.2) fall back to classical groups; nothing breaks.
- ALB → target connections are a separate TLS session; targets need their own PQ-capable stack if you re-encrypt.
- CloudFront, API Gateway and other services have their own settings and timelines; check each.
- CNSA 2.0 policies (
...-CNSA2-...-FIPS-PQ-2026-07) use pure ML-KEM-1024 and secp384r1 only, which many ordinary clients won't support.
Verify
echo | openssl s_client -connect your-alb-hostname:443 2>/dev/null | grep "Negotiated TLS1.3 group"
npx -y pqe-cli check your-domain.exampleOpenSSH · 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