Skip to content

Prefer post-quantum TLS key exchange - #1612

Open
epompeii wants to merge 1 commit into
develfrom
u/ep/prefer-post-quantum
Open

epompeii wants to merge 1 commit into
develfrom
u/ep/prefer-post-quantum

Conversation

@epompeii

@epompeii epompeii commented Dec 3, 2026

Copy link
Copy Markdown
Member

Prefer the hybrid post-quantum TLS key exchange X25519MLKEM768 in every Bencher binary that opens TLS connections.

The workspace sets default-features = false on rustls, which turns off its prefer-post-quantum feature. Without it, the aws-lc-rs provider orders its default key exchange groups as X25519, P-256, P-384, and then X25519MLKEM768. The CLI, the runner, and the API server install that default provider, so their TLS clients sent only an X25519 key share. A server that prefers ML-KEM got it only after a HelloRetryRequest, and any other server negotiated X25519.

Change

  • Turn on prefer-post-quantum for the workspace rustls dependency. It moves X25519MLKEM768 to the front of the default groups and changes nothing else.
  • Cargo unifies features only across the packages in one build, and bencher_cli and bencher_api reached rustls only through tokio-rustls. A build of either alone (services/cli in cli.yml, -p bencher_cli in the CLI Dockerfile, cargo install bencher_cli, -p bencher_api) therefore left the feature off. Both now depend on rustls directly and install the provider from it. The API no longer needs tokio-rustls, and the CLI keeps it only for its tests.
  • A changelog line under Pending v0.6.20, and the modified date on all 9 changelog pages.

As a TLS server, rustls picks the group by the client's order, so a self-hosted API server negotiates as before. The changelog line covers outbound requests only.

Proof

Each binary ran against OpenSSL 3.5.10 s_server -trace.

Before After
bencher CLI ClientHello key shares X25519 X25519MLKEM768, then X25519
bencher CLI ServerHello group X25519, or X25519MLKEM768 after a HelloRetryRequest when the server prefers it X25519MLKEM768, no retry
Runner (runner up) same as the CLI before same as the CLI after

A per-package cargo tree -e normal,features -i rustls shows prefer-post-quantum on for bencher_cli, bencher_api, and bencher_runner_cli, which it was not for the first 2 before.

The first ClientHello grows from 252 to 1475 bytes, the same size that current browsers send. Peers without ML-KEM still negotiate X25519.

Checks

  • cargo fmt --check, ./scripts/clippy.sh, cargo check --workspace --all-targets
  • cargo nextest run --all-features --profile ci: 5441 passed, 12 skipped
  • cargo deny --locked check bans licenses sources at 0.20.2
  • Cargo.lock changes only the dependency lists of bencher_api and bencher_cli, with no version changes

Turn on the rustls prefer-post-quantum feature for the workspace, which
moves the hybrid X25519MLKEM768 group to the front of the aws-lc-rs
provider's default key exchange groups. The CLI, the runner, and the API
server install that default provider, so their TLS clients now send an
X25519MLKEM768 key share first and still fall back to X25519 for peers
without it. As a TLS server, rustls follows the client's group order, so
the API server's choice is unchanged.

Cargo unifies features only across the packages in a build, and the CLI
and the API reached rustls only through tokio-rustls, so a build of
either alone left the feature off. Both now depend on rustls directly and
install the provider from it; the API no longer needs tokio-rustls, and
the CLI keeps it only for its tests.
@bencher-cloud

bencher-cloud Bot commented Dec 3, 2026

Copy link
Copy Markdown

🐰 Bencher Report

ProjectBencher
Branchu/ep/prefer-post-quantum
Testbedintel-v1
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
microseconds (µs)
(Result Δ%)
Upper Boundary
microseconds (µs)
(Limit %)
Adapter::Json📈 view plot
🚷 view threshold
5.32 µs
(+1.70%)Baseline: 5.23 µs
5.52 µs
(96.29%)
Adapter::Magic (JSON)📈 view plot
🚷 view threshold
5.16 µs
(+1.75%)Baseline: 5.07 µs
5.39 µs
(95.78%)
Adapter::Magic (Rust)📈 view plot
🚷 view threshold
7.65 µs
(-69.86%)Baseline: 25.37 µs
43.94 µs
(17.40%)
Adapter::Rust📈 view plot
🚷 view threshold
4.57 µs
(+1.75%)Baseline: 4.49 µs
4.77 µs
(95.76%)
Adapter::RustBench📈 view plot
🚷 view threshold
4.54 µs
(+1.37%)Baseline: 4.48 µs
4.75 µs
(95.71%)
🐰 View full continuous benchmarking report in Bencher

@epompeii
epompeii marked this pull request as ready for review December 3, 2026 23:52

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant