Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .changeset/post-quantum-key-share-first.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"@cipherstash/auth": patch
"@cipherstash/protect-ffi": patch
---

The native Node builds now offer a hybrid post-quantum key exchange first when
they connect to CTS and ZeroKMS. The ClientHello carries an `X25519MLKEM768`
key share beside the X25519 one. A server that chooses the hybrid group, which
the CTS and ZeroKMS load balancers will support, can agree on it in one round
trip. That protects traffic recorded today from being decrypted later by a
quantum computer. A server that prefers X25519, or does not support the hybrid
group, uses the X25519 share, as before.

Before this change the hybrid group was supported but listed last, with no key
share sent for it. Depending on the server, that gave either a classical key
exchange or an extra round trip on the first connection to each server. The WASM builds are
unchanged: they connect through the runtime's `fetch`, and its TLS.
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ reqwest = { version = "0.13", default-features = false, features = [
# verifier) and by stack-kms. They must stay the versions reqwest resolves:
# `tls_backend_preconfigured` recognises a `ClientConfig` only from the
# rustls reqwest itself links.
rustls = { version = "0.23", default-features = false, features = ["std", "tls12", "aws_lc_rs"] }
# `prefer-post-quantum` puts the hybrid group X25519MLKEM768 first in
# aws-lc-rs's key exchange order, so the ClientHello carries an X25519MLKEM768
# and an X25519 key share. A server that chooses the hybrid group can agree on
# it without a HelloRetryRequest; one that prefers X25519 can still pick it. reqwest turns rustls's default features
# off, which drops it; Cargo unifies features, so naming it here reaches
# reqwest's rustls too.
rustls = { version = "0.23.31", default-features = false, features = ["std", "tls12", "aws_lc_rs", "prefer-post-quantum"] }
Comment thread
coderdan marked this conversation as resolved.
Resolved
rustls-platform-verifier = "0.6"
rustls-webpki = { version = "0.103", default-features = false, features = ["alloc"] }
serde = { version = "1.0", features = ["derive"] }
Expand Down
1 change: 1 addition & 0 deletions languages/typescript/packages/protect-ffi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ zeroize = { version = "1.8", features = ["derive"] }
neon = { version = "1", features = ["serde", "tokio"] }
stack-profile = { version = "=0.42.3" }
tokio = { version = "1", features = ["full"] }
# Named only to turn on `prefer-post-quantum`. cipherstash-client and
# stack-auth reach rustls through reqwest, which turns rustls's default
# features off and so leaves the hybrid post-quantum group X25519MLKEM768 last
# in aws-lc-rs's key exchange order, with no key share sent for it. Cargo
# unifies features, so this puts it first for their requests to CTS and
# ZeroKMS. Native only: on wasm32 the runtime's `fetch` does the TLS.
rustls = { version = "0.23.31", default-features = false, features = ["prefer-post-quantum"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
tokio = { version = "1", default-features = false, features = ["macros", "rt", "sync"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ mod query_op;
#[cfg(target_arch = "wasm32")]
mod wasm;

// rustls is a dependency only for its `prefer-post-quantum` feature (see
// Cargo.toml); nothing calls it directly.
#[cfg(not(target_arch = "wasm32"))]
use rustls as _;

use client_options::NewClientOptions;
#[cfg(not(target_arch = "wasm32"))]
use client_options::{EnsureKeysetOpts, EnsureKeysetResult};
Expand Down Expand Up @@ -4062,3 +4067,22 @@ mod tests {
}
}
}

#[cfg(all(test, not(target_arch = "wasm32")))]
mod tls_tests {
use rustls::NamedGroup;

/// reqwest and stack-auth fall back to this provider when the process has
/// not installed one, and the addon installs none, so its first group is
/// the key share every request to CTS and ZeroKMS opens with.
#[test]
fn default_provider_offers_the_hybrid_post_quantum_group_first() {
let provider = rustls::crypto::aws_lc_rs::default_provider();
let groups: Vec<NamedGroup> = provider.kx_groups.iter().map(|g| g.name()).collect();
assert_eq!(
groups.first(),
Some(&NamedGroup::X25519MLKEM768),
"rustls's `prefer-post-quantum` feature is off; key exchange groups: {groups:?}"
);
}
}
16 changes: 16 additions & 0 deletions packages/stack-auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@

## [Unreleased]

### Features

- The HTTPS client offers the hybrid post-quantum key exchange `X25519MLKEM768`
first. The workspace's rustls dependency now turns on `prefer-post-quantum`,
which moves the group to the front of the aws-lc-rs default provider's order,
so the ClientHello carries an `X25519MLKEM768` key share beside the X25519
one. A server that chooses the hybrid group can agree on it in one round
trip, and a server that prefers X25519 can still choose X25519.
Before, the group was listed last with no key share, so a server that
preferred it asked for a retry on the first connection, and other servers
settled on X25519. It has no effect when the app installs ring or a provider
with its own `kx_groups`. `stack-kms`, which has no changelog of its own, gets
the same change through its `http` feature's rustls dependency.

## [0.43.0] - 2026-10-02


Expand Down
24 changes: 23 additions & 1 deletion packages/stack-auth/src/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ pub(crate) const BLOCKED_SPKIS: &[BlockedSpki] = &[
/// blocklist is refused as a revoked certificate.
///
/// The crypto provider is chosen the way reqwest chooses it: the process
/// default if one is installed, else aws-lc-rs. A preconfigured backend gets
/// default if one is installed, else aws-lc-rs, whose key exchange order
/// starts with the hybrid post-quantum group X25519MLKEM768 (the workspace
/// turns on rustls's `prefer-post-quantum`). A preconfigured backend gets
/// no ALPN from reqwest, so this sets it: `h2` then `http/1.1` when
/// `http2` is true, and only `http/1.1` otherwise. Pass `true` only when the
/// client's reqwest is built with its `http2` feature; a server that
Expand Down Expand Up @@ -539,6 +541,26 @@ mod tests {
assert_eq!(h1.alpn_protocols, vec![b"http/1.1".to_vec()]);
}

/// A connection opens with a key share for the first group, so the hybrid
/// post-quantum group must lead: a server that chooses it can then agree
/// on it in one round trip, and one that prefers X25519 or does not
/// support the hybrid group uses the X25519 share.
#[test]
fn the_hybrid_post_quantum_group_is_offered_first() {
let config = client_config(false).unwrap();
let groups: Vec<rustls::NamedGroup> = config
.crypto_provider()
.kx_groups
.iter()
.map(|g| g.name())
.collect();
assert_eq!(
groups.first(),
Some(&rustls::NamedGroup::X25519MLKEM768),
"rustls's `prefer-post-quantum` feature is off; key exchange groups: {groups:?}"
);
}

/// The config is one reqwest recognises: a rustls version reqwest does
/// not share makes `tls_backend_preconfigured` an unknown backend, and
/// `build` fails.
Expand Down
Loading