ByteGuideHub
Security & Cryptography • • 11 min read

Self-Hosted Post-Quantum Cryptography Migration: Hybrid TLS, ML-KEM/ML-DSA, and Crypto-Agility in Production

A practical guide to migrating self-hosted infrastructure to post-quantum cryptography using NIST ML-KEM and ML-DSA standards, hybrid TLS in OpenSSL/BoringSSL, certificate lifecycle management, and crypto-agility strategies.

Sponsored / Ad Space

Self-Hosted Post-Quantum Cryptography Migration: Hybrid TLS, ML-KEM/ML-DSA, and Crypto-Agility in Production

Quick Summary (TL;DR)

  • Start now, not later. “Harvest now, decrypt later” attacks mean today’s encrypted traffic may already be compromised by future quantum computers.
  • Use hybrid key exchange first. Deploy X25519MLKEM768 in TLS to get quantum resistance without breaking clients.
  • Adopt ML-KEM (FIPS 203) for key exchange and ML-DSA (FIPS 204) for signatures, replacing RSA/ECC where feasible.
  • Build crypto-agility through abstraction layers, inventory, and monitoring so you can swap algorithms without re-architecting.
  • Follow a phased rollout: assess → enable hybrid TLS → test → deploy PQC certs → monitor and iterate.

Post-quantum cryptography (PQC) has moved from academic curiosity to an operational requirement. If you run self-hosted infrastructure—web servers, APIs, VPNs, internal services—you need a migration plan that doesn’t break production and doesn’t wait for a “Y2Q” deadline. This guide walks through a practical, production-ready path using the finalized NIST standards, hybrid TLS, and crypto-agility principles.

Why Migrate to Post-Quantum Cryptography Now?

The Quantum Threat Timeline

No one knows exactly when a cryptographically relevant quantum computer (CRQC) will arrive. Estimates range from a decade to much longer, but the planning horizon matters more than the prediction. NIST, NSA, and CISA all recommend beginning migration now because the lead time for replacing cryptography across a large estate is measured in years, not weeks.

Harvest Now, Decrypt Later

The most immediate threat isn’t a live quantum attack—it’s data exfiltration today for decryption later. An adversary can record encrypted traffic now and decrypt it once a CRQC exists. Any data with a confidentiality lifetime longer than your migration timeline (health records, source code, credentials, legal documents) is already at risk. This is why key exchange (which protects the session) is the first priority, ahead of signatures.

NIST Post-Quantum Standards: ML-KEM and ML-DSA

ML-KEM (FIPS 203)

ML-KEM (Module-Lattice-Based Key-Encapsulation Mechanism) is derived from CRYSTALS-Kyber. It’s a key encapsulation mechanism used for key exchange—the part of TLS that establishes a shared secret. It comes in three parameter sets: ML-KEM-512, ML-KEM-768, and ML-KEM-1024, offering increasing security levels.

ML-DSA (FIPS 204)

ML-DSA (Module-Lattice-Based Digital Signature Algorithm), derived from CRYSTALS-Dilithium, is used for digital signatures—certificates, code signing, and authentication. It offers ML-DSA-44, ML-DSA-65, and ML-DSA-87 variants.

Comparison of PQC Algorithms

AlgorithmStandardPurposePublic Key SizeSignature/Ciphertext SizeSecurity Level
ML-KEM-768FIPS 203Key exchange1,184 B1,088 B (ciphertext)~192-bit
ML-KEM-1024FIPS 203Key exchange1,568 B1,568 B (ciphertext)~256-bit
ML-DSA-65FIPS 204Signatures1,952 B3,309 B~192-bit
ML-DSA-87FIPS 204Signatures2,592 B4,627 B~256-bit
X25519 (classical)RFC 7748Key exchange32 B32 B~128-bit
Ed25519 (classical)RFC 8032Signatures32 B64 B~128-bit

The size increase is the dominant operational challenge—plan for larger handshakes and certificates.

Hybrid Key Exchange in TLS

How Hybrid Key Exchange Works

Hybrid key exchange combines a classical algorithm with a PQC algorithm so the derived secret is secure if either remains unbroken. This gives you a safety net: if ML-KEM is later found weak, X25519 still protects the session, and vice versa. In TLS 1.3, the negotiated group X25519MLKEM768 (formerly X25519Kyber768Draft00) is the de facto standard.

sequenceDiagram
    participant C as Client
    participant S as Server
    C->>S: ClientHello (key_share: X25519 + ML-KEM-768)
    S->>C: ServerHello (key_share: X25519 + ML-KEM-768)
    Note over C,S: Each side computes shared secret:<br/>KDF(X25519_secret || ML-KEM_secret)
    C->>S: Finished (encrypted)
    S->>C: Finished (encrypted)
    Note over C,S: Application data flows over hybrid-derived keys

Implementing Hybrid TLS in OpenSSL and BoringSSL

OpenSSL 3.x Configuration

OpenSSL 3.5+ enables X25519MLKEM768 by default in TLS 1.3. To be explicit:

# Verify support
openssl list -tls-groups | grep -i mlkem

# Server config (nginx example using OpenSSL 3.5)
ssl_protocols TLSv1.3;
ssl_conf_command Groups X25519MLKEM768:X25519:P-256;

For a quick test with s_client:

openssl s_client -connect example.com:443 -groups X25519MLKEM768 -tls1_3

BoringSSL Configuration

BoringSSL exposes hybrid groups via SSL_CTX_set1_groups_list. In practice, Google Chrome and Cloudflare already negotiate X25519MLKEM768 by default. For a self-hosted service built on BoringSSL:

static const uint16_t kGroups[] = {
    SSL_GROUP_X25519_MLKEM768,
    SSL_GROUP_X25519,
};
SSL_CTX_set1_group_ids(ctx, kGroups, sizeof(kGroups) / sizeof(kGroups[0]));

Certificate Lifecycle Management with ML-DSA

Generating ML-DSA Certificates

With OpenSSL 3.5+ (or 3.2+ with the OQS provider), you can generate ML-DSA keys and certificates:

# Generate an ML-DSA-65 key
openssl genpkey -algorithm ML-DSA-65 -out server-mldsa.key

# Create a CSR
openssl req -new -key server-mldsa.key -out server-mldsa.csr \
  -subj "/CN=example.internal"

# Self-signed cert for testing
openssl req -x509 -key server-mldsa.key -out server-mldsa.crt \
  -days 90 -subj "/CN=example.internal"

For production, you’ll need a CA that issues ML-DSA certificates. Most public CAs are still in pilot programs, so start with hybrid certificates (a single certificate carrying both a classical and a PQC key) where available, or run an internal PQC CA using step-ca or cfssl builds with PQC support.

Certificate Authority Support

CA / ToolML-DSA SupportNotes
Let’s EncryptNot yetTrack ACME PQC roadmap
DigiCert / EntrustPilotEnterprise customers only
Internal step-caVia pluginsBest for self-hosted
OpenSSL CAYes (3.5+)Manual lifecycle management

Automating Renewal and Rotation

Treat ML-DSA certificates like any other: automate issuance and rotation. Because signatures are larger and lattice-based keys are newer, rotate on a shorter cycle (e.g., 30–60 days) to reduce blast radius if a key is compromised. Wire your ACME client or certbot-style workflow to your internal CA, and validate the certificate chain end-to-end after each rotation.

Building Crypto-Agility to Survive Algorithm Deprecation

Design Principles for Crypto-Agility

Crypto-agility means you can swap algorithms without touching application code. The design rules:

  1. Abstract cryptographic operations behind interfaces—never hardcode RSA or ECDSA in business logic.
  2. Drive algorithm choice from configuration, not code.
  3. Version your crypto policies so you can roll back.
  4. Assume every algorithm will eventually be deprecated.
flowchart TD
    A[Application] --> B[Crypto Abstraction Layer]
    B --> C{Policy Engine}
    C -->|TLS 1.3 + Hybrid| D[OpenSSL Provider]
    C -->|Signatures| E[ML-DSA Provider]
    C -->|Legacy fallback| F[RSA/ECC Provider]
    D --> G[Network]
    E --> G
    F --> G
    H[Config Management] --> C
    I[Monitoring] --> C

Inventory and Discovery

You cannot migrate what you cannot see. Build an inventory of every TLS endpoint, certificate, and key. Use:

# Discover supported groups across your fleet
nmap --script ssl-enum-ciphers -p 443 host.internal

# Detailed TLS inspection
testssl.sh --protocols --groups host.internal

Tag each asset with its current algorithms and a migration status.

Abstraction Layers and Configuration Management

Store crypto policy in your configuration management system (Ansible, Terraform, etc.):

# crypto-policy.yml
tls:
  min_version: "1.3"
  groups:
    - X25519MLKEM768
    - X25519
  certificates:
    signature_algorithm: "ML-DSA-65"
    rotation_days: 45

Push this policy to servers and let templates render the actual config. This gives you a single source of truth and an auditable change trail.

Monitoring and Alerts

Log negotiated cipher suites and groups from your servers, and alert on any use of quantum-vulnerable algorithms (RSA, ECDSA, finite-field DH). Export metrics like tls_negotiated_group to Prometheus and set alerts when a client falls back to classical-only groups.

Step-by-Step Migration Plan

Phase 1: Assessment and Inventory

  • Enumerate all TLS endpoints, certificates, and signing operations.
  • Classify data by confidentiality lifetime—prioritize long-lived secrets.
  • Identify software versions and whether they support PQC (OpenSSL 3.5+, BoringSSL, etc.).

Phase 2: Enable Hybrid Key Exchange

  • Upgrade TLS terminators to a PQC-capable stack.
  • Enable X25519MLKEM768 alongside X25519 as a fallback.
  • Keep TLS 1.3 as the minimum version.

Phase 3: Test and Validate

  • Run s_client/testssl.sh against staging to confirm hybrid negotiation.
  • Load-test to measure handshake latency and fragmentation behavior.
  • Verify older clients still connect via the classical fallback group.

Phase 4: Roll Out Certificates with ML-DSA

  • Provision an internal PQC CA or use a pilot CA.
  • Issue ML-DSA (or hybrid) certificates for internal services first.
  • Automate rotation and validate chains after each renewal.

Phase 5: Monitor and Iterate

  • Track negotiated groups and alert on classical-only fallbacks.
  • Re-audit quarterly and update policy as standards and tooling mature.
  • Plan for signature migration (code signing, mTLS) as a follow-on wave.

Performance and Operational Considerations

Computational Overhead

ML-KEM is fast—often comparable to or faster than classical ECDH for keygen and encapsulation. ML-DSA verification is also efficient, though signing is slower than Ed25519. The real cost is bandwidth and handshake size, not raw CPU.

Certificate and Key Sizes

ML-DSA-65 certificates are roughly 3–5 KB versus ~1 KB for ECDSA. This increases TLS handshake size and can push you past the initial congestion window, causing extra round trips.

TLS Handshake Size and Fragmentation

A hybrid X25519MLKEM768 key share adds ~1.2 KB to the ClientHello. Some middleboxes and legacy load balancers mishandle large ClientHellos, causing fragmentation or connection resets. Test through every hop in your path, and enable TCP fast open or increase initial window sizes where possible.

MetricClassical (X25519 + ECDSA)Hybrid (X25519MLKEM768 + ML-DSA-65)
ClientHello size~300 B~1.5 KB
Certificate size~1 KB~4 KB
Handshake CPUBaseline+10–30%
Handshake latencyBaseline+0–1 RTT (if fragmentation)

Conclusion

Post-quantum migration is a multi-year program, not a single upgrade. Start with hybrid key exchange to close the harvest-now-decrypt-later gap immediately, then layer in ML-DSA certificates as CA support matures. Throughout, invest in crypto-agility—abstraction, inventory, and monitoring—so the next algorithm transition is a configuration change, not a rewrite. The organizations that treat PQC as an ongoing operational discipline, rather than a one-time project, will be the ones that stay secure through the transition.

FAQ

What is hybrid key exchange in TLS, and why is it recommended for PQC migration? Hybrid key exchange combines a classical algorithm (like X25519) with a post-quantum algorithm (like ML-KEM) to derive the shared secret. This ensures the connection remains secure even if one algorithm is broken. It is recommended because it provides a safety net during the transition: if ML-KEM is later found vulnerable, the classical algorithm still protects the session, and vice versa.

Are ML-KEM and ML-DSA supported in OpenSSL and BoringSSL today? Yes. OpenSSL 3.5+ enables X25519MLKEM768 by default in TLS 1.3 and ships ML-KEM/ML-DSA support; earlier 3.2–3.4 releases can use them via providers. BoringSSL has production support for hybrid key exchange with ML-KEM. Support is evolving quickly, so always verify against the latest release notes before deploying.

How do I generate an ML-DSA certificate for my web server? Using OpenSSL 3.5+, generate an ML-DSA key pair with openssl genpkey -algorithm ML-DSA-65, create a CSR, and either self-sign it for testing or have it signed by a CA that supports ML-DSA. For production, use an internal PQC CA (e.g., step-ca) or a hybrid certificate that carries both classical and PQC keys until public CAs catch up.

What is crypto-agility, and how do I build it? Crypto-agility is the ability to quickly switch cryptographic algorithms without major architectural changes. Build it by abstracting cryptographic operations behind interfaces, using configuration management to control algorithm choices, maintaining an inventory of all cryptographic assets, and implementing monitoring to detect deprecated algorithms.

Will post-quantum cryptography impact TLS performance? Moderately. ML-KEM is computationally efficient, but larger public keys and certificates increase handshake size—potentially triggering fragmentation and an extra round trip. Expect roughly 10–30% more handshake CPU and larger packets. Test in your environment, especially through load balancers and middleboxes, to measure real impact.

Sponsored / Ad Space