Skip to content

Commit 6aace21

Browse files
committed
feat(sha3): gate ml-kem and ml-dsa specific APIs behind features (#1532)
1 parent 6929fb5 commit 6aace21

14 files changed

Lines changed: 35 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818

1919
### Changed
2020

21+
- (libcrux-sha3) [#1532](https://github.com/celabshq/libcrux/issues/1532): Put ML-KEM/ML-DSA specific SHA3 APIs behind optional features
2122
- [#1534](https://github.com/celabshq/libcrux/pull/XYZ): Update dependencies: `libcrux-blake2`, `libcrux-sha3`, `libcrux-sha2`, `libcrux-curve25519`, `libcrux-aes`, `libcrux-chacha20poly1305`, `libcrux-ml-dsa`, `libcrux-ml-kem`, `libcrux-rsa`, `libcrux-ed25519`, `libcrux-digest`, `libcrux-hmac`, `libcrux-p256`, `libcrux-aead`, `libcrux-hkdf`, `libcrux-ecdsa`, `libcrux-ecdh`, `libcrux-kem`, `libcrux-psq`, `hpke-rs`
2223
- [#1505](https://github.com/celabshq/libcrux/pull/1505): Update dependency: `hpke-rs`
2324
- (libcrux-traits, libcrux-sha3, libcrux-sha2, libcrux-blake2) [#1493](https://github.com/celabshq/libcrux/pull/1493): `finish` methods on digest traits consume the hasher

crates/algorithms/sha3/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ hax-lib.workspace = true
2222
[features]
2323
simd128 = ["libcrux-intrinsics/simd128"]
2424
simd256 = ["libcrux-intrinsics/simd256"]
25+
mlkem = []
26+
mldsa = []
2527

2628
[[bench]]
2729
name = "sha3"

crates/algorithms/sha3/benches/sha3.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(any(feature = "mlkem", feature = "mldsa"))]
12
#![allow(non_snake_case)]
23
use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion, Throughput};
34
use libcrux_sha3::{portable::incremental::Xof, *};

crates/algorithms/sha3/src/avx2.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/// Performing 4 operations in parallel
2+
#[cfg(any(feature = "mlkem", feature = "mldsa"))]
23
pub mod x4 {
34
use crate::generic_keccak::simd256::keccak4;
45

crates/algorithms/sha3/src/neon.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub fn shake256<const LEN: usize>(digest: &mut [u8; LEN], data: &[u8]) {
4949
}
5050

5151
/// Performing 2 operations in parallel
52+
#[cfg(any(feature = "mlkem", feature = "mldsa"))]
5253
pub mod x2 {
5354
use super::*;
5455

crates/algorithms/sha3/src/portable.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ pub fn shake256(digest: &mut [u8], data: &[u8]) {
4848
}
4949

5050
/// An incremental API for SHAKE
51+
#[cfg(any(feature = "mlkem", feature = "mldsa"))]
5152
pub mod incremental;

crates/algorithms/sha3/tests/avx2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg(feature = "simd256")]
1+
#![cfg(all(feature = "simd256", any(feature = "mlkem", feature = "mldsa")))]
22

33
mod test_vectors;
44

crates/algorithms/sha3/tests/cavp.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(any(feature = "mlkem", feature = "mldsa"))]
12
use libcrux_sha3::*;
23

34
macro_rules! sha3_test {

crates/algorithms/sha3/tests/cross_spec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(any(feature = "mlkem", feature = "mldsa"))]
12
/// Cross-spec tests: verify top-level SHA-3 / SHAKE functions against the
23
/// hacspec specification. Lower-level tests (permutation steps, sponge
34
/// helpers) live as unit tests inside `src/generic_keccak.rs`.

crates/algorithms/sha3/tests/neon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg(feature = "simd128")]
1+
#![cfg(all(feature = "simd128", any(feature = "mlkem", feature = "mldsa")))]
22

33
mod test_vectors;
44

0 commit comments

Comments
 (0)