Add x86 intrinsics support for sha1 and sha2#167
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 |
| 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.
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.
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-aarch64feature.