Skip to content

Commit 6b0bd71

Browse files
committed
Put libcrux-ml-kem behind default feature gate
1 parent bec42bd commit 6b0bd71

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ jobs:
5656
run: cargo build -p graviola
5757
- name: Run tests (debug)
5858
run: cargo test
59+
- name: Run tests (debug, --no-default-features)
60+
run: cargo test --no-default-features
5961

6062
- name: Build (release)
6163
run: cargo build -p graviola --release

rustls-graviola/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ readme = "README.md"
1111

1212
[dependencies]
1313
graviola = { version = "0.3.0", path = "../graviola" }
14-
libcrux-ml-kem = { version = "0.0.6", default-features = false, features = ["mlkem768", "alloc"] }
14+
libcrux-ml-kem = { version = "0.0.6", default-features = false, features = ["mlkem768", "alloc"], optional = true }
1515
rustls = { version = "0.23.18", default-features = false, features = ["std", "tls12"] }
1616

1717
[dev-dependencies]
@@ -24,3 +24,7 @@ hyper-util = { version = "0.1", default-features = false, features = ["server-au
2424
rustls = { version = "0.23.23", default-features = false, features = ["aws-lc-rs", "ring"] }
2525
tokio = { version = "1.0", features = ["io-std", "macros", "net", "rt-multi-thread"] }
2626
tokio-rustls = { version = "0.26", default-features = false }
27+
28+
[features]
29+
default = ["libcrux-ml-kem"]
30+
libcrux-ml-kem = ["dep:libcrux-ml-kem"]

rustls-graviola/src/kx.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
use crypto::SupportedKxGroup;
22
use graviola::key_agreement::{p256, p384, x25519};
3+
use rustls::crypto;
34
use rustls::ffdhe_groups::FfdheGroup;
4-
use rustls::{NamedGroup, crypto};
55

6+
#[cfg(feature = "libcrux-ml-kem")]
67
mod hybrid;
8+
#[cfg(feature = "libcrux-ml-kem")]
79
mod mlkem;
810

911
/// All key exchange algorithms, in order of preference.
1012
pub static ALL_KX_GROUPS: &[&dyn SupportedKxGroup] = &[
13+
#[cfg(feature = "libcrux-ml-kem")]
1114
X25519MLKEM768,
1215
&X25519 as &dyn SupportedKxGroup,
1316
&P256 as &dyn SupportedKxGroup,
@@ -177,6 +180,7 @@ impl crypto::ActiveKeyExchange for ActiveP384 {
177180
}
178181
}
179182

183+
#[cfg(feature = "libcrux-ml-kem")]
180184
pub static X25519MLKEM768: &dyn SupportedKxGroup = &hybrid::Hybrid {
181185
classical: &X25519,
182186
post_quantum: &mlkem::MlKem768,
@@ -186,11 +190,12 @@ pub static X25519MLKEM768: &dyn SupportedKxGroup = &hybrid::Hybrid {
186190
post_quantum_client_share_len: mlkem::MlKem768::ENCAPS_LEN,
187191
post_quantum_server_share_len: mlkem::MlKem768::CIPHERTEXT_LEN,
188192
},
189-
name: NamedGroup::X25519MLKEM768,
193+
name: rustls::NamedGroup::X25519MLKEM768,
190194
};
191195

192196
#[cfg(test)]
193197
mod tests {
198+
use rustls::NamedGroup;
194199
use rustls::ProtocolVersion;
195200

196201
use super::*;

rustls-graviola/tests/pair.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ fn all_suites() {
5858
#[test]
5959
fn all_key_exchanges() {
6060
// X25519MLKEM768 not supported by *ring*
61+
#[cfg(feature = "libcrux-ml-kem")]
6162
for other in [OtherProvider::BaselineAwsLcRs, OtherProvider::SelfTest] {
6263
test_key_exchange(rustls_graviola::kx::X25519MLKEM768, other, KeyType::Rsa2048);
6364
}

0 commit comments

Comments
 (0)