RustCrypto / asm-hashes

Assembly implementations of cryptographic hash functions
46 stars 26 forks source link

Use SHA-1/2 instructions for Skylake architecture. #1

Closed Pratyush closed 6 years ago

Pratyush commented 7 years ago

The new Intel Skylake architecture introduces SHA1 and SHA2 specific instructions that should speed up computation of these two primitives: https://software.intel.com/en-us/articles/intel-sha-extensions

There is sample code in C for these that uses intrinsics to do this:

https://github.com/noloader/SHA-Intrinsics

It would be great to have an implementation of these in this library so that we can have blazingly fast hash functions.

tarcieri commented 7 years ago

These instructions are not available on Skylake. The only shipping CPUs which presently have them are AMD Ryzen and Intel Goldmont.

As far as server-class CPUs, this feature will be in Cannonlake CPUs, which will "start to ship in the first half of 2018"

newpavlov commented 7 years ago

I have a draft for SHA1 and SHA2 (as code already structured around respective intrinsics/assembly instructions), but unfortunately I don't have access to CPU with this extension to properly test it. And as was correctly stated by @tarcieri Skylake does not have this extension.

You can see very raw draft for SHA1 in this branch.

newpavlov commented 6 years ago

I've opened a new issue in the RustCrypto/hashes repo. I think we'll go with intrinsics approach as part of the existing sha1 and sha2 crates.