From 6ab0fd8b968acdcdd0344581174110aa75ed65b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9F=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=5BArtyom=20Pavlov=5D?= Date: Thu, 12 Mar 2026 04:29:13 +0300 Subject: [PATCH 1/2] keccak: replace `keccak_soft_compact` configuration flag with `keccak_backend_soft="compact"` --- .github/workflows/keccak.yml | 4 ++-- keccak/Cargo.toml | 2 +- keccak/src/backends/soft.rs | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/keccak.yml b/.github/workflows/keccak.yml index 1d49ae5..73f6068 100644 --- a/.github/workflows/keccak.yml +++ b/.github/workflows/keccak.yml @@ -84,7 +84,7 @@ jobs: - run: cargo test --target ${{ matrix.target }} --features parallel - run: cargo test --release --target ${{ matrix.target }} --features parallel - env: - RUSTFLAGS: '-Dwarnings --cfg keccak_soft_compact' + RUSTFLAGS: '-Dwarnings --cfg keccak_backend_soft="compact"' run: cargo test --release --target ${{ matrix.target }} - env: RUSTFLAGS: '-Dwarnings --cfg keccak_backend="soft"' @@ -131,7 +131,7 @@ jobs: - run: cargo miri test --target ${{ matrix.target }} - run: cargo miri test --target ${{ matrix.target }} --features parallel - env: - RUSTFLAGS: '-Dwarnings --cfg keccak_soft_compact' + RUSTFLAGS: '-Dwarnings --cfg keccak_backend_soft="compact"' run: cargo miri test --release --target ${{ matrix.target }} --features parallel - env: RUSTFLAGS: '-Dwarnings --cfg keccak_backend="simd128"' diff --git a/keccak/Cargo.toml b/keccak/Cargo.toml index d5d6550..948ea16 100644 --- a/keccak/Cargo.toml +++ b/keccak/Cargo.toml @@ -33,7 +33,7 @@ unused_qualifications = "warn" [lints.rust.unexpected_cfgs] level = "warn" check-cfg = [ - 'cfg(keccak_soft_compact)', + 'cfg(keccak_backend_soft, values("compact"))', 'cfg(keccak_backend, values("aarch64_sha3", "simd128", "simd256", "simd512", "soft"))', ] diff --git a/keccak/src/backends/soft.rs b/keccak/src/backends/soft.rs index 11b6fde..f3ad673 100644 --- a/keccak/src/backends/soft.rs +++ b/keccak/src/backends/soft.rs @@ -52,7 +52,7 @@ impl_lanesize!(u64, F1600_ROUNDS); #[rustfmt::skip] macro_rules! unroll5 { ($var: ident, $body: block) => { - #[cfg(not(keccak_soft_compact))] + #[cfg(not(keccak_backend_soft = "compact"))] { { const $var: usize = 0; $body; } { const $var: usize = 1; $body; } @@ -60,7 +60,7 @@ macro_rules! unroll5 { { const $var: usize = 3; $body; } { const $var: usize = 4; $body; } } - #[cfg(keccak_soft_compact)] + #[cfg(keccak_backend_soft = "compact")] { for $var in 0..5 $body } @@ -70,7 +70,7 @@ macro_rules! unroll5 { #[rustfmt::skip] macro_rules! unroll24 { ($var: ident, $body: block) => { - #[cfg(not(keccak_soft_compact))] + #[cfg(not(keccak_backend_soft = "compact"))] { { const $var: usize = 0; $body; } { const $var: usize = 1; $body; } @@ -97,7 +97,7 @@ macro_rules! unroll24 { { const $var: usize = 22; $body; } { const $var: usize = 23; $body; } } - #[cfg(keccak_soft_compact)] + #[cfg(keccak_backend_soft = "compact")] { for $var in 0..24 $body } From c2121d4df163f0aa56bce1ec6d2db967695c6ed7 Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Sun, 15 Mar 2026 23:54:59 +0300 Subject: [PATCH 2/2] Update readme --- keccak/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/keccak/README.md b/keccak/README.md index 9b77050..ab15df0 100644 --- a/keccak/README.md +++ b/keccak/README.md @@ -54,12 +54,14 @@ keccak::Keccak::new().with_f1600(|f1600| { You can modify crate using the following configuration flags: - `keccak_backend`: select the specified backend. Supported values: - `aarch64_sha3`, `simd128`, `simd256`, `simd512`, `soft`. -- `keccak_soft_compact`: do not unroll loops in the software backend. - Reduces performance, but results in a more compact binary code. + - `aarch64_sha3`: AArch64-specific backend based on the `sha3` extension. + - `simd128/256/512`: backend based on the portable SIMD API. Requires Nightly compiler. + - `soft`: portable software backend. +- `keccak_backend_soft="compact"`: control software backend implementation. Supported values: + - `compact`: do not unroll loops. Reduces performance, but results in a more compact binary code. The flags can be enabled using `RUSTFLAGS` environment variable -(e.g. `RUSTFLAGS="--cfg aes_compact"`) or by modifying `.cargo/config`. +(e.g. `RUSTFLAGS='--cfg keccak_backend="soft"'`) or by modifying `.cargo/config.toml`. ## License