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.
The new API provides a better way for exposing support for parallel
processing in implemented backends and resolves the issue with branching
on each application of a Keccak permutation.
Extracts a struct to hold the state for Keccak-p1600/Keccak-f1600, along
with a CPU feature detection `InitToken` which is queried at the time
the state is initialized.
The previous `p1600`/`f1600` functions with CPU feature detection
support have been factored onto this struct, leaving the software
implementation available unconditionally as part of the public API, and
avoiding performing CPU feature detection on each invocation of the
permutation.
It looks like it should be possible to slot a struct like this into
something like `Sha3HasherCore` in place of its current `state` array.
Replaces these non-additive "features" with a 1-of-n backend selection
enabled by using `cfg` instead.
- `asm` => `--cfg keccak_backend="armv8_asm"`
- `simd` => `--cfg keccak_backend="simd"`
Closes#85
The following crates now have a new `cfg` for backend selection:
- `ascon`: `--cfg ascon_backend="soft-compact"`
- `keccak`: `--cfg keccak_backend="soft-compact"`
This replaces the previous crate features, as suggested in #85
We pass in `state.as_mut_ptr()` as `x0`, which was previously marked as
`in`. However, it's modified in the `asm!`, e.g.:
sub x0, x0, #192
Note: it's also post-incremented by `ld1.1d` as state is loaded.
Since it's modified, it needs to be `inout`. This marks it as such,
using the `=> _` syntax to discard the result, then it's reset, then
modified as state is written).
Similar mutations were occurring with `x1` and `x8` as well, which have
been modified accordingly.
Also fixes a warning for the ARMv8 `asm!` backend:
error[E0133]: use of inline assembly is unsafe and requires unsafe block
--> keccak/src/armv8.rs:8:5
|
8 | / core::arch::asm!("
9 | | // Read state
10 | | ld1.1d {{ v0- v3}}, [x0], #32
11 | | ld1.1d {{ v4- v7}}, [x0], #32
... |
119 | | options(nostack)
120 | | );
| |_____^ use of inline assembly
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/unsafe-op-in-unsafe-fn.html>
= note: inline assembly is entirely unchecked and can cause undefined behavior
note: an unsafe function restricts its caller, but its body is safe by default
--> keccak/src/armv8.rs:7:1
|
7 | pub unsafe fn p1600_armv8_sha3_asm(state: &mut [u64; 25], round_count: usize) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `-D unsafe-op-in-unsafe-fn` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(unsafe_op_in_unsafe_fn)]`
For more information about this error, try `rustc --explain E0133`.
This tweaks the `repository` fields in Cargo metadata in order to use the correct (i.e. git clonable) URL.
The existing GitHub webUI URLs for each package have been retained and moved to `homepage` fields.
`keccak` was previously excluded from the toplevel workspace due to its
MSRV of 1.41 and incompatibilities with packages used by `ascon`.
This bumps the edition, changes the version to `0.2.0-pre` to denote it
contains breaking changes (though this is not intended to be a
`0.2.0-pre` release), and bumps MSRV.
With the MSRV bumped, `keccak` can and has been re-added to the toplevel
workspace.
Due to the generics approach of the keccak_p routine, the performance
degrades significantly. To encounter this the commonly used functions
are now defined by macros.
The build is failing because `keccak` has a very old MSRV of 1.41, which
after merging #40 (which bumped the `ascon` edition to 2021) broke the
build because it can't handle the `edition` key.
As a workaround, this excludes `keccak` from the toplevel workspace so
it doesn't try to read the `ascon` edition key.
Separately, we should probably bump the `keccak` edition to 2021 as well
and release `keccak` v0.2.0, but that is left for future work.
- Bumps the crate's edition to 2018, which is MSRV-compatible.
- Adds a more expansive set of lints
- Adds the `missing_docs` lint, and adds docs where missing
- Fixes tests on ARMv8
Gates `asm` support under a crate feature.
Uses the `cpufeatures` crate to detect the presence of the `sha3`
extension for ARMv8 CPUs, automatically falling back to a software
implementation if it isn't available.
When the `asm` feature is enabled on `aarch64` targets, exposes
`f1600_asm` that relies on ARMv8 `sha3` hardware intrinsics.