Skip to content
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

Use the SHA-NI extension backend with enabled asm feature #224

Merged
merged 3 commits into from Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions sha2/CHANGELOG.md
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.9.3 (2021-01-30)
### Changed
- Use the SHA extension backend with enabled `asm` feature. ([#224])

[#224]: https://github.com/RustCrypto/hashes/pull/224

## 0.9.2 (2020-11-04)
### Added
- `force-soft` feature to enforce use of software implementation. ([#203])
Expand Down
2 changes: 1 addition & 1 deletion sha2/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sha2"
version = "0.9.2"
version = "0.9.3"
description = """
Pure Rust implementation of the SHA-2 hash function family
including SHA-224, SHA-256, SHA-384, and SHA-512.
Expand Down
21 changes: 12 additions & 9 deletions sha2/src/sha256.rs
Expand Up @@ -142,20 +142,23 @@ cfg_if::cfg_if! {
if #[cfg(feature = "force-soft")] {
mod soft;
use soft::compress;
} else if #[cfg(all(feature = "asm", target_arch = "aarch64", target_os = "linux"))] {
} else if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
#[cfg(not(feature = "asm"))]
mod soft;
mod aarch64;
use aarch64::compress;
} else if #[cfg(all(feature = "asm", any(target_arch = "x86", target_arch = "x86_64")))] {
fn compress(state: &mut [u32; 8], blocks: &[[u8; 64]]) {
for block in blocks {
sha2_asm::compress256(state, block);
#[cfg(feature = "asm")]
mod soft {
pub(crate) fn compress(state: &mut [u32; 8], blocks: &[[u8; 64]]) {
for block in blocks {
sha2_asm::compress256(state, block);
}
}
}
} else if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
mod soft;
mod x86;
use x86::compress;
} else if #[cfg(all(feature = "asm", target_arch = "aarch64", target_os = "linux"))] {
mod soft;
mod aarch64;
use aarch64::compress;
} else {
mod soft;
use soft::compress;
Expand Down