# Post-Quantum Cryptography

AISIX AI Gateway enables hybrid post-quantum TLS 1.3 key exchange (`X25519MLKEM768`) by default across both the Rust Data Plane and the Go Control Plane (AISIX Enterprise and AISIX Cloud). This protects sensitive prompts, responses, and API credentials in transit against Harvest-Now, Decrypt-Later (HNDL) attacks while automatically falling back to classical key exchange for peers that do not support PQC.

For a cross-product comparison across AISIX AI Gateway, API7 Enterprise, and Apache APISIX, see the [Post-Quantum Cryptography (PQC) Overview](https://docs.api7.ai/post-quantum-cryptography.md).

## Cryptographic Stack[​](#cryptographic-stack "Direct link to Cryptographic Stack")

* **AISIX Data Plane (Rust)**: Built on `rustls` (`0.23.x`) with the `aws-lc-rs` cryptographic provider installed process-wide and `prefer-post-quantum` enabled by default. The default TLS 1.3 key-exchange preference order places `X25519MLKEM768` first, followed by classical `X25519`, `secp256r1`, and `secp384r1`.
* **AISIX Enterprise and AISIX Cloud Control Plane (Go)**: Built on Go's standard `crypto/tls` (Go 1.24+), which enables `X25519MLKEM768` (and in Go 1.26+, `SecP256r1MLKEM768` and `SecP384r1MLKEM1024`) by default for TLS 1.3 connections.

## Connection Coverage by Hop[​](#connection-coverage-by-hop "Direct link to Connection Coverage by Hop")

| Connection Hop                                                                                   | TLS Implementation                                | Hybrid PQC Key Exchange             | Notes                                                                                                                                                                                              |
| ------------------------------------------------------------------------------------------------ | ------------------------------------------------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Caller to AISIX Proxy or Admin Listener (`proxy.tls`, `proxy.listeners[*].tls`, `admin.tls`)** | `rustls` (`aws-lc-rs`)                            | `X25519MLKEM768` (default)          | Active whenever TLS is terminated on AISIX. Classical TLS 1.3 and TLS 1.2 clients fall back automatically.                                                                                         |
| **AISIX to Upstream AI Providers, MCP/A2A Servers, Guardrails, OIDC, and Exporters**             | `rustls` (`aws-lc-rs`)                            | `X25519MLKEM768` (default)          | Covers HTTP providers, Realtime WebSockets, Amazon Bedrock, OTLP/SLS/Datadog, and object-store exporters. Negotiates `X25519MLKEM768` with PQC-capable providers and falls back cleanly otherwise. |
| **AISIX to etcd (`etcd.tls`) and Redis (`rediss://`)**                                           | `rustls` (`aws-lc-rs`) via `tonic` and `redis-rs` | `X25519MLKEM768` offered by default | Negotiated when the etcd or Redis server supports TLS 1.3 with `X25519MLKEM768`; otherwise falls back to classical curves.                                                                         |
| **AISIX Data Plane to AISIX Enterprise / Cloud Control Plane (mTLS)**                            | `rustls` (`aws-lc-rs`) ↔ Go `crypto/tls`          | `X25519MLKEM768` (default)          | Both ends support hybrid ML-KEM key exchange over TLS 1.3 out of the box.                                                                                                                          |

## Scope[​](#scope "Direct link to Scope")

* **TLS 1.3 Key Exchange**: Default PQC support protects TLS 1.3 key agreement with hybrid `X25519MLKEM768` (NIST FIPS 203 `ML-KEM-768` combined with `X25519`) against HNDL attacks.
* **Certificates and Signatures**: Classical ECDSA and RSA certificates are used for TLS authentication across AISIX OSS, AISIX Enterprise, and AISIX Cloud while post-quantum digital signature standards (NIST FIPS 204 `ML-DSA` and FIPS 205 `SLH-DSA`) mature across public certificate authorities and client ecosystems.

## Verify PQC Negotiation[​](#verify-pqc-negotiation "Direct link to Verify PQC Negotiation")

### Verify Inbound Listener TLS[​](#verify-inbound-listener-tls "Direct link to Verify Inbound Listener TLS")

From a machine with **OpenSSL 3.5 or newer**, run `s_client` against your AISIX HTTPS listener:

```
openssl s_client -connect "<aisix-host>:3443" -servername "<your-domain>" -tls1_3 -groups X25519MLKEM768:X25519 -brief </dev/null
```

Expected output includes:

```
Protocol version: TLSv1.3

Ciphersuite: TLS_AES_256_GCM_SHA384

Negotiated TLS1.3 group: X25519MLKEM768
```

Verify graceful fallback for a classical-only client:

```
openssl s_client -connect "<aisix-host>:3443" -servername "<your-domain>" -tls1_3 -groups X25519 -brief </dev/null
```

Expected output includes:

```
Protocol version: TLSv1.3

Peer Temp Key: X25519, 253 bits
```

### Verify Outbound Provider Connections[​](#verify-outbound-provider-connections "Direct link to Verify Outbound Provider Connections")

AISIX automatically offers `X25519MLKEM768` first on outbound TLS 1.3 handshakes to AI providers and self-hosted model servers. To confirm whether a specific upstream negotiates hybrid PQC, check the upstream TLS server logs (for example, `$ssl_curve` on an NGINX reverse proxy or `ConnectionState.CurveID` on a Go server) or test the upstream directly with OpenSSL 3.5+:

```
openssl s_client -connect "<provider-host>:443" -servername "<provider-host>" -tls1_3 -groups X25519MLKEM768:X25519 -brief </dev/null
```

## Compatibility and Troubleshooting[​](#compatibility-and-troubleshooting "Direct link to Compatibility and Troubleshooting")

Because `X25519MLKEM768` adds roughly 1.1 KB to the TLS 1.3 `ClientHello`, the handshake message often spans two TCP packets. Most public cloud LLM APIs handle this transparently, but older on-premises firewalls, transparent proxies, or DPI appliances sitting in front of self-hosted inference servers may drop or reset fragmented `ClientHello` handshakes.

If requests to an internal HTTPS model server stall or fail during TLS setup:

1. Run the OpenSSL `s_client` check above from the AISIX host against the model server with `-groups X25519MLKEM768` and compare it with `-groups X25519`.
2. If only `X25519MLKEM768` stalls or resets, inspect intermediate firewalls, load balancers, or SSL inspection proxies on that path and enable support for multi-packet TLS 1.3 `ClientHello` messages.
3. Confirm that TLS termination in front of AISIX (such as an ingress controller or cloud load balancer) also supports `X25519MLKEM768` if you want end-to-end PQC protection from callers through the edge to AISIX.

For self-hosted AISIX Enterprise Control Plane services (Go), you can set `GODEBUG=tlsmlkem=0,tlssecpmlkem=0` temporarily if a legacy network appliance blocks outbound Control Plane TLS handshakes.

## Next Steps[​](#next-steps "Direct link to Next Steps")

* Configure listener, upstream, etcd, and control-plane certificates in [TLS and mTLS](https://docs.api7.ai/ai-gateway/deployment/tls-and-mtls.md).
* Review network boundaries and hardening in [Network and Security](https://docs.api7.ai/ai-gateway/deployment/network-and-security.md).
* Read the [Post-Quantum Cryptography (PQC) Overview](https://docs.api7.ai/post-quantum-cryptography.md) for standards and cross-product comparison.
