diff --git a/Cargo.lock b/Cargo.lock index 733d92a45..a1b45678d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "blake2" version = "0.9.1" @@ -239,9 +241,9 @@ dependencies = [ [[package]] name = "sha1-asm" -version = "0.4.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9dae2289dd5f5dc67fb0f341a5676c5c197415c51ce7345ae1bd0d36a6cbbfc" +checksum = "563d4f7100bc3fce234e5f37bbf63dc2752558964505ba6ac3f7204bdc59eaac" dependencies = [ "cc", ] diff --git a/sha1/Cargo.toml b/sha1/Cargo.toml index fc4d2f51f..fd34ee35b 100644 --- a/sha1/Cargo.toml +++ b/sha1/Cargo.toml @@ -19,9 +19,9 @@ digest = "0.9" block-buffer = "0.9" opaque-debug = "0.3" cfg-if = "1.0" -sha1-asm = { version = "0.4", optional = true } +sha1-asm = { version = "0.5", optional = true } -[target.'cfg(any(target_arch = "aarch64", target_arch = "x86_64", target_arch = "x86"))'.dependencies] +[target.'cfg(any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64"))'.dependencies] cpufeatures = "0.1.5" [dev-dependencies] diff --git a/sha1/src/compress.rs b/sha1/src/compress.rs index 09f24f1f0..b45f87bc2 100644 --- a/sha1/src/compress.rs +++ b/sha1/src/compress.rs @@ -15,9 +15,7 @@ cfg_if::cfg_if! { #[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); - } + sha1_asm::compress(state, blocks) } } mod x86; diff --git a/sha1/src/compress/aarch64.rs b/sha1/src/compress/aarch64.rs index 4edd588ef..5952d1f62 100644 --- a/sha1/src/compress/aarch64.rs +++ b/sha1/src/compress/aarch64.rs @@ -1,19 +1,17 @@ //! SHA-1 `aarch64` backend. -/// Per rustc target feature docs for `aarch64-unknown-linux-gnu` and -/// `aarch64-apple-darwin` platforms, the `sha2` target feature enables -/// SHA-1 as well: -/// -/// > Enable SHA1 and SHA256 support. -cpufeatures::new!(sha2_hwcap, "sha2"); +// Per rustc target feature docs for `aarch64-unknown-linux-gnu` and +// `aarch64-apple-darwin` platforms, the `sha2` target feature enables +// SHA-1 as well: +// +// > Enable SHA1 and SHA256 support. +cpufeatures::new!(sha1_hwcap, "sha2"); -pub fn compress(state: &mut [u32; 5], blocks: &[u8; 64]) { +pub fn compress(state: &mut [u32; 5], blocks: &[[u8; 64]]) { // TODO: Replace with https://github.com/rust-lang/rfcs/pull/2725 // after stabilization - if sha2_hwcap::get() { - for block in blocks { - sha1_asm::compress(state, block); - } + if sha1_hwcap::get() { + sha1_asm::compress(state, blocks); } else { super::soft::compress(state, blocks); } diff --git a/sha1/src/consts.rs b/sha1/src/consts.rs index 277576ac9..c227df3a9 100644 --- a/sha1/src/consts.rs +++ b/sha1/src/consts.rs @@ -1,17 +1,12 @@ -#![allow(clippy::unreadable_literal)] +#![allow(clippy::unreadable_literal, dead_code)] pub const STATE_LEN: usize = 5; -#[cfg(any(not(feature = "asm"), feature = "asm-aarch64"))] pub const BLOCK_LEN: usize = 16; -#[cfg(any(not(feature = "asm"), feature = "asm-aarch64"))] pub const K0: u32 = 0x5A827999u32; -#[cfg(any(not(feature = "asm"), feature = "asm-aarch64"))] pub const K1: u32 = 0x6ED9EBA1u32; -#[cfg(any(not(feature = "asm"), feature = "asm-aarch64"))] pub const K2: u32 = 0x8F1BBCDCu32; -#[cfg(any(not(feature = "asm"), feature = "asm-aarch64"))] pub const K3: u32 = 0xCA62C1D6u32; pub const H: [u32; STATE_LEN] = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0];