-
Notifications
You must be signed in to change notification settings - Fork 271
Add x86 intrinsics support for sha1 and sha2 #167
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
Conversation
@newpavlov I agree, your code looks much nicer :) Some thoughts for my specific use cases (1) Bringing back dynamic detection would be great, often times the code will be built once and then run on different cpus in my case. |
I second the dynamic detection request. This is important for software that is installed on many different systems. |
The code is written with dynamic dispatch in mind, I just need to write CPUID detection using
If you don't need padding, then I think the easiest way will be to use the compression functions directly, which can be accessed after enabling the |
Runtime detection is back! If you interested, it's powered by the @linkmauve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice, thank you!
pub fn compress(state: &mut [u32; 5], blocks: &[[u8; 64]]) { | ||
// TODO: Replace with https://github.com/rust-lang/rfcs/pull/2725 | ||
// after stabilization | ||
if cpuid_bool::cpuid_bool!("sha", "sse2", "ssse3", "sse4.1") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code breaks platforms that don't support CPUID (e.g. SGX). You should be using https://doc.rust-lang.org/std/macro.is_x86_feature_detected.html, which is the standard way all platforms support feature detection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that is_x86_feature_detected
is not available in libcore
and the linked PR proposes changes to change it. See #183 for discussion as how to fix SGX.
Written using #90 and the software implementation as a reference.
This PR also simplifies handling of ARM backend and deprecates
asm-aarch64
feature.