RustCrypto / hashes

Collection of cryptographic hash functions written in pure Rust
1.75k stars 238 forks source link

sha2: fix aarch64 implementation being disabled #569

Closed enkore closed 3 months ago

enkore commented 3 months ago

Fixes #568

(eref 42d478fb6976)

tarcieri commented 3 months ago

Thanks!

enkore commented 3 months ago

works quite well, too: on a GH200 the aarch64.rs code runs at 1.7 GiB/s (versus 0.4 GiB/s for the soft implementation), OpenSSL 3 is just shy of 2 GiB/s.

tarcieri commented 3 months ago

We can probably switch from inline ASM back to the intrinsics at this point, given the current MSRV

enkore commented 3 months ago

Looks like these only landed in 1.76: https://doc.rust-lang.org/core/arch/aarch64/fn.vsha256su0q_u32.html

tarcieri commented 3 months ago

I couldn't even get them to work on 1.76, despite the documentation making it look like they should work: https://github.com/RustCrypto/hashes/actions/runs/8251432049/job/22568457459

tarcieri commented 3 months ago

Oh, perhaps the SHA-256 intrinsics were stabilized, but the SHA-512 ones weren't?

enkore commented 3 months ago

Looks like it, that's a bit odd.

tarcieri commented 3 months ago

Here's the stabilization PR: https://github.com/rust-lang/stdarch/pull/1399/files

I don't even see where e.g. vsha512h2q_u64 is defined? Edit: aha, here it is:

https://github.com/rust-lang/stdarch/blob/3961d3b/crates/core_arch/src/aarch64/neon/generated.rs#L15274-L15288

Gated under stdarch_neon_sha3. Tracking issue here: https://github.com/rust-lang/rust/issues/117225

tarcieri commented 3 months ago

Opened #571 to track this