1. Inventory public-key calls
Migrate asymmetric public-key schemes first. Under final NIST IR 8547, AES-128/256 and SHA-256/384/512 remain approved (only CNSA 2.0 requires upgrading AES-128/SHA-256 to AES-256/SHA-384+).
| Surface | Go packages / patterns | Priority |
|---|---|---|
| TLS key exchange | crypto/tls (servers & outbound clients), pinned CurvePreferences, cert/SPKI pins, GODEBUG=tlsmlkem=0 / tlssecpmlkem=0 |
First |
| Key wrapping | rsa.EncryptOAEP, classical crypto/ecdh |
First |
| Signatures | crypto/ecdsa, crypto/ed25519, rsa.SignPSS |
Phase 2 |
| Symmetric & hashes | crypto/aes (128/256-bit GCM), crypto/sha256, crypto/sha384, crypto/sha512 (CNSA 2.0 requires AES-256 & SHA-384+) |
Keep |
2. Unblock tls.X25519MLKEM768
Leave CurvePreferences unset (nil) so Go
1.24–1.27+ automatically prefers tls.X25519MLKEM768
(0x11EC), retains Go 1.26+ SecP ML-KEM hybrids and
classical fallbacks, and keeps MinVersion: tls.VersionTLS12
so existing TLS 1.2 peers do not break. (Note: in Go 1.27+, an
explicit CurvePreferences slice overrides
GODEBUG=tlsmlkem=0 / tlssecpmlkem=0;
nil respects them.)
tlsConfig := &tls.Config{
MinVersion: tls.VersionTLS12,
CurvePreferences: []tls.CurveID{
tls.X25519,
tls.CurveP256,
},
}
tlsConfig := &tls.Config{
MinVersion: tls.VersionTLS12, // Keep TLS 1.2 for compatibility; TLS 1.3 + X25519MLKEM768 negotiated by default
// CurvePreferences left nil: Go 1.24+ automatically enables X25519MLKEM768,
// Go 1.26+ adds SecP256r1MLKEM768 & SecP384r1MLKEM1024, plus classical fallbacks.
}
3. Wrap keys with crypto/mlkem
Replace classical ECDH or RSA-OAEP key wrapping with standard
library FIPS 203 ML-KEM-768. Always authenticate
wrapped payloads with an AEAD cipher (Decapsulate uses
FIPS 203 implicit rejection and returns err == nil on
tampered 1,088-byte ciphertexts), and never invent a custom hybrid
combiner—use NIST SP 800-227 (stdlib crypto/hpke
hpke.MLKEM768X25519() in Go 1.26+, X-Wing
draft-connolly-cfrg-xwing-kem, or HPKE
draft-ietf-hpke-pq) if you need hybrid application
key wrapping.
package pqc
import (
"crypto/mlkem"
"fmt"
)
func WrapKey(recipientPubKey []byte) (sharedKey, ciphertext []byte, err error) {
ek, err := mlkem.NewEncapsulationKey768(recipientPubKey)
if err != nil {
return nil, nil, fmt.Errorf("invalid ML-KEM-768 encapsulation key: %w", err)
}
sharedKey, ciphertext = ek.Encapsulate()
return sharedKey, ciphertext, nil
}
func UnwrapKey(dk *mlkem.DecapsulationKey768, ciphertext []byte) ([]byte, error) {
sharedKey, err := dk.Decapsulate(ciphertext)
if err != nil {
return nil, fmt.Errorf("ML-KEM-768 decapsulation failed: %w", err)
}
return sharedKey, nil
}
| Artifact | Bytes | Go constant |
|---|---|---|
| Encapsulation key (public) | 1,184 | mlkem.EncapsulationKeySize768 |
| Ciphertext | 1,088 | mlkem.CiphertextSize768 |
| Shared secret | 32 | mlkem.SharedKeySize |
| Decapsulation seed (secret) | 64 | mlkem.SeedSize |
4. Prove the change works
Commit permanent tests asserting default tls.X25519MLKEM768
negotiation (Go 1.25+), classical TLS 1.3 & TLS 1.2 fallback,
KAT/cross-implementation checks (crypto/mlkem/mlkemtest
in Go 1.26+, or OpenSSL 3.5+/4.x), negative/malformed-input rejection,
serialization/CLI paths, and clean GODEBUG settings,
then verify the live socket with both OpenSSL probes below.
state := resp.TLS
if state.Version != tls.VersionTLS13 {
t.Fatalf("got TLS %x, want TLS 1.3", state.Version)
}
if state.CurveID != tls.X25519MLKEM768 {
t.Fatalf("got CurveID %v, want X25519MLKEM768", state.CurveID)
}
# 1) Hybrid PQ negotiation
openssl s_client -connect example.com:443 -servername example.com \
-tls1_3 -groups X25519MLKEM768 -brief </dev/null
# 2) Classical TLS 1.3 fallback
openssl s_client -connect example.com:443 -servername example.com \
-tls1_3 -groups X25519:prime256v1 -brief </dev/null
Packet size & middlebox note (1,216 B key share / ~1.5 KB ClientHello)
RFC 10024 sends a 1,216-byte client share (1,184 B ML-KEM-768 + 32 B X25519) and a 1,120-byte server share. Test behind your actual firewall or ingress to confirm multi-packet ClientHello records pass cleanly.
What remains after key exchange
Public WebPKI is moving to Merkle Tree Certificates
(~2027), and Chrome and Edge stop trusting ECDSA P-256 CAs on
15 March 2027 (use P-384 or RSA-3072+ interim
chains). For private PKI and application signatures (JWTs,
webhooks, release signing), Go 1.27+ provides stdlib
crypto/mldsa (FIPS 204 ML-DSA-65:
1,952 B public key, 3,309 B signature) and
tls.MLDSA44/65/87.