From 52babc0b930a4e683af5f7b81727d51b9563160a Mon Sep 17 00:00:00 2001 From: Arul Sujith S Date: Wed, 29 Jul 2026 15:14:50 +0530 Subject: [PATCH] fix(sha3): rename features to incremental and refine test gating --- .github/workflows/libcrux-build-test.yml | 6 +++++ .github/workflows/mlkem-build-test.yml | 8 +++--- .github/workflows/workspace-test.yml | 3 +++ CHANGELOG.md | 1 + crates/algorithms/kmac/Cargo.toml | 2 +- crates/algorithms/sha3/CHANGELOG.md | 3 +++ crates/algorithms/sha3/Cargo.toml | 1 + crates/algorithms/sha3/benches/sha3.rs | 1 + crates/algorithms/sha3/hax.sh | 1 + crates/algorithms/sha3/src/avx2.rs | 1 + .../algorithms/sha3/src/generic_keccak/xof.rs | 27 +++++++++---------- crates/algorithms/sha3/src/neon.rs | 1 + crates/algorithms/sha3/src/portable.rs | 1 + crates/algorithms/sha3/src/proof_utils.rs | 2 ++ crates/algorithms/sha3/src/simd/portable.rs | 4 +-- crates/algorithms/sha3/tests/avx2.rs | 2 +- crates/algorithms/sha3/tests/cavp.rs | 13 +++++---- crates/algorithms/sha3/tests/cross_spec.rs | 2 +- crates/algorithms/sha3/tests/neon.rs | 2 +- crates/algorithms/sha3/tests/portable.rs | 23 ++++++++++++++-- crates/sys/platform/src/x86.rs | 4 +-- libcrux-ml-dsa/Cargo.toml | 2 +- libcrux-ml-kem/Cargo.toml | 2 +- libcrux-ml-kem/src/mlkem.rs | 7 +++-- 24 files changed, 80 insertions(+), 39 deletions(-) diff --git a/.github/workflows/libcrux-build-test.yml b/.github/workflows/libcrux-build-test.yml index d32a8dfb5c..cadee66cb2 100644 --- a/.github/workflows/libcrux-build-test.yml +++ b/.github/workflows/libcrux-build-test.yml @@ -115,9 +115,15 @@ jobs: - name: 🏃🏻‍♀️ Test run: cargo test --verbose $RUST_TARGET_FLAG + - name: 🏃🏻‍♀️ Test SHA3 Incremental + run: cargo test -p libcrux-sha3 --features incremental --verbose $RUST_TARGET_FLAG + - name: 🏃🏻‍♀️ Test Release run: cargo test --verbose --release $RUST_TARGET_FLAG + - name: 🏃🏻‍♀️ Test SHA3 Incremental Release + run: cargo test -p libcrux-sha3 --features incremental --verbose --release $RUST_TARGET_FLAG + libcrux-build-test-status: if: ${{ always() }} needs: [build] diff --git a/.github/workflows/mlkem-build-test.yml b/.github/workflows/mlkem-build-test.yml index 9f735f71e2..8bfd0ce7ef 100644 --- a/.github/workflows/mlkem-build-test.yml +++ b/.github/workflows/mlkem-build-test.yml @@ -104,25 +104,25 @@ jobs: working-directory: crates/algorithms/sha3 run: | cargo clean - cargo test --verbose $RUST_TARGET_FLAG + cargo test --features incremental --verbose $RUST_TARGET_FLAG - name: 🏃🏻‍♀️ SHA3 Test Release working-directory: crates/algorithms/sha3 run: | cargo clean - cargo test --release --verbose $RUST_TARGET_FLAG + cargo test --features incremental --release --verbose $RUST_TARGET_FLAG - name: 🏃🏻‍♀️ SHA3 Test Portable working-directory: crates/algorithms/sha3 run: | cargo clean - LIBCRUX_DISABLE_SIMD128=1 LIBCRUX_DISABLE_SIMD256=1 cargo test --verbose $RUST_TARGET_FLAG + LIBCRUX_DISABLE_SIMD128=1 LIBCRUX_DISABLE_SIMD256=1 cargo test --features incremental --verbose $RUST_TARGET_FLAG - name: 🏃🏻‍♀️ SHA3 Test Portable Release working-directory: crates/algorithms/sha3 run: | cargo clean - LIBCRUX_DISABLE_SIMD128=1 LIBCRUX_DISABLE_SIMD256=1 cargo test --verbose --release $RUST_TARGET_FLAG + LIBCRUX_DISABLE_SIMD128=1 LIBCRUX_DISABLE_SIMD256=1 cargo test --features incremental --verbose --release $RUST_TARGET_FLAG # Test ... diff --git a/.github/workflows/workspace-test.yml b/.github/workflows/workspace-test.yml index 980bf85558..947f1bb77c 100644 --- a/.github/workflows/workspace-test.yml +++ b/.github/workflows/workspace-test.yml @@ -33,6 +33,9 @@ jobs: - name: Run workspace tests run: cargo nextest run --workspace --no-fail-fast -- --skip _mm256_bsrli_epi128 + - name: Run libcrux-sha3 incremental tests + run: cargo nextest run -p libcrux-sha3 --features incremental --no-fail-fast + - name: Run workspace doctests run: cargo test --doc --workspace --no-fail-fast diff --git a/CHANGELOG.md b/CHANGELOG.md index f2f641a9d6..5ecc2a98b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- (libcrux-sha3) [#1532](https://github.com/celabshq/libcrux/issues/1532): Put ML-KEM/ML-DSA specific SHA3 APIs behind optional features - [#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` - [#1505](https://github.com/celabshq/libcrux/pull/1505): Update dependency: `hpke-rs` - (libcrux-traits, libcrux-sha3, libcrux-sha2, libcrux-blake2) [#1493](https://github.com/celabshq/libcrux/pull/1493): `finish` methods on digest traits consume the hasher diff --git a/crates/algorithms/kmac/Cargo.toml b/crates/algorithms/kmac/Cargo.toml index aa3703a4bd..b4a11874c1 100644 --- a/crates/algorithms/kmac/Cargo.toml +++ b/crates/algorithms/kmac/Cargo.toml @@ -15,7 +15,7 @@ path = "src/kmac.rs" [dependencies] hax-lib.workspace = true -libcrux-sha3.workspace = true +libcrux-sha3 = { workspace = true, features = ["incremental"] } [dev-dependencies] libcrux-kats = { workspace = true, features = ["kmac"] } diff --git a/crates/algorithms/sha3/CHANGELOG.md b/crates/algorithms/sha3/CHANGELOG.md index e7bbd3bc45..ed777eeeb4 100644 --- a/crates/algorithms/sha3/CHANGELOG.md +++ b/crates/algorithms/sha3/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. +## [Unreleased] +- (libcrux-sha3) [#1532](https://github.com/celabshq/libcrux/issues/1532): Put ML-KEM/ML-DSA specific SHA3 APIs behind optional features + The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). diff --git a/crates/algorithms/sha3/Cargo.toml b/crates/algorithms/sha3/Cargo.toml index efa4ded523..da8dc3ff57 100644 --- a/crates/algorithms/sha3/Cargo.toml +++ b/crates/algorithms/sha3/Cargo.toml @@ -22,6 +22,7 @@ hax-lib.workspace = true [features] simd128 = ["libcrux-intrinsics/simd128"] simd256 = ["libcrux-intrinsics/simd256"] +incremental = [] [[bench]] name = "sha3" diff --git a/crates/algorithms/sha3/benches/sha3.rs b/crates/algorithms/sha3/benches/sha3.rs index 1ca87f0d65..b3b1fc6e08 100644 --- a/crates/algorithms/sha3/benches/sha3.rs +++ b/crates/algorithms/sha3/benches/sha3.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "incremental")] #![allow(non_snake_case)] use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion, Throughput}; use libcrux_sha3::{portable::incremental::Xof, *}; diff --git a/crates/algorithms/sha3/hax.sh b/crates/algorithms/sha3/hax.sh index 596c036ccd..f084263512 100755 --- a/crates/algorithms/sha3/hax.sh +++ b/crates/algorithms/sha3/hax.sh @@ -23,6 +23,7 @@ function extract_all() { # result is a fixed-length `t_Array u8 v_LEN`. An interface would erase that to # `t_Slice u8` with a trivial postcondition and the subtyping check fails. extract crates/algorithms/sha3 \ + --features incremental \ into -i "+**" \ -i "-**::avx2::**" \ -i "-**::arm64::**" \ diff --git a/crates/algorithms/sha3/src/avx2.rs b/crates/algorithms/sha3/src/avx2.rs index 79df89d937..440c9335af 100644 --- a/crates/algorithms/sha3/src/avx2.rs +++ b/crates/algorithms/sha3/src/avx2.rs @@ -1,4 +1,5 @@ /// Performing 4 operations in parallel +#[cfg(feature = "incremental")] pub mod x4 { use crate::generic_keccak::simd256::keccak4; diff --git a/crates/algorithms/sha3/src/generic_keccak/xof.rs b/crates/algorithms/sha3/src/generic_keccak/xof.rs index 4fcf59bea1..6b66aedc21 100644 --- a/crates/algorithms/sha3/src/generic_keccak/xof.rs +++ b/crates/algorithms/sha3/src/generic_keccak/xof.rs @@ -153,14 +153,14 @@ impl> KeccakXofState<1, RATE, STATE> { self.inner.squeeze::(out, out_offset, RATE); #[cfg(hax)] - let self_buf_len = self.buf_len; + let _self_buf_len = self.buf_len; #[cfg(hax)] - let self_squeeze_pos = self.squeeze_pos; + let _self_squeeze_pos = self.squeeze_pos; // Apply f then extract for each subsequent full block. for i in 1..blocks { hax_lib::loop_invariant!(|_: usize| out.len() == out_len - && self_buf_len == self.buf_len - && self_squeeze_pos == self.squeeze_pos); + && _self_buf_len == self.buf_len + && _self_squeeze_pos == self.squeeze_pos); #[cfg(hax)] hax_lib::assert!( out_offset.to_int() + i.to_int() * RATE.to_int() <= out.len().to_int() diff --git a/crates/algorithms/sha3/src/neon.rs b/crates/algorithms/sha3/src/neon.rs index 3d103bbf9a..a783609979 100644 --- a/crates/algorithms/sha3/src/neon.rs +++ b/crates/algorithms/sha3/src/neon.rs @@ -49,6 +49,7 @@ pub fn shake256(digest: &mut [u8; LEN], data: &[u8]) { } /// Performing 2 operations in parallel +#[cfg(feature = "incremental")] pub mod x2 { use super::*; diff --git a/crates/algorithms/sha3/src/portable.rs b/crates/algorithms/sha3/src/portable.rs index 8df49ebf6c..5827b654d0 100644 --- a/crates/algorithms/sha3/src/portable.rs +++ b/crates/algorithms/sha3/src/portable.rs @@ -48,4 +48,5 @@ pub fn shake256(digest: &mut [u8], data: &[u8]) { } /// An incremental API for SHAKE +#[cfg(feature = "incremental")] pub mod incremental; diff --git a/crates/algorithms/sha3/src/proof_utils.rs b/crates/algorithms/sha3/src/proof_utils.rs index 3de38aa246..74ed7acc61 100644 --- a/crates/algorithms/sha3/src/proof_utils.rs +++ b/crates/algorithms/sha3/src/proof_utils.rs @@ -12,6 +12,7 @@ pub(crate) fn valid_rate(rate: usize) -> bool { rate != 0 && rate <= 200 && rate % 8 == 0 && (rate % 32 == 8 || rate % 32 == 16) } +#[allow(unused_imports)] pub(crate) use lemmas::{lemma_div_mul_mod, lemma_mul_succ_le}; mod lemmas { @@ -37,6 +38,7 @@ let lemma_div_mul_mod (a b: usize) = () "# )] + #[allow(dead_code)] pub(crate) fn lemma_div_mul_mod(_a: usize, _b: usize) {} /// Lemma proving multiplication bounds for successive elements. diff --git a/crates/algorithms/sha3/src/simd/portable.rs b/crates/algorithms/sha3/src/simd/portable.rs index fa57b797f0..fac6247967 100644 --- a/crates/algorithms/sha3/src/simd/portable.rs +++ b/crates/algorithms/sha3/src/simd/portable.rs @@ -121,10 +121,10 @@ pub(crate) fn store_block( let octets = len / 8; #[cfg(hax)] - let out_len = out.len(); // ghost variable + let _out_len = out.len(); // ghost variable for i in 0..octets { - hax_lib::loop_invariant!(|i: usize| out.len() == out_len); + hax_lib::loop_invariant!(|i: usize| out.len() == _out_len); let bytes = get_ij(s, i / 5, i % 5).to_le_bytes(); let out_pos = start + 8 * i; diff --git a/crates/algorithms/sha3/tests/avx2.rs b/crates/algorithms/sha3/tests/avx2.rs index 359eefa168..1535d7d2e7 100644 --- a/crates/algorithms/sha3/tests/avx2.rs +++ b/crates/algorithms/sha3/tests/avx2.rs @@ -1,4 +1,4 @@ -#![cfg(feature = "simd256")] +#![cfg(all(feature = "simd256", feature = "incremental"))] mod test_vectors; diff --git a/crates/algorithms/sha3/tests/cavp.rs b/crates/algorithms/sha3/tests/cavp.rs index 80bb939ccc..a138d8e895 100644 --- a/crates/algorithms/sha3/tests/cavp.rs +++ b/crates/algorithms/sha3/tests/cavp.rs @@ -137,6 +137,7 @@ shake_vo_test!( shake256_ema ); +#[cfg(feature = "incremental")] macro_rules! shake_vo_test_incremental { ($name:ident, $kats_fn:path, $shake:ty) => { #[test] @@ -159,11 +160,13 @@ macro_rules! shake_vo_test_incremental { }; } +#[cfg(feature = "incremental")] shake_vo_test_incremental!( SHAKE128VariableOut_incremental, libcrux_kats::sha3::shake128_variable_out, libcrux_sha3::portable::incremental::Shake128Xof ); +#[cfg(feature = "incremental")] shake_vo_test_incremental!( SHAKE256VariableOut_incremental, libcrux_kats::sha3::shake256_variable_out, @@ -241,7 +244,7 @@ sha3_neon_test!( macro_rules! shake128_neon_test { ($test_name:ident, $kats_fn:path) => { #[test] - #[cfg(feature = "simd128")] + #[cfg(all(feature = "simd128", feature = "incremental"))] #[allow(non_snake_case)] fn $test_name() { let _ = pretty_env_logger::try_init(); @@ -270,7 +273,7 @@ shake128_neon_test!(neon_SHAKE128LongMsg, libcrux_kats::sha3::shake128_long); macro_rules! shake256_neon_test { ($test_name:ident, $kats_fn:path) => { #[test] - #[cfg(feature = "simd128")] + #[cfg(all(feature = "simd128", feature = "incremental"))] #[allow(non_snake_case)] fn $test_name() { let _ = pretty_env_logger::try_init(); @@ -297,7 +300,7 @@ shake256_neon_test!(neon_SHAKE256LongMsg, libcrux_kats::sha3::shake256_long); macro_rules! shake256_vo_neon_test { ($test_name:ident, $kats_fn:path) => { #[test] - #[cfg(feature = "simd128")] + #[cfg(all(feature = "simd128", feature = "incremental"))] #[allow(non_snake_case)] fn $test_name() { let _ = pretty_env_logger::try_init(); @@ -326,7 +329,7 @@ shake256_vo_neon_test!( macro_rules! shake256_avx2_test { ($test_name:ident, $kats_fn:path) => { #[test] - #[cfg(feature = "simd256")] + #[cfg(all(feature = "simd256", feature = "incremental"))] #[allow(non_snake_case)] fn $test_name() { let _ = pretty_env_logger::try_init(); @@ -359,7 +362,7 @@ shake256_avx2_test!(avx2_SHAKE256LongMsg, libcrux_kats::sha3::shake256_long); macro_rules! shake256_vo_avx2_test { ($test_name:ident, $kats_fn:path) => { #[test] - #[cfg(feature = "simd256")] + #[cfg(all(feature = "simd256", feature = "incremental"))] #[allow(non_snake_case)] fn $test_name() { let _ = pretty_env_logger::try_init(); diff --git a/crates/algorithms/sha3/tests/cross_spec.rs b/crates/algorithms/sha3/tests/cross_spec.rs index 33f225c012..cf86acb57f 100644 --- a/crates/algorithms/sha3/tests/cross_spec.rs +++ b/crates/algorithms/sha3/tests/cross_spec.rs @@ -368,7 +368,7 @@ mod neon_cross_spec { // AVX2 (simd256) — cross-spec via x4 incremental API // ========================================================================= -#[cfg(feature = "simd256")] +#[cfg(all(feature = "simd256", feature = "incremental"))] mod avx2_cross_spec { #[test] fn avx2_x4_shake256_matches_spec() { diff --git a/crates/algorithms/sha3/tests/neon.rs b/crates/algorithms/sha3/tests/neon.rs index 0374b57ac2..057c752999 100644 --- a/crates/algorithms/sha3/tests/neon.rs +++ b/crates/algorithms/sha3/tests/neon.rs @@ -1,4 +1,4 @@ -#![cfg(feature = "simd128")] +#![cfg(all(feature = "simd128", feature = "incremental"))] mod test_vectors; diff --git a/crates/algorithms/sha3/tests/portable.rs b/crates/algorithms/sha3/tests/portable.rs index 464948126b..3354c21b24 100644 --- a/crates/algorithms/sha3/tests/portable.rs +++ b/crates/algorithms/sha3/tests/portable.rs @@ -2,8 +2,10 @@ mod test_vectors; // Portable implementation tests use crate::test_vectors::{DIGEST_LEN, DIGEST_LEN_SHAKE256, STRING_LEN, STRING_LEN_SHAKE256}; -use libcrux_sha3::portable::incremental::Xof; -use libcrux_sha3::portable::{incremental, sha224, sha256, sha384, sha512, shake128, shake256}; +use libcrux_sha3::portable::{sha224, sha256, sha384, sha512, shake128, shake256}; + +#[cfg(feature = "incremental")] +use libcrux_sha3::portable::incremental::{self, Shake128Xof, Shake256Xof, Xof}; #[test] fn sha3_224() { @@ -110,6 +112,7 @@ fn sha3_shake256() { ); } +#[cfg(feature = "incremental")] #[test] fn sha3_shake128_incremental() { // Test squeezing 1 block (168 bytes) @@ -151,6 +154,7 @@ fn sha3_shake128_incremental() { ); } +#[cfg(feature = "incremental")] #[test] fn sha3_shake256_incremental() { // Test squeezing 1 block (136 bytes for SHAKE256, not 168) @@ -173,6 +177,7 @@ fn sha3_shake256_incremental() { ); } +#[cfg(feature = "incremental")] #[test] fn sha3_shake128_absorb() { let mut state = incremental::Shake128Xof::new(); @@ -205,6 +210,7 @@ fn sha3_shake128_absorb() { assert_eq!(hex::encode(digest), expected); } +#[cfg(feature = "incremental")] #[test] fn sha3_shake256_absorb() { let mut state = incremental::Shake256Xof::new(); @@ -244,6 +250,7 @@ fn sha3_shake256_absorb() { /// keccakf1600() call before the first extraction. This test requests 200 bytes /// (> SHAKE128 RATE of 168) in a single squeeze call and compares against the /// known one-shot output. +#[cfg(feature = "incremental")] #[test] fn bug1_xof_squeeze_skips_first_block_shake128() { // One-shot: known correct output @@ -260,6 +267,7 @@ fn bug1_xof_squeeze_skips_first_block_shake128() { } /// Same regression test for SHAKE256 (RATE = 136). +#[cfg(feature = "incremental")] #[test] fn bug1_xof_squeeze_skips_first_block_shake256() { let mut expected = [0u8; 200]; @@ -275,6 +283,7 @@ fn bug1_xof_squeeze_skips_first_block_shake256() { /// Regression test: multiple squeeze calls should produce the same output as /// a single large squeeze (i.e., streaming squeeze is consistent). +#[cfg(feature = "incremental")] #[test] fn bug1_xof_squeeze_multi_call_consistency() { // Single large squeeze @@ -299,6 +308,7 @@ fn bug1_xof_squeeze_multi_call_consistency() { /// as a single large squeeze. Previously, the XOF only supported RATE-aligned /// chunks because it had no internal buffering for the leftover bytes of a /// partially-consumed squeeze block. +#[cfg(feature = "incremental")] #[test] fn issue_1362_xof_streaming_squeeze_partial_chunks_shake128() { let mut single = [0u8; 600]; @@ -318,6 +328,7 @@ fn issue_1362_xof_streaming_squeeze_partial_chunks_shake128() { } /// Same as the SHAKE128 test, but for SHAKE256 (RATE = 136). +#[cfg(feature = "incremental")] #[test] fn issue_1362_xof_streaming_squeeze_partial_chunks_shake256() { let mut single = [0u8; 500]; @@ -337,6 +348,7 @@ fn issue_1362_xof_streaming_squeeze_partial_chunks_shake256() { /// Single-byte streaming squeeze: stresses the internal buffering by /// forcing a buffer drain on every call. +#[cfg(feature = "incremental")] #[test] fn issue_1362_xof_streaming_squeeze_byte_at_a_time_shake128() { let mut single = [0u8; 350]; // > 2 * RATE so we cross block boundaries @@ -352,6 +364,7 @@ fn issue_1362_xof_streaming_squeeze_byte_at_a_time_shake128() { assert_eq!(single, multi); } +#[cfg(feature = "incremental")] #[test] fn issue_1362_xof_streaming_squeeze_byte_at_a_time_shake256() { let mut single = [0u8; 350]; // > 2 * RATE so we cross block boundaries @@ -369,6 +382,7 @@ fn issue_1362_xof_streaming_squeeze_byte_at_a_time_shake256() { /// Squeeze that crosses a block boundary inside one call after a previous /// partial squeeze: drain leftover, then extract more than one further block. +#[cfg(feature = "incremental")] #[test] fn issue_1362_xof_squeeze_crosses_block_boundary_after_partial_drain_shake128() { let mut single = [0u8; 400]; @@ -386,6 +400,7 @@ fn issue_1362_xof_squeeze_crosses_block_boundary_after_partial_drain_shake128() assert_eq!(single, multi); } +#[cfg(feature = "incremental")] #[test] fn issue_1362_xof_squeeze_crosses_block_boundary_after_partial_drain_shake256() { let mut single = [0u8; 400]; @@ -400,6 +415,7 @@ fn issue_1362_xof_squeeze_crosses_block_boundary_after_partial_drain_shake256() assert_eq!(single, multi); } +#[cfg(feature = "incremental")] #[test] fn issue_1362_xof_squeeze_empty_outputs_shake128() { let mut single = [0u8; 400]; @@ -416,6 +432,7 @@ fn issue_1362_xof_squeeze_empty_outputs_shake128() { assert_eq!(single, multi); } +#[cfg(feature = "incremental")] #[test] fn issue_1362_xof_squeeze_empty_outputs_shake256() { let mut single = [0u8; 400]; @@ -432,6 +449,7 @@ fn issue_1362_xof_squeeze_empty_outputs_shake256() { assert_eq!(single, multi); } +#[cfg(feature = "incremental")] #[test] fn issue_1362_xof_start_with_empty_squeeze_shake128() { let mut single = [0u8; 400]; @@ -448,6 +466,7 @@ fn issue_1362_xof_start_with_empty_squeeze_shake128() { assert_eq!(single, multi); } +#[cfg(feature = "incremental")] #[test] fn issue_1362_xof_start_with_empty_squeeze_shake256() { let mut single = [0u8; 400]; diff --git a/crates/sys/platform/src/x86.rs b/crates/sys/platform/src/x86.rs index 0e5a0d2f5c..2af526d306 100644 --- a/crates/sys/platform/src/x86.rs +++ b/crates/sys/platform/src/x86.rs @@ -3,9 +3,9 @@ #![allow(non_upper_case_globals)] #[cfg(target_arch = "x86")] -use core::arch::x86::{__cpuid, __cpuid_count, CpuidResult}; +use core::arch::x86::{CpuidResult, __cpuid, __cpuid_count}; #[cfg(target_arch = "x86_64")] -use core::arch::x86_64::{__cpuid, __cpuid_count, CpuidResult}; +use core::arch::x86_64::{CpuidResult, __cpuid, __cpuid_count}; use core::sync::atomic::{AtomicBool, Ordering}; #[allow(non_camel_case_types)] diff --git a/libcrux-ml-dsa/Cargo.toml b/libcrux-ml-dsa/Cargo.toml index 7fa8c51924..9c5009a22e 100644 --- a/libcrux-ml-dsa/Cargo.toml +++ b/libcrux-ml-dsa/Cargo.toml @@ -26,7 +26,7 @@ bench = false # so libtest doesn't eat the arguments to criterion # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -libcrux-sha3.workspace = true +libcrux-sha3 = { workspace = true, features = ["incremental"] } libcrux-intrinsics.workspace = true libcrux-platform.workspace = true libcrux-macros.workspace = true diff --git a/libcrux-ml-kem/Cargo.toml b/libcrux-ml-kem/Cargo.toml index 720372da5f..35ad116e88 100644 --- a/libcrux-ml-kem/Cargo.toml +++ b/libcrux-ml-kem/Cargo.toml @@ -24,7 +24,7 @@ bench = false # so libtest doesn't eat the arguments to criterion [dependencies] rand = { version = "0.10", optional = true, default-features = false } libcrux-platform.workspace = true -libcrux-sha3.workspace = true +libcrux-sha3 = { workspace = true, features = ["incremental"] } libcrux-intrinsics.workspace = true libcrux-secrets.workspace = true libcrux-traits.workspace = true diff --git a/libcrux-ml-kem/src/mlkem.rs b/libcrux-ml-kem/src/mlkem.rs index c3aca77ebb..116c4b8db6 100644 --- a/libcrux-ml-kem/src/mlkem.rs +++ b/libcrux-ml-kem/src/mlkem.rs @@ -158,7 +158,7 @@ macro_rules! impl_incr_key_size { } #[cfg(all(not(eurydice), feature = "rand"))] - use ::rand::{CryptoRng, RngCore}; + use ::rand::{CryptoRng, Rng}; impl KeyPairBytes { /// Generate a new key pair. @@ -174,7 +174,7 @@ macro_rules! impl_incr_key_size { /// Generate a new key pair. /// This uses unpacked keys and does not compress the keys. #[cfg(all(not(eurydice), feature = "rand"))] - pub fn generate(rng: &mut (impl RngCore + CryptoRng)) -> Self { + pub fn generate(rng: &mut (impl Rng + CryptoRng)) -> Self { let mut randomness = [0u8; KEY_GENERATION_SEED_SIZE]; rng.fill_bytes(&mut randomness); let mut out = Self { @@ -248,7 +248,7 @@ macro_rules! impl_incr_key_size { /// Generate a new key pair. /// This uses unpacked keys and does not compress the keys. #[cfg(all(not(eurydice), feature = "rand"))] - pub fn generate(rng: &mut (impl RngCore + CryptoRng)) -> Self { + pub fn generate(rng: &mut (impl Rng + CryptoRng)) -> Self { let mut randomness = [0u8; KEY_GENERATION_SEED_SIZE]; rng.fill_bytes(&mut randomness); let mut out = Self { @@ -369,7 +369,6 @@ macro_rules! impl_incr_key_size { #[cfg(feature = "rand")] pub mod rand { use super::*; - use ::rand::TryRngCore; /// Encapsulate the first part of the ciphertext. ///