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

On this page
  1. The 30-second check
  2. Default key-exchange groups
  3. Fix 1: you're on the ring provider
  4. Fix 2: a custom kx_groups list
  5. Fix 3: an old rustls
  6. Native TLS and OpenSSL bindings
  7. Verify the handshake

Short answer: 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.

The 30-second check

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:

Default key-exchange groups

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

ListGroups, in order
DEFAULT_KX_GROUPSX25519MLKEM768, SECP384R1, X25519, SECP256R1
ALL_KX_GROUPSX25519MLKEM768, 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:

# Cargo.toml
[dependencies]
rustls = { version = "0.23.27", default-features = false, features = ["aws_lc_rs", "std", "tls12"] }
// 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:

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

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 for checking the linked version.

Verify the handshake

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). 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