DEV Community

Cover image for Post-Quantum Encryption: How We Moved LLM Gateway
smakosh
smakosh

Posted on Originally published at llmgateway.io

Post-Quantum Encryption: How We Moved LLM Gateway

Encrypted traffic has a shelf life. An attacker who records a TLS session today cannot read it, but can keep it. Once a large quantum computer exists, the classical key exchange that protected that session can be broken and everything inside it read. This is called harvest now, decrypt later, and it means the deadline for post-quantum encryption is not the day the quantum computer ships. It is the day the traffic is sent.

An LLM gateway is a good target for that kind of patience. Prompts carry source code, contracts, medical notes and customer records, and they all pass through one place on the way to a model provider. So this week we moved LLM Gateway to post-quantum encryption on every path we control, and added checks that keep it there. This post covers what changed, what did not need to, and what cannot be post-quantum yet.

What post-quantum encryption means for a gateway

A request crosses two network hops: from your application to the gateway, and from the gateway to the model provider. On both, TLS does two separate jobs.

  • Key exchange agrees on the session key. This is what harvest now, decrypt later attacks. If it is classical (X25519, P-256), recorded traffic can be decrypted later.
  • Authentication proves who the server is, with a certificate signature. A quantum computer could forge it, but only at connection time. It cannot be used to decrypt a recording.

The fix for the first job is X25519MLKEM768: a hybrid key exchange that runs classical X25519 and ML-KEM-768 together and derives the session key from both. ML-KEM is the lattice-based mechanism NIST standardized as FIPS 203 in August 2024. Hybrid matters because ML-KEM is young. If a flaw is found in it, the session is still as strong as X25519. If a quantum computer arrives, it is still as strong as ML-KEM. An attacker has to break both.

Where we stand today

Path Protection Status
Clients to the hosted gateway, API and apps X25519MLKEM768 on TLS 1.3 7 of 7 hostnames, checked daily
Gateway to model providers X25519MLKEM768 offered first Accepted by 24 of 31 default endpoints
Gateway to Airside carriers X25519MLKEM768 required to list Enforced at preflight
Stored provider keys and OAuth secrets AES-256-GCM Unchanged, already safe
API key hashes and signed tokens HMAC-SHA256 Unchanged, already safe
Enterprise licenses Ed25519 and ML-DSA-65, both required New licenses from December 2026
Redis and Postgres Private network, nothing outside reaches it No traffic to record
Public TLS certificates, Google-signed tokens RSA or ECDSA Not post-quantum yet, cannot decrypt a recording

The numbers in the first two rows come from a script in our public repository, run on December 3, 2026. You can run it yourself; it is covered below.

Clients to the gateway

Our hosted endpoints sit behind Google Cloud's Application Load Balancer, which negotiates X25519MLKEM768 with its default TLS policy. Every hostname we serve does: llmgateway.io, api.llmgateway.io, internal.llmgateway.io, docs.llmgateway.io, devpass.llmgateway.io, lounge.llmgateway.io and airside.llmgateway.io.

Whether your requests use it depends on your client. Current Chrome, Firefox and Safari offer the hybrid group. So does Node.js 24, and anything else built on OpenSSL 3.5 or later. You do not change any code:

curl https://api.llmgateway.io/v1/chat/completions \
  -H "Authorization: Bearer $LLM_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-5","messages":[{"role":"user","content":"hi"}]}'
Enter fullscreen mode Exit fullscreen mode

To see what your own stack negotiates, ask OpenSSL 3.5 for the group:

openssl s_client -connect api.llmgateway.io:443 -groups X25519MLKEM768 </dev/null 2>/dev/null \
  | grep "Negotiated TLS1.3 group"
Enter fullscreen mode Exit fullscreen mode

Gateway to providers

This hop needed no new cryptography from us, only the right runtime. Our images run Node.js 24 with OpenSSL 3.5, which offers X25519MLKEM768 first on every outgoing TLS connection and falls back to a classical group only when the other side lacks it. A custom image built on an older Node.js loses it.

So the question becomes which providers accept it. We probed the default endpoint of every provider in our catalogue: 24 of 31 negotiated X25519MLKEM768, including OpenAI, Anthropic, Google AI Studio and Vertex AI, xAI, Mistral, DeepSeek, Groq, Cerebras, Together and Fireworks. Seven still answered with classical X25519. That list changes as providers upgrade their edge, so we report it instead of hardcoding it.

Refusing providers without it

By default a provider without a post-quantum key exchange is still reached over a classical one. Self-hosted deployments can turn that off on the gateway and the worker:

UPSTREAM_TLS_POST_QUANTUM_ONLY=true
Enter fullscreen mode Exit fullscreen mode

With it set, outgoing connections offer only hybrid ML-KEM groups (X25519MLKEM768, SecP256r1MLKEM768, SecP384r1MLKEM1024) on TLS 1.3. The handshake with a provider that lacks one fails like a network error, and routing falls back to a provider that supports it. A request pinned to such a provider, or sent with x-no-fallback: true, fails.

The setting covers more than chat requests: realtime WebSocket sessions, custom providers and your own base URLs, the worker's polling of long-running video jobs, downloads of image and document URLs sent in requests, and webhook deliveries. It does not cover clients that open their own sockets, such as the Stripe and Google Cloud Storage SDKs. None of those carries a prompt to a provider.

Airside carriers are checked for it

Airside is the portal where inference providers list their own endpoints on LLM Gateway. Those endpoints serve prompts, so every carrier verification run now ends with a post-quantum TLS check. It handshakes the endpoint the gateway will call, offering only hybrid ML-KEM groups on TLS 1.3, and warns unless one is negotiated.

For now a carrier without it can still list, so providers have time to upgrade. The check will later become a requirement for new listings, widened claims and relists.

Secrets at rest were already safe

Not everything had to move. Quantum computers break the asymmetric algorithms behind key exchange and signatures. Symmetric encryption and hashes are only weakened: the best known quantum attack halves the effective key length, which leaves 256-bit keys with a wide margin.

  • Stored provider keys, connector secrets and MCP OAuth secrets are encrypted with AES-256-GCM.
  • API keys are stored as HMAC-SHA256 fingerprints, and signed tokens use HMAC-SHA256.

Both stay as they are.

Enterprise licenses are dual-signed

Signatures were the other gap. Self-hosted Enterprise deployments verify a signed license token, and that signature was Ed25519, which a quantum computer could forge.

Licenses issued from December 2026 carry two signatures over the same content: Ed25519 and ML-DSA-65, the lattice signature NIST standardized as FIPS 204. Both must verify. The pinned public key decides the algorithm, never the token, so a dual-signed key cannot be downgraded to its Ed25519 half.

Older Ed25519-only licenses keep working through their expiry, but stop on 1 January 2028 if that comes first. A forged classical license stops being accepted on a fixed date, whatever expiry it claims. If your license runs past that date, ask sales for a replacement.

A daily check keeps it from regressing

A TLS policy is one load balancer setting away from silently falling back. So the repository has a check, scripts/check-post-quantum-tls.mjs, and a workflow that runs it every day at 06:45 UTC.

It connects to each of our hosts offering only hybrid groups. The job fails when a host answers a classical handshake but refuses a hybrid one on all three attempts. An unreachable host only warns, so a network blip does not page anyone. Provider endpoints are reported, not enforced, since their TLS configuration is theirs to change.

Run it against your own hosts with Node.js 24 or later:

PQ_TLS_HOSTS=gateway.example.com,api.example.com node scripts/check-post-quantum-tls.mjs
Enter fullscreen mode Exit fullscreen mode

What is not post-quantum yet

Three things, and we would rather list them than claim "quantum-safe":

  • Certificates. Public TLS certificates are still RSA or ECDSA, ours included. This affects identity at connection time, not recorded traffic.
  • Google-signed tokens. Google signs service-account tokens and Cloud Storage URLs with RSA and accepts nothing else.
  • Seven provider endpoints. Traffic to a provider without a hybrid group uses a classical key exchange unless you refuse it with the setting above.

Redis and Postgres carry no TLS in our deployment by design. They run on a private network that only our services reach, so there is no traffic in transit to record. If your Postgres has to cross a network you do not control, note that Postgres 18 does not offer the hybrid group by default; the self-host guide has the ssl_groups line to add.

How to do the same in your stack

  1. Upgrade the runtime before writing any code. OpenSSL 3.5 and Node.js 24 offer X25519MLKEM768 by default.
  2. Check what your edge negotiates. Most large CDNs and cloud load balancers support the hybrid group, but only on TLS 1.3.
  3. Leave AES-256 and HMAC-SHA256 alone. Spend the effort on key exchange first, then on long-lived signatures.
  4. Sign anything long-lived with two algorithms, and put an end date on the classical-only version.
  5. Write the check down as code and run it daily. A claim nobody tests decays.

The changes are in two public pull requests: post-quantum crypto and the Airside requirement.



Originally published on the LLM Gateway blog.

Top comments (0)