# Post-quantum TLS in Rust: rustls, aws-lc-rs and X25519MLKEM768

> rustls 0.23.27+ with the aws-lc-rs provider negotiates hybrid X25519MLKEM768 by default. Check your provider, fix ring builds and custom kx_groups, and verify.

Source: https://pqshift.dev/learn/post-quantum-tls-rust · Published 2026-12-04 · Updated 2026-12-04 · pqshift

rustls negotiates the hybrid post-quantum group `X25519MLKEM768` by default when it uses the **aws-lc-rs** crypto provider (the default provider since rustls 0.23), and it puts that group first. It has been on by default since rustls 0.23.27. With the **ring** provider there is no ML-KEM, so you get classical key exchange only. The `rustls-post-quantum` crate is no longer needed for key exchange.

## Which rustls, and which crypto provider?

```bash
cargo tree -i rustls -e features | head -20     # rustls version and enabled features
cargo tree -i aws-lc-rs | head -5                 # is the aws-lc-rs provider in the build?
cargo tree -i ring | head -5                      # is ring (no ML-KEM) the provider instead?
grep -rn "kx_groups\|ring::default_provider\|with_provider" --include=*.rs src/
```

You have hybrid key exchange if all three hold:

- rustls is **0.23.27 or later**,
- the provider is **aws-lc-rs**, not ring,
- and no code overrides `kx_groups` with a classical-only list.

## Default key-exchange groups

From `rustls::crypto::aws_lc_rs` (rustls 0.23.48):

| List | Groups, in order |
|---|---|
| `DEFAULT_KX_GROUPS` | `X25519MLKEM768`, `SECP384R1`, `X25519`, `SECP256R1` |
| `ALL_KX_GROUPS` | `X25519MLKEM768`, `SECP256R1MLKEM768`, `SECP384R1`, `X25519`, `SECP256R1`, `MLKEM768`, `MLKEM1024` |

Pure `MLKEM768` (without X25519) exists but is not enabled by default. That is deliberate: hybrid keeps the classical hedge.

## Fix 1: you're on the ring provider

Crates often pick ring through feature flags: `reqwest` with `rustls-tls-ring`, `tokio-rustls` or `hyper-rustls` with `default-features = false, features = ["ring"]`, or code that calls `rustls::crypto::ring::default_provider().install_default()`. Switch to aws-lc-rs:

```toml
# Cargo.toml
[dependencies]
rustls = { version = "0.23.27", default-features = false, features = ["aws_lc_rs", "std", "tls12"] }
```

```rust
// Once, at startup, if more than one provider is compiled in
rustls::crypto::aws_lc_rs::default_provider()
    .install_default()
    .expect("install aws-lc-rs provider");
```

aws-lc-rs needs a C compiler and CMake at build time (and Go and NASM for some targets). Most CI images have them; minimal `rust:*-slim` and musl images may not.

## Fix 2: a custom kx_groups list

If you build a `CryptoProvider` with your own groups, put the hybrid first and keep classical fallbacks:

```rust
use rustls::crypto::aws_lc_rs::{self as provider, kx_group};

let provider = rustls::crypto::CryptoProvider {
    kx_groups: vec![
        kx_group::X25519MLKEM768, // hybrid post-quantum, TLS 1.3 only
        kx_group::X25519,         // classical fallback
        kx_group::SECP256R1,
    ],
    ..provider::default_provider()
};
let config = rustls::ClientConfig::builder_with_provider(provider.into())
    .with_safe_default_protocol_versions()?
    .with_root_certificates(roots)
    .with_no_client_auth();
```

## Fix 3: an old rustls

```bash
cargo update -p rustls
cargo tree -d | grep rustls      # several rustls versions in one binary?
```

Older libraries may pin their own rustls. Each copy has its own defaults, so check every one. Between 0.23.22 and 0.23.26, the `prefer-post-quantum` feature controlled whether ML-KEM was preferred over classical groups. Before 0.23.22 the `rustls-post-quantum` crate supplied it.

## Native TLS and OpenSSL bindings

Crates built on `native-tls` or the `openssl` crate use the platform library: OpenSSL on Linux, Secure Transport/Network.framework on macOS, SChannel on Windows. On Linux, that means OpenSSL 3.5+ gives you the hybrid group by default. See the [OpenSSL server guide](https://pqshift.dev/learn/post-quantum-tls-nginx) for checking the linked version.

## Verify the handshake

```bash
openssl s_client -connect your-service.example:443 -groups X25519MLKEM768 </dev/null 2>/dev/null | grep -i group
```

For a Rust client, connect it to a server that only accepts the hybrid group (recipe in [How to check if a server uses post-quantum TLS](https://pqshift.dev/learn/test-post-quantum-tls)). If it connects, it offered `X25519MLKEM768`.

## FAQ

### Does rustls support post-quantum key exchange?

Yes. With the aws-lc-rs provider, rustls offers X25519MLKEM768 first by default, since 0.23.27. The ring provider has no ML-KEM.

### Do I still need the rustls-post-quantum crate?

Not for key exchange. ML-KEM moved into rustls in 0.23.22; rustls-post-quantum now only adds experimental ML-DSA support.

## Sources

- [rustls manual: defaults (rustls 0.23.48)](https://docs.rs/crate/rustls/latest/source/src/manual/defaults.rs)
- [rustls aws_lc_rs provider source (DEFAULT_KX_GROUPS, ALL_KX_GROUPS)](https://docs.rs/crate/rustls/latest/source/src/crypto/aws_lc_rs/mod.rs)
- [rustls-post-quantum crate](https://docs.rs/rustls-post-quantum/latest/)
- [Cloudflare: post-quantum support in third-party software](https://developers.cloudflare.com/ssl/post-quantum-cryptography/pqc-support/)
