sha256: add AArch64 SHA-2 crypto-extension hardware backend - #90
Open
npajkovsky wants to merge 1 commit into
Open
sha256: add AArch64 SHA-2 crypto-extension hardware backend#90npajkovsky wants to merge 1 commit into
npajkovsky wants to merge 1 commit into
Conversation
Adds an opt-in (`asm` feature) hardware compression backend for SHA-256 on little-endian aarch64, using the ARMv8 Cryptographic Extension (SHA256H/SHA256H2/SHA256SU0/SHA256SU1) via core::arch intrinsics. Runtime support is detected with is_aarch64_feature_detected!, falling back to the portable scalar implementation everywhere else. - New crypto/sha2/src/asm/ module: one submodule per algorithm (asm::sha256), dispatching by (target_arch, target_endian) at its own `mod` declaration; try_compress is always callable and is a no-op on targets with no backend, so callers never need their own #[cfg]. - #![forbid(unsafe_code)] moves from the crate root into sha256.rs/ sha512.rs (unconditional, independent of the `asm` feature); the crate root drops to #![deny(unsafe_code)] and asm/mod.rs grants itself the sole #![allow(unsafe_code)] exception, since `forbid` can never be overridden by a nested #[allow]. - Forwards the feature through the workspace Cargo.toml as `sha2-asm`. - Extends the sha256 benchmark with a 1KiB-chunked and a 1MiB one-shot case alongside the existing 16KiB one-shot. Benchmark (16KiB one-shot, criterion): baseline (scalar): 33.147 µs ( 471.38 MiB/s) asm (aarch64 SHA-2): 4.757 µs (3.2077 GiB/s) ~7x faster Assisted-by: Claude:sonnet-5 Signed-off-by: Nikola Pajkovsky <nikolap@openssl.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an opt-in (
asmfeature) hardware compression backend for SHA-256 on little-endian aarch64, using the ARMv8 Cryptographic Extension (SHA256H/SHA256H2/SHA256SU0/SHA256SU1) via core::arch intrinsics. Runtime support is detected withis_aarch64_feature_detected!, falling back to the portable scalar implementation everywhere else.
moddeclaration; try_compress is always callable and is a no-op on targets with no backend, so callers never need their own #[cfg].asmfeature); the crate root drops to #![deny(unsafe_code)] and asm/mod.rs grants itself the sole #![allow(unsafe_code)] exception, sinceforbidcan never be overridden by a nested #[allow].sha2-asm.Benchmark (16KiB one-shot, criterion):
baseline (scalar): 33.147 µs ( 471.38 MiB/s)
asm (aarch64 SHA-2): 4.757 µs (3.2077 GiB/s) ~7x faster
Assisted-by: Claude:sonnet-5