Skip to content

Commit 1fb79e9

Browse files
committed
sha1: bump sha1-asm to v0.5
1 parent 5f9d064 commit 1fb79e9

File tree

5 files changed

+15
-22
lines changed

5 files changed

+15
-22
lines changed

Cargo.lock

+4-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sha1/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ digest = "0.9"
1919
block-buffer = "0.9"
2020
opaque-debug = "0.3"
2121
cfg-if = "1.0"
22-
sha1-asm = { version = "0.4", optional = true }
22+
sha1-asm = { version = "0.5", optional = true }
2323

2424
[target.'cfg(any(target_arch = "aarch64", target_arch = "x86_64", target_arch = "x86"))'.dependencies]
2525
cpufeatures = "0.1.5"

sha1/src/compress.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ cfg_if::cfg_if! {
1515
#[cfg(feature = "asm")]
1616
mod soft {
1717
pub(crate) fn compress(state: &mut [u32; 5], blocks: &[[u8; 64]]) {
18-
for block in blocks {
19-
sha1_asm::compress(state, block);
20-
}
18+
sha1_asm::compress(state, blocks)
2119
}
2220
}
2321
mod x86;

sha1/src/compress/aarch64.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
//! SHA-1 `aarch64` backend.
22
3-
/// Per rustc target feature docs for `aarch64-unknown-linux-gnu` and
4-
/// `aarch64-apple-darwin` platforms, the `sha2` target feature enables
5-
/// SHA-1 as well:
6-
///
7-
/// > Enable SHA1 and SHA256 support.
8-
cpufeatures::new!(sha2_hwcap, "sha2");
3+
// Per rustc target feature docs for `aarch64-unknown-linux-gnu` and
4+
// `aarch64-apple-darwin` platforms, the `sha2` target feature enables
5+
// SHA-1 as well:
6+
//
7+
// > Enable SHA1 and SHA256 support.
8+
cpufeatures::new!(sha1_hwcap, "sha2");
99

10-
pub fn compress(state: &mut [u32; 5], blocks: &[u8; 64]) {
10+
pub fn compress(state: &mut [u32; 5], blocks: &[[u8; 64]]) {
1111
// TODO: Replace with https://github.com/rust-lang/rfcs/pull/2725
1212
// after stabilization
13-
if sha2_hwcap::get() {
14-
for block in blocks {
15-
sha1_asm::compress(state, block);
16-
}
13+
if sha1_hwcap::get() {
14+
sha1_asm::compress(state, blocks);
1715
} else {
1816
super::soft::compress(state, blocks);
1917
}

sha1/src/consts.rs

-5
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22

33
pub const STATE_LEN: usize = 5;
44

5-
#[cfg(any(not(feature = "asm"), feature = "asm-aarch64"))]
65
pub const BLOCK_LEN: usize = 16;
76

8-
#[cfg(any(not(feature = "asm"), feature = "asm-aarch64"))]
97
pub const K0: u32 = 0x5A827999u32;
10-
#[cfg(any(not(feature = "asm"), feature = "asm-aarch64"))]
118
pub const K1: u32 = 0x6ED9EBA1u32;
12-
#[cfg(any(not(feature = "asm"), feature = "asm-aarch64"))]
139
pub const K2: u32 = 0x8F1BBCDCu32;
14-
#[cfg(any(not(feature = "asm"), feature = "asm-aarch64"))]
1510
pub const K3: u32 = 0xCA62C1D6u32;
1611

1712
pub const H: [u32; STATE_LEN] = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0];

0 commit comments

Comments
 (0)