From 0cd7dc8f4196b6ff17233b53f025e9ddc44480e4 Mon Sep 17 00:00:00 2001 From: Teddy Katz Date: Sun, 31 Jan 2021 01:55:36 -0500 Subject: [PATCH] Use SHA1 intrinsics when `asm` feature is enabled --- Cargo.lock | 2 +- sha1/CHANGELOG.md | 6 ++++++ sha1/Cargo.toml | 2 +- sha1/src/compress.rs | 15 +++++++++------ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 35bf56e75..76f77b6e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -223,7 +223,7 @@ dependencies = [ [[package]] name = "sha-1" -version = "0.9.2" +version = "0.9.3" dependencies = [ "block-buffer", "cfg-if", diff --git a/sha1/CHANGELOG.md b/sha1/CHANGELOG.md index 5a76f1cf6..3a415ba90 100644 --- a/sha1/CHANGELOG.md +++ b/sha1/CHANGELOG.md @@ -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-31) +### Changed +- Use SHA1 intrinsics when `asm` feature is enabled + +[#225]: https://github.com/RustCrypto/hashes/pull/225 + ## 0.9.2 (2020-11-04) ### Added - `force-soft` feature to enforce use of software implementation. ([#203]) diff --git a/sha1/Cargo.toml b/sha1/Cargo.toml index 65fdacbbc..c07ba3658 100644 --- a/sha1/Cargo.toml +++ b/sha1/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sha-1" -version = "0.9.2" +version = "0.9.3" description = "SHA-1 hash function" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" diff --git a/sha1/src/compress.rs b/sha1/src/compress.rs index c849c89e0..1370bf84e 100644 --- a/sha1/src/compress.rs +++ b/sha1/src/compress.rs @@ -9,14 +9,17 @@ cfg_if::cfg_if! { mod soft; mod aarch64; use aarch64::compress as compress_inner; - } else if #[cfg(all(feature = "asm", any(target_arch = "x86", target_arch = "x86_64")))] { - fn compress_inner(state: &mut [u32; 5], blocks: &[[u8; 64]]) { - for block in blocks { - sha1_asm::compress(state, block); - } - } } else if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { + #[cfg(not(feature = "asm"))] mod soft; + #[cfg(feature = "asm")] + mod soft { + pub(crate) fn compress(state: &mut [u32; 5], blocks: &[[u8; 64]]) { + for block in blocks { + sha1_asm::compress(state, block); + } + } + } mod x86; use x86::compress as compress_inner; } else {