Skip to content

Commit 609b63e

Browse files
authored
keccak: replace keccak_soft_compact with keccak_backend_soft="compact" (#116)
This would allow to extend configuration knobs for the software backend in future and would be more consisted with potential similar knobs for other backends.
1 parent d96c7f3 commit 609b63e

4 files changed

Lines changed: 13 additions & 11 deletions

File tree

.github/workflows/keccak.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
- run: cargo test --target ${{ matrix.target }} --features parallel
8585
- run: cargo test --release --target ${{ matrix.target }} --features parallel
8686
- env:
87-
RUSTFLAGS: '-Dwarnings --cfg keccak_soft_compact'
87+
RUSTFLAGS: '-Dwarnings --cfg keccak_backend_soft="compact"'
8888
run: cargo test --release --target ${{ matrix.target }}
8989
- env:
9090
RUSTFLAGS: '-Dwarnings --cfg keccak_backend="soft"'
@@ -131,7 +131,7 @@ jobs:
131131
- run: cargo miri test --target ${{ matrix.target }}
132132
- run: cargo miri test --target ${{ matrix.target }} --features parallel
133133
- env:
134-
RUSTFLAGS: '-Dwarnings --cfg keccak_soft_compact'
134+
RUSTFLAGS: '-Dwarnings --cfg keccak_backend_soft="compact"'
135135
run: cargo miri test --release --target ${{ matrix.target }} --features parallel
136136
- env:
137137
RUSTFLAGS: '-Dwarnings --cfg keccak_backend="simd128"'

keccak/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ unused_qualifications = "warn"
3333
[lints.rust.unexpected_cfgs]
3434
level = "warn"
3535
check-cfg = [
36-
'cfg(keccak_soft_compact)',
36+
'cfg(keccak_backend_soft, values("compact"))',
3737
'cfg(keccak_backend, values("aarch64_sha3", "simd128", "simd256", "simd512", "soft"))',
3838
]
3939

keccak/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ keccak::Keccak::new().with_f1600(|f1600| {
5454
You can modify crate using the following configuration flags:
5555

5656
- `keccak_backend`: select the specified backend. Supported values:
57-
`aarch64_sha3`, `simd128`, `simd256`, `simd512`, `soft`.
58-
- `keccak_soft_compact`: do not unroll loops in the software backend.
59-
Reduces performance, but results in a more compact binary code.
57+
- `aarch64_sha3`: AArch64-specific backend based on the `sha3` extension.
58+
- `simd128/256/512`: backend based on the portable SIMD API. Requires Nightly compiler.
59+
- `soft`: portable software backend.
60+
- `keccak_backend_soft="compact"`: control software backend implementation. Supported values:
61+
- `compact`: do not unroll loops. Reduces performance, but results in a more compact binary code.
6062

6163
The flags can be enabled using `RUSTFLAGS` environment variable
62-
(e.g. `RUSTFLAGS="--cfg aes_compact"`) or by modifying `.cargo/config`.
64+
(e.g. `RUSTFLAGS='--cfg keccak_backend="soft"'`) or by modifying `.cargo/config.toml`.
6365

6466
## License
6567

keccak/src/backends/soft.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ impl_lanesize!(u64, F1600_ROUNDS);
5252
#[rustfmt::skip]
5353
macro_rules! unroll5 {
5454
($var: ident, $body: block) => {
55-
#[cfg(not(keccak_soft_compact))]
55+
#[cfg(not(keccak_backend_soft = "compact"))]
5656
{
5757
{ const $var: usize = 0; $body; }
5858
{ const $var: usize = 1; $body; }
5959
{ const $var: usize = 2; $body; }
6060
{ const $var: usize = 3; $body; }
6161
{ const $var: usize = 4; $body; }
6262
}
63-
#[cfg(keccak_soft_compact)]
63+
#[cfg(keccak_backend_soft = "compact")]
6464
{
6565
for $var in 0..5 $body
6666
}
@@ -70,7 +70,7 @@ macro_rules! unroll5 {
7070
#[rustfmt::skip]
7171
macro_rules! unroll24 {
7272
($var: ident, $body: block) => {
73-
#[cfg(not(keccak_soft_compact))]
73+
#[cfg(not(keccak_backend_soft = "compact"))]
7474
{
7575
{ const $var: usize = 0; $body; }
7676
{ const $var: usize = 1; $body; }
@@ -97,7 +97,7 @@ macro_rules! unroll24 {
9797
{ const $var: usize = 22; $body; }
9898
{ const $var: usize = 23; $body; }
9999
}
100-
#[cfg(keccak_soft_compact)]
100+
#[cfg(keccak_backend_soft = "compact")]
101101
{
102102
for $var in 0..24 $body
103103
}

0 commit comments

Comments
 (0)