-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sha1: ARM acceleration using stdarch
intrinsics
#257
Comments
stdarch
intrinsicsstdarch
intrinsics
Here is a public domain implementation of SHA-256 using the ARMv8 intrinsics: https://github.com/noloader/SHA-Intrinsics/blob/master/sha256-arm.c I translated it in the aforementioned gist: https://gist.github.com/tarcieri/414a3300072160f372b5d93ccfce280b |
as a note: all of the intrinsics I've found used are stable for aarch64 as of 1.72, I went on a quest to figure that out, so I felt like sharing the results of that. (https://doc.rust-lang.org/stable/core/arch/aarch64/fn.vsha256hq_u32.html being 1 of them, the rest I checked are also there, note that it says 1.72.1, it was actually stabilized in 1.72.0 but the version tagging and changelogging got missed, and it currently just says whatever version stable is) |
Yeah, we managed to make both
Oh nevermind, it's there, it's just using ASM "polyfills". We can bump to MSRV 1.72 in the next breaking release: https://github.com/RustCrypto/hashes/blob/master/sha2/src/sha256/aarch64.rs |
stdarch
intrinsicsstdarch
intrinsics
I removed
|
Dependency on asm-hashes was removed recently in preparation for v0.11 releases, so it's worth to port the assembly to |
There are a number of issues and comments floating around about this, so I thought I'd make a single tracking issue for this.
Right now we have a separate asm-hashes repo containing assembly implementations of various hash functions.
Longer-term, it would be nice to have ARM implementations of hash functions using stdarch intrinsics, particularly if they provide similar performance via use of e.g. ARMv8 Cryptography Extensions. I was almost able prototype a SHA-256 implementation this way:
https://gist.github.com/tarcieri/414a3300072160f372b5d93ccfce280b
There are a few notable blockers though:
vst1q_u32
and(added)vreinterpretq_u8_u32
thestdarch
intrinsics for ARM are unstable/nightly-onlythere is presently no CI solution for e.g. Apple M1 (we can and already do usecross
for more genericaarch64
)target_feature
/RUSTFLAGS
and/or runtime detection. see also cpufeatures: ARM support utils#378I think we could move forward prototyping things like SHA-1 and SHA-256 using the
stdarch
intrinsics for the ARMv8 Cryptography Extensions, but we may just need to leave those as draft PRs for now, or if we do merge them potentially add something like anightly
feature to gate them under.The text was updated successfully, but these errors were encountered: