hashes: rename process_block to process_blocks
What changed, and why it matters
This is a routine code cleanup in the project's hash functions. A single-block helper was renamed and adjusted so it can later accept multiple blocks at once. The actual hashing math and behavior are unchanged, and the commit message explicitly says it is only refactoring with no logic changes.
No security action needed. Treat as normal maintenance/refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit renames process_block to process_blocks across RIPEMD-160, SHA-1, SHA-256, SHA-512, and SHA3-256 implementations. It changes the function signature from a fixed-size block array (&[u8; BLOCK_SIZE] or &[u8; RATE]) to a dynamically sized slice (&[u8]) and wraps the existing per-block logic in chunks_exact(BLOCK_SIZE) / chunks_exact(RATE) loops. Call sites in internal_macros.rs and sha3_256/mod.rs are updated to use the new name. The cryptographic round constants, state updates, and overall output are preserved. No security-sensitive changes are present.
Changed components
hashes/src/internal_macros.rshashes/src/ripemd160/crypto.rshashes/src/sha1/crypto.rshashes/src/sha256/crypto.rshashes/src/sha3_256/mod.rshashes/src/sha512/crypto.rsInspect captured patch +457 / −435
diff --git a/hashes/src/internal_macros.rs b/hashes/src/internal_macros.rs
index f151a52f..35c2aba3 100644
--- a/hashes/src/internal_macros.rs
+++ b/hashes/src/internal_macros.rs
@@ -181,8 +181,7 @@ macro_rules! engine_input_impl(
.copy_from_slice(&inp[..write_len]);
self.bytes_hashed += write_len as u64;
if $crate::incomplete_block_len(self) == 0 {
- // TODO change this to accept multiple blocks instead
- Self::process_block(&mut self.h, &self.buffer);
+ Self::process_blocks(&mut self.h, &self.buffer);
}
inp = &inp[write_len..];
}
diff --git a/hashes/src/ripemd160/crypto.rs b/hashes/src/ripemd160/crypto.rs
index ca545218..a538d428 100644
--- a/hashes/src/ripemd160/crypto.rs
+++ b/hashes/src/ripemd160/crypto.rs
@@ -131,194 +131,196 @@ macro_rules! process_block(
);
impl HashEngine {
- pub(super) fn process_block(state: &mut [u32; 5], block: &[u8; BLOCK_SIZE]) {
- debug_assert_eq!(block.len(), BLOCK_SIZE);
+ pub(super) fn process_blocks(state: &mut [u32; 5], blocks: &[u8]) {
+ debug_assert!(!blocks.is_empty() && blocks.len() % BLOCK_SIZE == 0);
- let mut w = [0u32; 16];
- for (w_val, buff_bytes) in w.iter_mut().zip(block.bitcoin_as_chunks().0) {
- *w_val = u32::from_le_bytes(*buff_bytes)
- }
+ for block in blocks.chunks_exact(BLOCK_SIZE) {
+ let mut w = [0u32; 16];
+ for (w_val, buff_bytes) in w.iter_mut().zip(block.bitcoin_as_chunks().0) {
+ *w_val = u32::from_le_bytes(*buff_bytes)
+ }
- process_block!(*state, w,
- // Round 1
- round1: h_ordering 0, 1, 2, 3, 4; data_index 0; roll_shift 11;
- round1: h_ordering 4, 0, 1, 2, 3; data_index 1; roll_shift 14;
- round1: h_ordering 3, 4, 0, 1, 2; data_index 2; roll_shift 15;
- round1: h_ordering 2, 3, 4, 0, 1; data_index 3; roll_shift 12;
- round1: h_ordering 1, 2, 3, 4, 0; data_index 4; roll_shift 5;
- round1: h_ordering 0, 1, 2, 3, 4; data_index 5; roll_shift 8;
- round1: h_ordering 4, 0, 1, 2, 3; data_index 6; roll_shift 7;
- round1: h_ordering 3, 4, 0, 1, 2; data_index 7; roll_shift 9;
- round1: h_ordering 2, 3, 4, 0, 1; data_index 8; roll_shift 11;
- round1: h_ordering 1, 2, 3, 4, 0; data_index 9; roll_shift 13;
- round1: h_ordering 0, 1, 2, 3, 4; data_index 10; roll_shift 14;
- round1: h_ordering 4, 0, 1, 2, 3; data_index 11; roll_shift 15;
- round1: h_ordering 3, 4, 0, 1, 2; data_index 12; roll_shift 6;
- round1: h_ordering 2, 3, 4, 0, 1; data_index 13; roll_shift 7;
- round1: h_ordering 1, 2, 3, 4, 0; data_index 14; roll_shift 9;
- round1: h_ordering 0, 1, 2, 3, 4; data_index 15; roll_shift 8;
+ process_block!(*state, w,
+ // Round 1
+ round1: h_ordering 0, 1, 2, 3, 4; data_index 0; roll_shift 11;
+ round1: h_ordering 4, 0, 1, 2, 3; data_index 1; roll_shift 14;
+ round1: h_ordering 3, 4, 0, 1, 2; data_index 2; roll_shift 15;
+ round1: h_ordering 2, 3, 4, 0, 1; data_index 3; roll_shift 12;
+ round1: h_ordering 1, 2, 3, 4, 0; data_index 4; roll_shift 5;
+ round1: h_ordering 0, 1, 2, 3, 4; data_index 5; roll_shift 8;
+ round1: h_ordering 4, 0, 1, 2, 3; data_index 6; roll_shift 7;
+ round1: h_ordering 3, 4, 0, 1, 2; data_index 7; roll_shift 9;
+ round1: h_ordering 2, 3, 4, 0, 1; data_index 8; roll_shift 11;
+ round1: h_ordering 1, 2, 3, 4, 0; data_index 9; roll_shift 13;
+ round1: h_ordering 0, 1, 2, 3, 4; data_index 10; roll_shift 14;
+ round1: h_ordering 4, 0, 1, 2, 3; data_index 11; roll_shift 15;
+ round1: h_ordering 3, 4, 0, 1, 2; data_index 12; roll_shift 6;
+ round1: h_ordering 2, 3, 4, 0, 1; data_index 13; roll_shift 7;
+ round1: h_ordering 1, 2, 3, 4, 0; data_index 14; roll_shift 9;
+ round1: h_ordering 0, 1, 2, 3, 4; data_index 15; roll_shift 8;
- // Round 2
- round2: h_ordering 4, 0, 1, 2, 3; data_index 7; roll_shift 7;
- round2: h_ordering 3, 4, 0, 1, 2; data_index 4; roll_shift 6;
- round2: h_ordering 2, 3, 4, 0, 1; data_index 13; roll_shift 8;
- round2: h_ordering 1, 2, 3, 4, 0; data_index 1; roll_shift 13;
- round2: h_ordering 0, 1, 2, 3, 4; data_index 10; roll_shift 11;
- round2: h_ordering 4, 0, 1, 2, 3; data_index 6; roll_shift 9;
- round2: h_ordering 3, 4, 0, 1, 2; data_index 15; roll_shift 7;
- round2: h_ordering 2, 3, 4, 0, 1; data_index 3; roll_shift 15;
- round2: h_ordering 1, 2, 3, 4, 0; data_index 12; roll_shift 7;
- round2: h_ordering 0, 1, 2, 3, 4; data_index 0; roll_shift 12;
- round2: h_ordering 4, 0, 1, 2, 3; data_index 9; roll_shift 15;
- round2: h_ordering 3, 4, 0, 1, 2; data_index 5; roll_shift 9;
- round2: h_ordering 2, 3, 4, 0, 1; data_index 2; roll_shift 11;
- round2: h_ordering 1, 2, 3, 4, 0; data_index 14; roll_shift 7;
- round2: h_ordering 0, 1, 2, 3, 4; data_index 11; roll_shift 13;
- round2: h_ordering 4, 0, 1, 2, 3; data_index 8; roll_shift 12;
+ // Round 2
+ round2: h_ordering 4, 0, 1, 2, 3; data_index 7; roll_shift 7;
+ round2: h_ordering 3, 4, 0, 1, 2; data_index 4; roll_shift 6;
+ round2: h_ordering 2, 3, 4, 0, 1; data_index 13; roll_shift 8;
+ round2: h_ordering 1, 2, 3, 4, 0; data_index 1; roll_shift 13;
+ round2: h_ordering 0, 1, 2, 3, 4; data_index 10; roll_shift 11;
+ round2: h_ordering 4, 0, 1, 2, 3; data_index 6; roll_shift 9;
+ round2: h_ordering 3, 4, 0, 1, 2; data_index 15; roll_shift 7;
+ round2: h_ordering 2, 3, 4, 0, 1; data_index 3; roll_shift 15;
+ round2: h_ordering 1, 2, 3, 4, 0; data_index 12; roll_shift 7;
+ round2: h_ordering 0, 1, 2, 3, 4; data_index 0; roll_shift 12;
+ round2: h_ordering 4, 0, 1, 2, 3; data_index 9; roll_shift 15;
+ round2: h_ordering 3, 4, 0, 1, 2; data_index 5; roll_shift 9;
+ round2: h_ordering 2, 3, 4, 0, 1; data_index 2; roll_shift 11;
+ round2: h_ordering 1, 2, 3, 4, 0; data_index 14; roll_shift 7;
+ round2: h_ordering 0, 1, 2, 3, 4; data_index 11; roll_shift 13;
+ round2: h_ordering 4, 0, 1, 2, 3; data_index 8; roll_shift 12;
- // Round 3
- round3: h_ordering 3, 4, 0, 1, 2; data_index 3; roll_shift 11;
- round3: h_ordering 2, 3, 4, 0, 1; data_index 10; roll_shift 13;
- round3: h_ordering 1, 2, 3, 4, 0; data_index 14; roll_shift 6;
- round3: h_ordering 0, 1, 2, 3, 4; data_index 4; roll_shift 7;
- round3: h_ordering 4, 0, 1, 2, 3; data_index 9; roll_shift 14;
- round3: h_ordering 3, 4, 0, 1, 2; data_index 15; roll_shift 9;
- round3: h_ordering 2, 3, 4, 0, 1; data_index 8; roll_shift 13;
- round3: h_ordering 1, 2, 3, 4, 0; data_index 1; roll_shift 15;
- round3: h_ordering 0, 1, 2, 3, 4; data_index 2; roll_shift 14;
- round3: h_ordering 4, 0, 1, 2, 3; data_index 7; roll_shift 8;
- round3: h_ordering 3, 4, 0, 1, 2; data_index 0; roll_shift 13;
- round3: h_ordering 2, 3, 4, 0, 1; data_index 6; roll_shift 6;
- round3: h_ordering 1, 2, 3, 4, 0; data_index 13; roll_shift 5;
- round3: h_ordering 0, 1, 2, 3, 4; data_index 11; roll_shift 12;
- round3: h_ordering 4, 0, 1, 2, 3; data_index 5; roll_shift 7;
- round3: h_ordering 3, 4, 0, 1, 2; data_index 12; roll_shift 5;
+ // Round 3
+ round3: h_ordering 3, 4, 0, 1, 2; data_index 3; roll_shift 11;
+ round3: h_ordering 2, 3, 4, 0, 1; data_index 10; roll_shift 13;
+ round3: h_ordering 1, 2, 3, 4, 0; data_index 14; roll_shift 6;
+ round3: h_ordering 0, 1, 2, 3, 4; data_index 4; roll_shift 7;
+ round3: h_ordering 4, 0, 1, 2, 3; data_index 9; roll_shift 14;
+ round3: h_ordering 3, 4, 0, 1, 2; data_index 15; roll_shift 9;
+ round3: h_ordering 2, 3, 4, 0, 1; data_index 8; roll_shift 13;
+ round3: h_ordering 1, 2, 3, 4, 0; data_index 1; roll_shift 15;
+ round3: h_ordering 0, 1, 2, 3, 4; data_index 2; roll_shift 14;
+ round3: h_ordering 4, 0, 1, 2, 3; data_index 7; roll_shift 8;
+ round3: h_ordering 3, 4, 0, 1, 2; data_index 0; roll_shift 13;
+ round3: h_ordering 2, 3, 4, 0, 1; data_index 6; roll_shift 6;
+ round3: h_ordering 1, 2, 3, 4, 0; data_index 13; roll_shift 5;
+ round3: h_ordering 0, 1, 2, 3, 4; data_index 11; roll_shift 12;
+ round3: h_ordering 4, 0, 1, 2, 3; data_index 5; roll_shift 7;
+ round3: h_ordering 3, 4, 0, 1, 2; data_index 12; roll_shift 5;
- // Round 4
- round4: h_ordering 2, 3, 4, 0, 1; data_index 1; roll_shift 11;
- round4: h_ordering 1, 2, 3, 4, 0; data_index 9; roll_shift 12;
- round4: h_ordering 0, 1, 2, 3, 4; data_index 11; roll_shift 14;
- round4: h_ordering 4, 0, 1, 2, 3; data_index 10; roll_shift 15;
- round4: h_ordering 3, 4, 0, 1, 2; data_index 0; roll_shift 14;
- round4: h_ordering 2, 3, 4, 0, 1; data_index 8; roll_shift 15;
- round4: h_ordering 1, 2, 3, 4, 0; data_index 12; roll_shift 9;
- round4: h_ordering 0, 1, 2, 3, 4; data_index 4; roll_shift 8;
- round4: h_ordering 4, 0, 1, 2, 3; data_index 13; roll_shift 9;
- round4: h_ordering 3, 4, 0, 1, 2; data_index 3; roll_shift 14;
- round4: h_ordering 2, 3, 4, 0, 1; data_index 7; roll_shift 5;
- round4: h_ordering 1, 2, 3, 4, 0; data_index 15; roll_shift 6;
- round4: h_ordering 0, 1, 2, 3, 4; data_index 14; roll_shift 8;
- round4: h_ordering 4, 0, 1, 2, 3; data_index 5; roll_shift 6;
- round4: h_ordering 3, 4, 0, 1, 2; data_index 6; roll_shift 5;
- round4: h_ordering 2, 3, 4, 0, 1; data_index 2; roll_shift 12;
+ // Round 4
+ round4: h_ordering 2, 3, 4, 0, 1; data_index 1; roll_shift 11;
+ round4: h_ordering 1, 2, 3, 4, 0; data_index 9; roll_shift 12;
+ round4: h_ordering 0, 1, 2, 3, 4; data_index 11; roll_shift 14;
+ round4: h_ordering 4, 0, 1, 2, 3; data_index 10; roll_shift 15;
+ round4: h_ordering 3, 4, 0, 1, 2; data_index 0; roll_shift 14;
+ round4: h_ordering 2, 3, 4, 0, 1; data_index 8; roll_shift 15;
+ round4: h_ordering 1, 2, 3, 4, 0; data_index 12; roll_shift 9;
+ round4: h_ordering 0, 1, 2, 3, 4; data_index 4; roll_shift 8;
+ round4: h_ordering 4, 0, 1, 2, 3; data_index 13; roll_shift 9;
+ round4: h_ordering 3, 4, 0, 1, 2; data_index 3; roll_shift 14;
+ round4: h_ordering 2, 3, 4, 0, 1; data_index 7; roll_shift 5;
+ round4: h_ordering 1, 2, 3, 4, 0; data_index 15; roll_shift 6;
+ round4: h_ordering 0, 1, 2, 3, 4; data_index 14; roll_shift 8;
+ round4: h_ordering 4, 0, 1, 2, 3; data_index 5; roll_shift 6;
+ round4: h_ordering 3, 4, 0, 1, 2; data_index 6; roll_shift 5;
+ round4: h_ordering 2, 3, 4, 0, 1; data_index 2; roll_shift 12;
- // Round 5
- round5: h_ordering 1, 2, 3, 4, 0; data_index 4; roll_shift 9;
- round5: h_ordering 0, 1, 2, 3, 4; data_index 0; roll_shift 15;
- round5: h_ordering 4, 0, 1, 2, 3; data_index 5; roll_shift 5;
- round5: h_ordering 3, 4, 0, 1, 2; data_index 9; roll_shift 11;
- round5: h_ordering 2, 3, 4, 0, 1; data_index 7; roll_shift 6;
- round5: h_ordering 1, 2, 3, 4, 0; data_index 12; roll_shift 8;
- round5: h_ordering 0, 1, 2, 3, 4; data_index 2; roll_shift 13;
- round5: h_ordering 4, 0, 1, 2, 3; data_index 10; roll_shift 12;
- round5: h_ordering 3, 4, 0, 1, 2; data_index 14; roll_shift 5;
- round5: h_ordering 2, 3, 4, 0, 1; data_index 1; roll_shift 12;
- round5: h_ordering 1, 2, 3, 4, 0; data_index 3; roll_shift 13;
- round5: h_ordering 0, 1, 2, 3, 4; data_index 8; roll_shift 14;
- round5: h_ordering 4, 0, 1, 2, 3; data_index 11; roll_shift 11;
- round5: h_ordering 3, 4, 0, 1, 2; data_index 6; roll_shift 8;
- round5: h_ordering 2, 3, 4, 0, 1; data_index 15; roll_shift 5;
- round5: h_ordering 1, 2, 3, 4, 0; data_index 13; roll_shift 6;
+ // Round 5
+ round5: h_ordering 1, 2, 3, 4, 0; data_index 4; roll_shift 9;
+ round5: h_ordering 0, 1, 2, 3, 4; data_index 0; roll_shift 15;
+ round5: h_ordering 4, 0, 1, 2, 3; data_index 5; roll_shift 5;
+ round5: h_ordering 3, 4, 0, 1, 2; data_index 9; roll_shift 11;
+ round5: h_ordering 2, 3, 4, 0, 1; data_index 7; roll_shift 6;
+ round5: h_ordering 1, 2, 3, 4, 0; data_index 12; roll_shift 8;
+ round5: h_ordering 0, 1, 2, 3, 4; data_index 2; roll_shift 13;
+ round5: h_ordering 4, 0, 1, 2, 3; data_index 10; roll_shift 12;
+ round5: h_ordering 3, 4, 0, 1, 2; data_index 14; roll_shift 5;
+ round5: h_ordering 2, 3, 4, 0, 1; data_index 1; roll_shift 12;
+ round5: h_ordering 1, 2, 3, 4, 0; data_index 3; roll_shift 13;
+ round5: h_ordering 0, 1, 2, 3, 4; data_index 8; roll_shift 14;
+ round5: h_ordering 4, 0, 1, 2, 3; data_index 11; roll_shift 11;
+ round5: h_ordering 3, 4, 0, 1, 2; data_index 6; roll_shift 8;
+ round5: h_ordering 2, 3, 4, 0, 1; data_index 15; roll_shift 5;
+ round5: h_ordering 1, 2, 3, 4, 0; data_index 13; roll_shift 6;
- // Parallel Round 1;
- par_round1: h_ordering 0, 1, 2, 3, 4; data_index 5; roll_shift 8;
- par_round1: h_ordering 4, 0, 1, 2, 3; data_index 14; roll_shift 9;
- par_round1: h_ordering 3, 4, 0, 1, 2; data_index 7; roll_shift 9;
- par_round1: h_ordering 2, 3, 4, 0, 1; data_index 0; roll_shift 11;
- par_round1: h_ordering 1, 2, 3, 4, 0; data_index 9; roll_shift 13;
- par_round1: h_ordering 0, 1, 2, 3, 4; data_index 2; roll_shift 15;
- par_round1: h_ordering 4, 0, 1, 2, 3; data_index 11; roll_shift 15;
- par_round1: h_ordering 3, 4, 0, 1, 2; data_index 4; roll_shift 5;
- par_round1: h_ordering 2, 3, 4, 0, 1; data_index 13; roll_shift 7;
- par_round1: h_ordering 1, 2, 3, 4, 0; data_index 6; roll_shift 7;
- par_round1: h_ordering 0, 1, 2, 3, 4; data_index 15; roll_shift 8;
- par_round1: h_ordering 4, 0, 1, 2, 3; data_index 8; roll_shift 11;
- par_round1: h_ordering 3, 4, 0, 1, 2; data_index 1; roll_shift 14;
- par_round1: h_ordering 2, 3, 4, 0, 1; data_index 10; roll_shift 14;
- par_round1: h_ordering 1, 2, 3, 4, 0; data_index 3; roll_shift 12;
- par_round1: h_ordering 0, 1, 2, 3, 4; data_index 12; roll_shift 6;
+ // Parallel Round 1;
+ par_round1: h_ordering 0, 1, 2, 3, 4; data_index 5; roll_shift 8;
+ par_round1: h_ordering 4, 0, 1, 2, 3; data_index 14; roll_shift 9;
+ par_round1: h_ordering 3, 4, 0, 1, 2; data_index 7; roll_shift 9;
+ par_round1: h_ordering 2, 3, 4, 0, 1; data_index 0; roll_shift 11;
+ par_round1: h_ordering 1, 2, 3, 4, 0; data_index 9; roll_shift 13;
+ par_round1: h_ordering 0, 1, 2, 3, 4; data_index 2; roll_shift 15;
+ par_round1: h_ordering 4, 0, 1, 2, 3; data_index 11; roll_shift 15;
+ par_round1: h_ordering 3, 4, 0, 1, 2; data_index 4; roll_shift 5;
+ par_round1: h_ordering 2, 3, 4, 0, 1; data_index 13; roll_shift 7;
+ par_round1: h_ordering 1, 2, 3, 4, 0; data_index 6; roll_shift 7;
+ par_round1: h_ordering 0, 1, 2, 3, 4; data_index 15; roll_shift 8;
+ par_round1: h_ordering 4, 0, 1, 2, 3; data_index 8; roll_shift 11;
+ par_round1: h_ordering 3, 4, 0, 1, 2; data_index 1; roll_shift 14;
+ par_round1: h_ordering 2, 3, 4, 0, 1; data_index 10; roll_shift 14;
+ par_round1: h_ordering 1, 2, 3, 4, 0; data_index 3; roll_shift 12;
+ par_round1: h_ordering 0, 1, 2, 3, 4; data_index 12; roll_shift 6;
- // Parallel Round 2
- par_round2: h_ordering 4, 0, 1, 2, 3; data_index 6; roll_shift 9;
- par_round2: h_ordering 3, 4, 0, 1, 2; data_index 11; roll_shift 13;
- par_round2: h_ordering 2, 3, 4, 0, 1; data_index 3; roll_shift 15;
- par_round2: h_ordering 1, 2, 3, 4, 0; data_index 7; roll_shift 7;
- par_round2: h_ordering 0, 1, 2, 3, 4; data_index 0; roll_shift 12;
- par_round2: h_ordering 4, 0, 1, 2, 3; data_index 13; roll_shift 8;
- par_round2: h_ordering 3, 4, 0, 1, 2; data_index 5; roll_shift 9;
- par_round2: h_ordering 2, 3, 4, 0, 1; data_index 10; roll_shift 11;
- par_round2: h_ordering 1, 2, 3, 4, 0; data_index 14; roll_shift 7;
- par_round2: h_ordering 0, 1, 2, 3, 4; data_index 15; roll_shift 7;
- par_round2: h_ordering 4, 0, 1, 2, 3; data_index 8; roll_shift 12;
- par_round2: h_ordering 3, 4, 0, 1, 2; data_index 12; roll_shift 7;
- par_round2: h_ordering 2, 3, 4, 0, 1; data_index 4; roll_shift 6;
- par_round2: h_ordering 1, 2, 3, 4, 0; data_index 9; roll_shift 15;
- par_round2: h_ordering 0, 1, 2, 3, 4; data_index 1; roll_shift 13;
- par_round2: h_ordering 4, 0, 1, 2, 3; data_index 2; roll_shift 11;
+ // Parallel Round 2
+ par_round2: h_ordering 4, 0, 1, 2, 3; data_index 6; roll_shift 9;
+ par_round2: h_ordering 3, 4, 0, 1, 2; data_index 11; roll_shift 13;
+ par_round2: h_ordering 2, 3, 4, 0, 1; data_index 3; roll_shift 15;
+ par_round2: h_ordering 1, 2, 3, 4, 0; data_index 7; roll_shift 7;
+ par_round2: h_ordering 0, 1, 2, 3, 4; data_index 0; roll_shift 12;
+ par_round2: h_ordering 4, 0, 1, 2, 3; data_index 13; roll_shift 8;
+ par_round2: h_ordering 3, 4, 0, 1, 2; data_index 5; roll_shift 9;
+ par_round2: h_ordering 2, 3, 4, 0, 1; data_index 10; roll_shift 11;
+ par_round2: h_ordering 1, 2, 3, 4, 0; data_index 14; roll_shift 7;
+ par_round2: h_ordering 0, 1, 2, 3, 4; data_index 15; roll_shift 7;
+ par_round2: h_ordering 4, 0, 1, 2, 3; data_index 8; roll_shift 12;
+ par_round2: h_ordering 3, 4, 0, 1, 2; data_index 12; roll_shift 7;
+ par_round2: h_ordering 2, 3, 4, 0, 1; data_index 4; roll_shift 6;
+ par_round2: h_ordering 1, 2, 3, 4, 0; data_index 9; roll_shift 15;
+ par_round2: h_ordering 0, 1, 2, 3, 4; data_index 1; roll_shift 13;
+ par_round2: h_ordering 4, 0, 1, 2, 3; data_index 2; roll_shift 11;
- // Parallel Round 3
- par_round3: h_ordering 3, 4, 0, 1, 2; data_index 15; roll_shift 9;
- par_round3: h_ordering 2, 3, 4, 0, 1; data_index 5; roll_shift 7;
- par_round3: h_ordering 1, 2, 3, 4, 0; data_index 1; roll_shift 15;
- par_round3: h_ordering 0, 1, 2, 3, 4; data_index 3; roll_shift 11;
- par_round3: h_ordering 4, 0, 1, 2, 3; data_index 7; roll_shift 8;
- par_round3: h_ordering 3, 4, 0, 1, 2; data_index 14; roll_shift 6;
- par_round3: h_ordering 2, 3, 4, 0, 1; data_index 6; roll_shift 6;
- par_round3: h_ordering 1, 2, 3, 4, 0; data_index 9; roll_shift 14;
- par_round3: h_ordering 0, 1, 2, 3, 4; data_index 11; roll_shift 12;
- par_round3: h_ordering 4, 0, 1, 2, 3; data_index 8; roll_shift 13;
- par_round3: h_ordering 3, 4, 0, 1, 2; data_index 12; roll_shift 5;
- par_round3: h_ordering 2, 3, 4, 0, 1; data_index 2; roll_shift 14;
- par_round3: h_ordering 1, 2, 3, 4, 0; data_index 10; roll_shift 13;
- par_round3: h_ordering 0, 1, 2, 3, 4; data_index 0; roll_shift 13;
- par_round3: h_ordering 4, 0, 1, 2, 3; data_index 4; roll_shift 7;
- par_round3: h_ordering 3, 4, 0, 1, 2; data_index 13; roll_shift 5;
+ // Parallel Round 3
+ par_round3: h_ordering 3, 4, 0, 1, 2; data_index 15; roll_shift 9;
+ par_round3: h_ordering 2, 3, 4, 0, 1; data_index 5; roll_shift 7;
+ par_round3: h_ordering 1, 2, 3, 4, 0; data_index 1; roll_shift 15;
+ par_round3: h_ordering 0, 1, 2, 3, 4; data_index 3; roll_shift 11;
+ par_round3: h_ordering 4, 0, 1, 2, 3; data_index 7; roll_shift 8;
+ par_round3: h_ordering 3, 4, 0, 1, 2; data_index 14; roll_shift 6;
+ par_round3: h_ordering 2, 3, 4, 0, 1; data_index 6; roll_shift 6;
+ par_round3: h_ordering 1, 2, 3, 4, 0; data_index 9; roll_shift 14;
+ par_round3: h_ordering 0, 1, 2, 3, 4; data_index 11; roll_shift 12;
+ par_round3: h_ordering 4, 0, 1, 2, 3; data_index 8; roll_shift 13;
+ par_round3: h_ordering 3, 4, 0, 1, 2; data_index 12; roll_shift 5;
+ par_round3: h_ordering 2, 3, 4, 0, 1; data_index 2; roll_shift 14;
+ par_round3: h_ordering 1, 2, 3, 4, 0; data_index 10; roll_shift 13;
+ par_round3: h_ordering 0, 1, 2, 3, 4; data_index 0; roll_shift 13;
+ par_round3: h_ordering 4, 0, 1, 2, 3; data_index 4; roll_shift 7;
+ par_round3: h_ordering 3, 4, 0, 1, 2; data_index 13; roll_shift 5;
- // Parallel Round 4
- par_round4: h_ordering 2, 3, 4, 0, 1; data_index 8; roll_shift 15;
- par_round4: h_ordering 1, 2, 3, 4, 0; data_index 6; roll_shift 5;
- par_round4: h_ordering 0, 1, 2, 3, 4; data_index 4; roll_shift 8;
- par_round4: h_ordering 4, 0, 1, 2, 3; data_index 1; roll_shift 11;
- par_round4: h_ordering 3, 4, 0, 1, 2; data_index 3; roll_shift 14;
- par_round4: h_ordering 2, 3, 4, 0, 1; data_index 11; roll_shift 14;
- par_round4: h_ordering 1, 2, 3, 4, 0; data_index 15; roll_shift 6;
- par_round4: h_ordering 0, 1, 2, 3, 4; data_index 0; roll_shift 14;
- par_round4: h_ordering 4, 0, 1, 2, 3; data_index 5; roll_shift 6;
- par_round4: h_ordering 3, 4, 0, 1, 2; data_index 12; roll_shift 9;
- par_round4: h_ordering 2, 3, 4, 0, 1; data_index 2; roll_shift 12;
- par_round4: h_ordering 1, 2, 3, 4, 0; data_index 13; roll_shift 9;
- par_round4: h_ordering 0, 1, 2, 3, 4; data_index 9; roll_shift 12;
- par_round4: h_ordering 4, 0, 1, 2, 3; data_index 7; roll_shift 5;
- par_round4: h_ordering 3, 4, 0, 1, 2; data_index 10; roll_shift 15;
- par_round4: h_ordering 2, 3, 4, 0, 1; data_index 14; roll_shift 8;
+ // Parallel Round 4
+ par_round4: h_ordering 2, 3, 4, 0, 1; data_index 8; roll_shift 15;
+ par_round4: h_ordering 1, 2, 3, 4, 0; data_index 6; roll_shift 5;
+ par_round4: h_ordering 0, 1, 2, 3, 4; data_index 4; roll_shift 8;
+ par_round4: h_ordering 4, 0, 1, 2, 3; data_index 1; roll_shift 11;
+ par_round4: h_ordering 3, 4, 0, 1, 2; data_index 3; roll_shift 14;
+ par_round4: h_ordering 2, 3, 4, 0, 1; data_index 11; roll_shift 14;
+ par_round4: h_ordering 1, 2, 3, 4, 0; data_index 15; roll_shift 6;
+ par_round4: h_ordering 0, 1, 2, 3, 4; data_index 0; roll_shift 14;
+ par_round4: h_ordering 4, 0, 1, 2, 3; data_index 5; roll_shift 6;
+ par_round4: h_ordering 3, 4, 0, 1, 2; data_index 12; roll_shift 9;
+ par_round4: h_ordering 2, 3, 4, 0, 1; data_index 2; roll_shift 12;
+ par_round4: h_ordering 1, 2, 3, 4, 0; data_index 13; roll_shift 9;
+ par_round4: h_ordering 0, 1, 2, 3, 4; data_index 9; roll_shift 12;
+ par_round4: h_ordering 4, 0, 1, 2, 3; data_index 7; roll_shift 5;
+ par_round4: h_ordering 3, 4, 0, 1, 2; data_index 10; roll_shift 15;
+ par_round4: h_ordering 2, 3, 4, 0, 1; data_index 14; roll_shift 8;
- // Parallel Round 5
- par_round5: h_ordering 1, 2, 3, 4, 0; data_index 12; roll_shift 8;
- par_round5: h_ordering 0, 1, 2, 3, 4; data_index 15; roll_shift 5;
- par_round5: h_ordering 4, 0, 1, 2, 3; data_index 10; roll_shift 12;
- par_round5: h_ordering 3, 4, 0, 1, 2; data_index 4; roll_shift 9;
- par_round5: h_ordering 2, 3, 4, 0, 1; data_index 1; roll_shift 12;
- par_round5: h_ordering 1, 2, 3, 4, 0; data_index 5; roll_shift 5;
- par_round5: h_ordering 0, 1, 2, 3, 4; data_index 8; roll_shift 14;
- par_round5: h_ordering 4, 0, 1, 2, 3; data_index 7; roll_shift 6;
- par_round5: h_ordering 3, 4, 0, 1, 2; data_index 6; roll_shift 8;
- par_round5: h_ordering 2, 3, 4, 0, 1; data_index 2; roll_shift 13;
- par_round5: h_ordering 1, 2, 3, 4, 0; data_index 13; roll_shift 6;
- par_round5: h_ordering 0, 1, 2, 3, 4; data_index 14; roll_shift 5;
- par_round5: h_ordering 4, 0, 1, 2, 3; data_index 0; roll_shift 15;
- par_round5: h_ordering 3, 4, 0, 1, 2; data_index 3; roll_shift 13;
- par_round5: h_ordering 2, 3, 4, 0, 1; data_index 9; roll_shift 11;
- par_round5: h_ordering 1, 2, 3, 4, 0; data_index 11; roll_shift 11;
- );
+ // Parallel Round 5
+ par_round5: h_ordering 1, 2, 3, 4, 0; data_index 12; roll_shift 8;
+ par_round5: h_ordering 0, 1, 2, 3, 4; data_index 15; roll_shift 5;
+ par_round5: h_ordering 4, 0, 1, 2, 3; data_index 10; roll_shift 12;
+ par_round5: h_ordering 3, 4, 0, 1, 2; data_index 4; roll_shift 9;
+ par_round5: h_ordering 2, 3, 4, 0, 1; data_index 1; roll_shift 12;
+ par_round5: h_ordering 1, 2, 3, 4, 0; data_index 5; roll_shift 5;
+ par_round5: h_ordering 0, 1, 2, 3, 4; data_index 8; roll_shift 14;
+ par_round5: h_ordering 4, 0, 1, 2, 3; data_index 7; roll_shift 6;
+ par_round5: h_ordering 3, 4, 0, 1, 2; data_index 6; roll_shift 8;
+ par_round5: h_ordering 2, 3, 4, 0, 1; data_index 2; roll_shift 13;
+ par_round5: h_ordering 1, 2, 3, 4, 0; data_index 13; roll_shift 6;
+ par_round5: h_ordering 0, 1, 2, 3, 4; data_index 14; roll_shift 5;
+ par_round5: h_ordering 4, 0, 1, 2, 3; data_index 0; roll_shift 15;
+ par_round5: h_ordering 3, 4, 0, 1, 2; data_index 3; roll_shift 13;
+ par_round5: h_ordering 2, 3, 4, 0, 1; data_index 9; roll_shift 11;
+ par_round5: h_ordering 1, 2, 3, 4, 0; data_index 11; roll_shift 11;
+ );
+ }
}
}
diff --git a/hashes/src/sha1/crypto.rs b/hashes/src/sha1/crypto.rs
index 14d866fb..596de124 100644
--- a/hashes/src/sha1/crypto.rs
+++ b/hashes/src/sha1/crypto.rs
@@ -6,45 +6,47 @@ use super::{HashEngine, BLOCK_SIZE};
impl HashEngine {
// Basic unoptimized algorithm from Wikipedia
- pub(super) fn process_block(state: &mut[u32; 5], block: &[u8; BLOCK_SIZE]) {
- debug_assert_eq!(block.len(), BLOCK_SIZE);
-
- let mut w = [0u32; 80];
- for (w_val, buff_bytes) in w.iter_mut().zip(block.bitcoin_as_chunks().0) {
- *w_val = u32::from_be_bytes(*buff_bytes)
- }
- for i in 16..80 {
- w[i] = (w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]).rotate_left(1);
+ pub(super) fn process_blocks(state: &mut[u32; 5], blocks: &[u8]) {
+ debug_assert!(!blocks.is_empty() && blocks.len() % BLOCK_SIZE == 0);
+
+ for block in blocks.chunks_exact(BLOCK_SIZE) {
+ let mut w = [0u32; 80];
+ for (w_val, buff_bytes) in w.iter_mut().zip(block.bitcoin_as_chunks().0) {
+ *w_val = u32::from_be_bytes(*buff_bytes)
+ }
+ for i in 16..80 {
+ w[i] = (w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]).rotate_left(1);
+ }
+
+ let mut a = state[0];
+ let mut b = state[1];
+ let mut c = state[2];
+ let mut d = state[3];
+ let mut e = state[4];
+
+ for (i, &wi) in w.iter().enumerate() {
+ let (f, k) = match i {
+ 0..=19 => ((b & c) | (!b & d), 0x5a827999),
+ 20..=39 => (b ^ c ^ d, 0x6ed9eba1),
+ 40..=59 => ((b & c) | (b & d) | (c & d), 0x8f1bbcdc),
+ 60..=79 => (b ^ c ^ d, 0xca62c1d6),
+ _ => unreachable!(),
+ };
+
+ let new_a =
+ a.rotate_left(5).wrapping_add(f).wrapping_add(e).wrapping_add(k).wrapping_add(wi);
+ e = d;
+ d = c;
+ c = b.rotate_left(30);
+ b = a;
+ a = new_a;
+ }
+
+ state[0] = state[0].wrapping_add(a);
+ state[1] = state[1].wrapping_add(b);
+ state[2] = state[2].wrapping_add(c);
+ state[3] = state[3].wrapping_add(d);
+ state[4] = state[4].wrapping_add(e);
}
-
- let mut a = state[0];
- let mut b = state[1];
- let mut c = state[2];
- let mut d = state[3];
- let mut e = state[4];
-
- for (i, &wi) in w.iter().enumerate() {
- let (f, k) = match i {
- 0..=19 => ((b & c) | (!b & d), 0x5a827999),
- 20..=39 => (b ^ c ^ d, 0x6ed9eba1),
- 40..=59 => ((b & c) | (b & d) | (c & d), 0x8f1bbcdc),
- 60..=79 => (b ^ c ^ d, 0xca62c1d6),
- _ => unreachable!(),
- };
-
- let new_a =
- a.rotate_left(5).wrapping_add(f).wrapping_add(e).wrapping_add(k).wrapping_add(wi);
- e = d;
- d = c;
- c = b.rotate_left(30);
- b = a;
- a = new_a;
- }
-
- state[0] = state[0].wrapping_add(a);
- state[1] = state[1].wrapping_add(b);
- state[2] = state[2].wrapping_add(c);
- state[3] = state[3].wrapping_add(d);
- state[4] = state[4].wrapping_add(e);
}
}
diff --git a/hashes/src/sha256/crypto.rs b/hashes/src/sha256/crypto.rs
index a27f0caf..51938456 100644
--- a/hashes/src/sha256/crypto.rs
+++ b/hashes/src/sha256/crypto.rs
@@ -269,7 +269,7 @@ impl Midstate {
}
impl HashEngine {
- pub(super) fn process_block(state: &mut[u32; 8], block: &[u8; BLOCK_SIZE]) {
+ pub(super) fn process_blocks(state: &mut[u32; 8], blocks: &[u8]) {
#[cfg(all(feature = "std", any(target_arch = "x86", target_arch = "x86_64")))]
{
if std::is_x86_feature_detected!("sse4.1")
@@ -277,39 +277,50 @@ impl HashEngine {
&& std::is_x86_feature_detected!("sse2")
&& std::is_x86_feature_detected!("ssse3")
{
- return unsafe { Self::process_block_simd_x86_intrinsics(state, block) };
+ for block in blocks.chunks_exact(BLOCK_SIZE) {
+ unsafe { Self::process_block_simd_x86_intrinsics(state, block) };
+ }
+ return;
}
}
#[cfg(all(feature = "cpufeatures", any(target_arch = "x86", target_arch = "x86_64")))]
{
if cpuid_sha256_x86::get() {
- return unsafe { Self::process_block_simd_x86_intrinsics(state, block) };
+ for block in blocks.chunks_exact(BLOCK_SIZE) {
+ unsafe { Self::process_block_simd_x86_intrinsics(state, block) };
+ }
+ return;
}
}
-
#[cfg(all(feature = "std", target_arch = "aarch64"))]
{
if std::arch::is_aarch64_feature_detected!("sha2") {
- return unsafe { Self::process_block_simd_arm_intrinsics(state, block) };
+ for block in blocks.chunks_exact(BLOCK_SIZE) {
+ unsafe { Self::process_block_simd_arm_intrinsics(state, block) };
+ }
+ return;
}
}
#[cfg(all(feature = "cpufeatures", target_arch = "aarch64"))]
{
if cpuid_sha256_aarch64::get() {
- return unsafe { Self::process_block_simd_arm_intrinsics(state, block) };
+ for block in blocks.chunks_exact(BLOCK_SIZE) {
+ unsafe { Self::process_block_simd_arm_intrinsics(state, block) };
+ }
+ return;
}
}
// fallback implementation without using any intrinsics
- Self::software_process_block(state, block)
+ Self::software_process_block(state, blocks)
}
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), any(feature = "std", feature = "cpufeatures")))]
#[target_feature(enable = "sha,sse2,ssse3,sse4.1")]
- unsafe fn process_block_simd_x86_intrinsics(state: &mut[u32; 8], block: &[u8; BLOCK_SIZE]) {
+ unsafe fn process_block_simd_x86_intrinsics(state: &mut[u32; 8], block: &[u8]) {
// Code translated and based on from
// https://github.com/noloader/SHA-Intrinsics/blob/4899efc81d1af159c1fd955936c673139f35aea9/sha256-x86.c
@@ -568,7 +579,7 @@ impl HashEngine {
#[cfg(all(target_arch = "aarch64", any(feature = "std", feature = "cpufeatures")))]
#[target_feature(enable = "sha2")]
- unsafe fn process_block_simd_arm_intrinsics(state: &mut[u32; 8], block: &[u8; BLOCK_SIZE]) {
+ unsafe fn process_block_simd_arm_intrinsics(state: &mut[u32; 8], block: &[u8]) {
// Code translated and based on from
// https://github.com/noloader/SHA-Intrinsics/blob/4e754bec921a9f281b69bd681ca0065763aa911c/sha256-arm.c
@@ -755,99 +766,101 @@ impl HashEngine {
}
// Algorithm copied from libsecp256k1
- fn software_process_block(state: &mut[u32; 8], block: &[u8; BLOCK_SIZE]) {
- debug_assert_eq!(block.len(), BLOCK_SIZE);
+ fn software_process_block(state: &mut[u32; 8], blocks: &[u8]) {
+ debug_assert!(!blocks.is_empty() && blocks.len() % BLOCK_SIZE == 0);
- let mut w = [0u32; 16];
- for (w_val, buff_bytes) in w.iter_mut().zip(block.bitcoin_as_chunks().0) {
- *w_val = u32::from_be_bytes(*buff_bytes);
- }
+ for block in blocks.chunks_exact(BLOCK_SIZE) {
+ let mut w = [0u32; 16];
+ for (w_val, buff_bytes) in w.iter_mut().zip(block.bitcoin_as_chunks().0) {
+ *w_val = u32::from_be_bytes(*buff_bytes);
+ }
+
+ let mut a = state[0];
+ let mut b = state[1];
+ let mut c = state[2];
+ let mut d = state[3];
+ let mut e = state[4];
+ let mut f = state[5];
+ let mut g = state[6];
+ let mut h = state[7];
+
+ round!(a, b, c, d, e, f, g, h, 0x428a2f98, w[0]);
+ round!(h, a, b, c, d, e, f, g, 0x71374491, w[1]);
+ round!(g, h, a, b, c, d, e, f, 0xb5c0fbcf, w[2]);
+ round!(f, g, h, a, b, c, d, e, 0xe9b5dba5, w[3]);
+ round!(e, f, g, h, a, b, c, d, 0x3956c25b, w[4]);
+ round!(d, e, f, g, h, a, b, c, 0x59f111f1, w[5]);
+ round!(c, d, e, f, g, h, a, b, 0x923f82a4, w[6]);
+ round!(b, c, d, e, f, g, h, a, 0xab1c5ed5, w[7]);
+ round!(a, b, c, d, e, f, g, h, 0xd807aa98, w[8]);
+ round!(h, a, b, c, d, e, f, g, 0x12835b01, w[9]);
+ round!(g, h, a, b, c, d, e, f, 0x243185be, w[10]);
+ round!(f, g, h, a, b, c, d, e, 0x550c7dc3, w[11]);
+ round!(e, f, g, h, a, b, c, d, 0x72be5d74, w[12]);
+ round!(d, e, f, g, h, a, b, c, 0x80deb1fe, w[13]);
+ round!(c, d, e, f, g, h, a, b, 0x9bdc06a7, w[14]);
+ round!(b, c, d, e, f, g, h, a, 0xc19bf174, w[15]);
+
+ round!(a, b, c, d, e, f, g, h, 0xe49b69c1, w[0], w[14], w[9], w[1]);
+ round!(h, a, b, c, d, e, f, g, 0xefbe4786, w[1], w[15], w[10], w[2]);
+ round!(g, h, a, b, c, d, e, f, 0x0fc19dc6, w[2], w[0], w[11], w[3]);
+ round!(f, g, h, a, b, c, d, e, 0x240ca1cc, w[3], w[1], w[12], w[4]);
+ round!(e, f, g, h, a, b, c, d, 0x2de92c6f, w[4], w[2], w[13], w[5]);
+ round!(d, e, f, g, h, a, b, c, 0x4a7484aa, w[5], w[3], w[14], w[6]);
+ round!(c, d, e, f, g, h, a, b, 0x5cb0a9dc, w[6], w[4], w[15], w[7]);
+ round!(b, c, d, e, f, g, h, a, 0x76f988da, w[7], w[5], w[0], w[8]);
+ round!(a, b, c, d, e, f, g, h, 0x983e5152, w[8], w[6], w[1], w[9]);
+ round!(h, a, b, c, d, e, f, g, 0xa831c66d, w[9], w[7], w[2], w[10]);
+ round!(g, h, a, b, c, d, e, f, 0xb00327c8, w[10], w[8], w[3], w[11]);
+ round!(f, g, h, a, b, c, d, e, 0xbf597fc7, w[11], w[9], w[4], w[12]);
+ round!(e, f, g, h, a, b, c, d, 0xc6e00bf3, w[12], w[10], w[5], w[13]);
+ round!(d, e, f, g, h, a, b, c, 0xd5a79147, w[13], w[11], w[6], w[14]);
+ round!(c, d, e, f, g, h, a, b, 0x06ca6351, w[14], w[12], w[7], w[15]);
+ round!(b, c, d, e, f, g, h, a, 0x14292967, w[15], w[13], w[8], w[0]);
+
+ round!(a, b, c, d, e, f, g, h, 0x27b70a85, w[0], w[14], w[9], w[1]);
+ round!(h, a, b, c, d, e, f, g, 0x2e1b2138, w[1], w[15], w[10], w[2]);
+ round!(g, h, a, b, c, d, e, f, 0x4d2c6dfc, w[2], w[0], w[11], w[3]);
+ round!(f, g, h, a, b, c, d, e, 0x53380d13, w[3], w[1], w[12], w[4]);
+ round!(e, f, g, h, a, b, c, d, 0x650a7354, w[4], w[2], w[13], w[5]);
+ round!(d, e, f, g, h, a, b, c, 0x766a0abb, w[5], w[3], w[14], w[6]);
+ round!(c, d, e, f, g, h, a, b, 0x81c2c92e, w[6], w[4], w[15], w[7]);
+ round!(b, c, d, e, f, g, h, a, 0x92722c85, w[7], w[5], w[0], w[8]);
+ round!(a, b, c, d, e, f, g, h, 0xa2bfe8a1, w[8], w[6], w[1], w[9]);
+ round!(h, a, b, c, d, e, f, g, 0xa81a664b, w[9], w[7], w[2], w[10]);
+ round!(g, h, a, b, c, d, e, f, 0xc24b8b70, w[10], w[8], w[3], w[11]);
+ round!(f, g, h, a, b, c, d, e, 0xc76c51a3, w[11], w[9], w[4], w[12]);
+ round!(e, f, g, h, a, b, c, d, 0xd192e819, w[12], w[10], w[5], w[13]);
+ round!(d, e, f, g, h, a, b, c, 0xd6990624, w[13], w[11], w[6], w[14]);
+ round!(c, d, e, f, g, h, a, b, 0xf40e3585, w[14], w[12], w[7], w[15]);
+ round!(b, c, d, e, f, g, h, a, 0x106aa070, w[15], w[13], w[8], w[0]);
- let mut a = state[0];
- let mut b = state[1];
- let mut c = state[2];
- let mut d = state[3];
- let mut e = state[4];
- let mut f = state[5];
- let mut g = state[6];
- let mut h = state[7];
-
- round!(a, b, c, d, e, f, g, h, 0x428a2f98, w[0]);
- round!(h, a, b, c, d, e, f, g, 0x71374491, w[1]);
- round!(g, h, a, b, c, d, e, f, 0xb5c0fbcf, w[2]);
- round!(f, g, h, a, b, c, d, e, 0xe9b5dba5, w[3]);
- round!(e, f, g, h, a, b, c, d, 0x3956c25b, w[4]);
- round!(d, e, f, g, h, a, b, c, 0x59f111f1, w[5]);
- round!(c, d, e, f, g, h, a, b, 0x923f82a4, w[6]);
- round!(b, c, d, e, f, g, h, a, 0xab1c5ed5, w[7]);
- round!(a, b, c, d, e, f, g, h, 0xd807aa98, w[8]);
- round!(h, a, b, c, d, e, f, g, 0x12835b01, w[9]);
- round!(g, h, a, b, c, d, e, f, 0x243185be, w[10]);
- round!(f, g, h, a, b, c, d, e, 0x550c7dc3, w[11]);
- round!(e, f, g, h, a, b, c, d, 0x72be5d74, w[12]);
- round!(d, e, f, g, h, a, b, c, 0x80deb1fe, w[13]);
- round!(c, d, e, f, g, h, a, b, 0x9bdc06a7, w[14]);
- round!(b, c, d, e, f, g, h, a, 0xc19bf174, w[15]);
-
- round!(a, b, c, d, e, f, g, h, 0xe49b69c1, w[0], w[14], w[9], w[1]);
- round!(h, a, b, c, d, e, f, g, 0xefbe4786, w[1], w[15], w[10], w[2]);
- round!(g, h, a, b, c, d, e, f, 0x0fc19dc6, w[2], w[0], w[11], w[3]);
- round!(f, g, h, a, b, c, d, e, 0x240ca1cc, w[3], w[1], w[12], w[4]);
- round!(e, f, g, h, a, b, c, d, 0x2de92c6f, w[4], w[2], w[13], w[5]);
- round!(d, e, f, g, h, a, b, c, 0x4a7484aa, w[5], w[3], w[14], w[6]);
- round!(c, d, e, f, g, h, a, b, 0x5cb0a9dc, w[6], w[4], w[15], w[7]);
- round!(b, c, d, e, f, g, h, a, 0x76f988da, w[7], w[5], w[0], w[8]);
- round!(a, b, c, d, e, f, g, h, 0x983e5152, w[8], w[6], w[1], w[9]);
- round!(h, a, b, c, d, e, f, g, 0xa831c66d, w[9], w[7], w[2], w[10]);
- round!(g, h, a, b, c, d, e, f, 0xb00327c8, w[10], w[8], w[3], w[11]);
- round!(f, g, h, a, b, c, d, e, 0xbf597fc7, w[11], w[9], w[4], w[12]);
- round!(e, f, g, h, a, b, c, d, 0xc6e00bf3, w[12], w[10], w[5], w[13]);
- round!(d, e, f, g, h, a, b, c, 0xd5a79147, w[13], w[11], w[6], w[14]);
- round!(c, d, e, f, g, h, a, b, 0x06ca6351, w[14], w[12], w[7], w[15]);
- round!(b, c, d, e, f, g, h, a, 0x14292967, w[15], w[13], w[8], w[0]);
-
- round!(a, b, c, d, e, f, g, h, 0x27b70a85, w[0], w[14], w[9], w[1]);
- round!(h, a, b, c, d, e, f, g, 0x2e1b2138, w[1], w[15], w[10], w[2]);
- round!(g, h, a, b, c, d, e, f, 0x4d2c6dfc, w[2], w[0], w[11], w[3]);
- round!(f, g, h, a, b, c, d, e, 0x53380d13, w[3], w[1], w[12], w[4]);
- round!(e, f, g, h, a, b, c, d, 0x650a7354, w[4], w[2], w[13], w[5]);
- round!(d, e, f, g, h, a, b, c, 0x766a0abb, w[5], w[3], w[14], w[6]);
- round!(c, d, e, f, g, h, a, b, 0x81c2c92e, w[6], w[4], w[15], w[7]);
- round!(b, c, d, e, f, g, h, a, 0x92722c85, w[7], w[5], w[0], w[8]);
- round!(a, b, c, d, e, f, g, h, 0xa2bfe8a1, w[8], w[6], w[1], w[9]);
- round!(h, a, b, c, d, e, f, g, 0xa81a664b, w[9], w[7], w[2], w[10]);
- round!(g, h, a, b, c, d, e, f, 0xc24b8b70, w[10], w[8], w[3], w[11]);
- round!(f, g, h, a, b, c, d, e, 0xc76c51a3, w[11], w[9], w[4], w[12]);
- round!(e, f, g, h, a, b, c, d, 0xd192e819, w[12], w[10], w[5], w[13]);
- round!(d, e, f, g, h, a, b, c, 0xd6990624, w[13], w[11], w[6], w[14]);
- round!(c, d, e, f, g, h, a, b, 0xf40e3585, w[14], w[12], w[7], w[15]);
- round!(b, c, d, e, f, g, h, a, 0x106aa070, w[15], w[13], w[8], w[0]);
-
- round!(a, b, c, d, e, f, g, h, 0x19a4c116, w[0], w[14], w[9], w[1]);
- round!(h, a, b, c, d, e, f, g, 0x1e376c08, w[1], w[15], w[10], w[2]);
- round!(g, h, a, b, c, d, e, f, 0x2748774c, w[2], w[0], w[11], w[3]);
- round!(f, g, h, a, b, c, d, e, 0x34b0bcb5, w[3], w[1], w[12], w[4]);
- round!(e, f, g, h, a, b, c, d, 0x391c0cb3, w[4], w[2], w[13], w[5]);
- round!(d, e, f, g, h, a, b, c, 0x4ed8aa4a, w[5], w[3], w[14], w[6]);
- round!(c, d, e, f, g, h, a, b, 0x5b9cca4f, w[6], w[4], w[15], w[7]);
- round!(b, c, d, e, f, g, h, a, 0x682e6ff3, w[7], w[5], w[0], w[8]);
- round!(a, b, c, d, e, f, g, h, 0x748f82ee, w[8], w[6], w[1], w[9]);
- round!(h, a, b, c, d, e, f, g, 0x78a5636f, w[9], w[7], w[2], w[10]);
- round!(g, h, a, b, c, d, e, f, 0x84c87814, w[10], w[8], w[3], w[11]);
- round!(f, g, h, a, b, c, d, e, 0x8cc70208, w[11], w[9], w[4], w[12]);
- round!(e, f, g, h, a, b, c, d, 0x90befffa, w[12], w[10], w[5], w[13]);
- round!(d, e, f, g, h, a, b, c, 0xa4506ceb, w[13], w[11], w[6], w[14]);
- round!(c, d, e, f, g, h, a, b, 0xbef9a3f7, w[14], w[12], w[7], w[15]);
- round!(b, c, d, e, f, g, h, a, 0xc67178f2, w[15], w[13], w[8], w[0]);
- let _ = w[15]; // silence "unnecessary assignment" lint in macro
-
- state[0] = state[0].wrapping_add(a);
- state[1] = state[1].wrapping_add(b);
- state[2] = state[2].wrapping_add(c);
- state[3] = state[3].wrapping_add(d);
- state[4] = state[4].wrapping_add(e);
- state[5] = state[5].wrapping_add(f);
- state[6] = state[6].wrapping_add(g);
- state[7] = state[7].wrapping_add(h);
+ round!(a, b, c, d, e, f, g, h, 0x19a4c116, w[0], w[14], w[9], w[1]);
+ round!(h, a, b, c, d, e, f, g, 0x1e376c08, w[1], w[15], w[10], w[2]);
+ round!(g, h, a, b, c, d, e, f, 0x2748774c, w[2], w[0], w[11], w[3]);
+ round!(f, g, h, a, b, c, d, e, 0x34b0bcb5, w[3], w[1], w[12], w[4]);
+ round!(e, f, g, h, a, b, c, d, 0x391c0cb3, w[4], w[2], w[13], w[5]);
+ round!(d, e, f, g, h, a, b, c, 0x4ed8aa4a, w[5], w[3], w[14], w[6]);
+ round!(c, d, e, f, g, h, a, b, 0x5b9cca4f, w[6], w[4], w[15], w[7]);
+ round!(b, c, d, e, f, g, h, a, 0x682e6ff3, w[7], w[5], w[0], w[8]);
+ round!(a, b, c, d, e, f, g, h, 0x748f82ee, w[8], w[6], w[1], w[9]);
+ round!(h, a, b, c, d, e, f, g, 0x78a5636f, w[9], w[7], w[2], w[10]);
+ round!(g, h, a, b, c, d, e, f, 0x84c87814, w[10], w[8], w[3], w[11]);
+ round!(f, g, h, a, b, c, d, e, 0x8cc70208, w[11], w[9], w[4], w[12]);
+ round!(e, f, g, h, a, b, c, d, 0x90befffa, w[12], w[10], w[5], w[13]);
+ round!(d, e, f, g, h, a, b, c, 0xa4506ceb, w[13], w[11], w[6], w[14]);
+ round!(c, d, e, f, g, h, a, b, 0xbef9a3f7, w[14], w[12], w[7], w[15]);
+ round!(b, c, d, e, f, g, h, a, 0xc67178f2, w[15], w[13], w[8], w[0]);
+ let _ = w[15]; // silence "unnecessary assignment" lint in macro
+
+ state[0] = state[0].wrapping_add(a);
+ state[1] = state[1].wrapping_add(b);
+ state[2] = state[2].wrapping_add(c);
+ state[3] = state[3].wrapping_add(d);
+ state[4] = state[4].wrapping_add(e);
+ state[5] = state[5].wrapping_add(f);
+ state[6] = state[6].wrapping_add(g);
+ state[7] = state[7].wrapping_add(h);
+ }
}
}
diff --git a/hashes/src/sha3_256/mod.rs b/hashes/src/sha3_256/mod.rs
index aa626196..c16f9688 100644
--- a/hashes/src/sha3_256/mod.rs
+++ b/hashes/src/sha3_256/mod.rs
@@ -182,7 +182,7 @@ impl HashEngine {
Self { h: KeccakState::new(), bytes_hashed: 0, buffer: [0; RATE] }
}
- fn absorb(state: &mut KeccakState, block: &[u8; RATE]) {
+ fn absorb(state: &mut KeccakState, block: &[u8]) {
for lane in 0..RATE_LANES {
let x = lane % 5;
let y = lane / 5;
@@ -193,9 +193,13 @@ impl HashEngine {
}
}
- fn process_block(state: &mut KeccakState, block: &[u8; RATE]) {
- Self::absorb(state, block);
- keccakf1600(state);
+ fn process_blocks(state: &mut KeccakState, blocks: &[u8]) {
+ debug_assert!(!blocks.is_empty() && blocks.len() % RATE == 0);
+
+ for block in blocks.chunks_exact(RATE) {
+ Self::absorb(state, block);
+ keccakf1600(state);
+ }
}
}
@@ -213,7 +217,7 @@ impl crate::HashEngine for HashEngine {
self.buffer[incomplete_block_len + 1..].fill(0);
self.buffer[incomplete_block_len] = 0x06;
self.buffer[RATE - 1] ^= 0x80;
- Self::process_block(&mut self.h, &self.buffer);
+ Self::process_blocks(&mut self.h, &self.buffer);
let mut out = [0u8; 32];
out[..8].copy_from_slice(&self.h.lane(0, 0).to_le_bytes());
diff --git a/hashes/src/sha512/crypto.rs b/hashes/src/sha512/crypto.rs
index a9b46adb..060da4fd 100644
--- a/hashes/src/sha512/crypto.rs
+++ b/hashes/src/sha512/crypto.rs
@@ -75,116 +75,118 @@ mod fast_hash {
impl HashEngine {
// Algorithm copied from libsecp256k1
- pub(crate) fn process_block(state: &mut[u64; 8], block: &[u8; BLOCK_SIZE]) {
- debug_assert_eq!(block.len(), BLOCK_SIZE);
-
- let mut w = [0u64; 16];
- for (w_val, buff_bytes) in w.iter_mut().zip(block.bitcoin_as_chunks().0) {
- *w_val = u64::from_be_bytes(*buff_bytes);
+ pub(crate) fn process_blocks(state: &mut[u64; 8], blocks: &[u8]) {
+ debug_assert!(!blocks.is_empty() && blocks.len() % BLOCK_SIZE == 0);
+
+ for block in blocks.chunks_exact(BLOCK_SIZE) {
+ let mut w = [0u64; 16];
+ for (w_val, buff_bytes) in w.iter_mut().zip(block.bitcoin_as_chunks().0) {
+ *w_val = u64::from_be_bytes(*buff_bytes);
+ }
+
+ let mut a = state[0];
+ let mut b = state[1];
+ let mut c = state[2];
+ let mut d = state[3];
+ let mut e = state[4];
+ let mut f = state[5];
+ let mut g = state[6];
+ let mut h = state[7];
+
+ round!(a, b, c, d, e, f, g, h, 0x428a2f98d728ae22, w[0]);
+ round!(h, a, b, c, d, e, f, g, 0x7137449123ef65cd, w[1]);
+ round!(g, h, a, b, c, d, e, f, 0xb5c0fbcfec4d3b2f, w[2]);
+ round!(f, g, h, a, b, c, d, e, 0xe9b5dba58189dbbc, w[3]);
+ round!(e, f, g, h, a, b, c, d, 0x3956c25bf348b538, w[4]);
+ round!(d, e, f, g, h, a, b, c, 0x59f111f1b605d019, w[5]);
+ round!(c, d, e, f, g, h, a, b, 0x923f82a4af194f9b, w[6]);
+ round!(b, c, d, e, f, g, h, a, 0xab1c5ed5da6d8118, w[7]);
+ round!(a, b, c, d, e, f, g, h, 0xd807aa98a3030242, w[8]);
+ round!(h, a, b, c, d, e, f, g, 0x12835b0145706fbe, w[9]);
+ round!(g, h, a, b, c, d, e, f, 0x243185be4ee4b28c, w[10]);
+ round!(f, g, h, a, b, c, d, e, 0x550c7dc3d5ffb4e2, w[11]);
+ round!(e, f, g, h, a, b, c, d, 0x72be5d74f27b896f, w[12]);
+ round!(d, e, f, g, h, a, b, c, 0x80deb1fe3b1696b1, w[13]);
+ round!(c, d, e, f, g, h, a, b, 0x9bdc06a725c71235, w[14]);
+ round!(b, c, d, e, f, g, h, a, 0xc19bf174cf692694, w[15]);
+
+ round!(a, b, c, d, e, f, g, h, 0xe49b69c19ef14ad2, w[0], w[14], w[9], w[1]);
+ round!(h, a, b, c, d, e, f, g, 0xefbe4786384f25e3, w[1], w[15], w[10], w[2]);
+ round!(g, h, a, b, c, d, e, f, 0x0fc19dc68b8cd5b5, w[2], w[0], w[11], w[3]);
+ round!(f, g, h, a, b, c, d, e, 0x240ca1cc77ac9c65, w[3], w[1], w[12], w[4]);
+ round!(e, f, g, h, a, b, c, d, 0x2de92c6f592b0275, w[4], w[2], w[13], w[5]);
+ round!(d, e, f, g, h, a, b, c, 0x4a7484aa6ea6e483, w[5], w[3], w[14], w[6]);
+ round!(c, d, e, f, g, h, a, b, 0x5cb0a9dcbd41fbd4, w[6], w[4], w[15], w[7]);
+ round!(b, c, d, e, f, g, h, a, 0x76f988da831153b5, w[7], w[5], w[0], w[8]);
+ round!(a, b, c, d, e, f, g, h, 0x983e5152ee66dfab, w[8], w[6], w[1], w[9]);
+ round!(h, a, b, c, d, e, f, g, 0xa831c66d2db43210, w[9], w[7], w[2], w[10]);
+ round!(g, h, a, b, c, d, e, f, 0xb00327c898fb213f, w[10], w[8], w[3], w[11]);
+ round!(f, g, h, a, b, c, d, e, 0xbf597fc7beef0ee4, w[11], w[9], w[4], w[12]);
+ round!(e, f, g, h, a, b, c, d, 0xc6e00bf33da88fc2, w[12], w[10], w[5], w[13]);
+ round!(d, e, f, g, h, a, b, c, 0xd5a79147930aa725, w[13], w[11], w[6], w[14]);
+ round!(c, d, e, f, g, h, a, b, 0x06ca6351e003826f, w[14], w[12], w[7], w[15]);
+ round!(b, c, d, e, f, g, h, a, 0x142929670a0e6e70, w[15], w[13], w[8], w[0]);
+
+ round!(a, b, c, d, e, f, g, h, 0x27b70a8546d22ffc, w[0], w[14], w[9], w[1]);
+ round!(h, a, b, c, d, e, f, g, 0x2e1b21385c26c926, w[1], w[15], w[10], w[2]);
+ round!(g, h, a, b, c, d, e, f, 0x4d2c6dfc5ac42aed, w[2], w[0], w[11], w[3]);
+ round!(f, g, h, a, b, c, d, e, 0x53380d139d95b3df, w[3], w[1], w[12], w[4]);
+ round!(e, f, g, h, a, b, c, d, 0x650a73548baf63de, w[4], w[2], w[13], w[5]);
+ round!(d, e, f, g, h, a, b, c, 0x766a0abb3c77b2a8, w[5], w[3], w[14], w[6]);
+ round!(c, d, e, f, g, h, a, b, 0x81c2c92e47edaee6, w[6], w[4], w[15], w[7]);
+ round!(b, c, d, e, f, g, h, a, 0x92722c851482353b, w[7], w[5], w[0], w[8]);
+ round!(a, b, c, d, e, f, g, h, 0xa2bfe8a14cf10364, w[8], w[6], w[1], w[9]);
+ round!(h, a, b, c, d, e, f, g, 0xa81a664bbc423001, w[9], w[7], w[2], w[10]);
+ round!(g, h, a, b, c, d, e, f, 0xc24b8b70d0f89791, w[10], w[8], w[3], w[11]);
+ round!(f, g, h, a, b, c, d, e, 0xc76c51a30654be30, w[11], w[9], w[4], w[12]);
+ round!(e, f, g, h, a, b, c, d, 0xd192e819d6ef5218, w[12], w[10], w[5], w[13]);
+ round!(d, e, f, g, h, a, b, c, 0xd69906245565a910, w[13], w[11], w[6], w[14]);
+ round!(c, d, e, f, g, h, a, b, 0xf40e35855771202a, w[14], w[12], w[7], w[15]);
+ round!(b, c, d, e, f, g, h, a, 0x106aa07032bbd1b8, w[15], w[13], w[8], w[0]);
+
+ round!(a, b, c, d, e, f, g, h, 0x19a4c116b8d2d0c8, w[0], w[14], w[9], w[1]);
+ round!(h, a, b, c, d, e, f, g, 0x1e376c085141ab53, w[1], w[15], w[10], w[2]);
+ round!(g, h, a, b, c, d, e, f, 0x2748774cdf8eeb99, w[2], w[0], w[11], w[3]);
+ round!(f, g, h, a, b, c, d, e, 0x34b0bcb5e19b48a8, w[3], w[1], w[12], w[4]);
+ round!(e, f, g, h, a, b, c, d, 0x391c0cb3c5c95a63, w[4], w[2], w[13], w[5]);
+ round!(d, e, f, g, h, a, b, c, 0x4ed8aa4ae3418acb, w[5], w[3], w[14], w[6]);
+ round!(c, d, e, f, g, h, a, b, 0x5b9cca4f7763e373, w[6], w[4], w[15], w[7]);
+ round!(b, c, d, e, f, g, h, a, 0x682e6ff3d6b2b8a3, w[7], w[5], w[0], w[8]);
+ round!(a, b, c, d, e, f, g, h, 0x748f82ee5defb2fc, w[8], w[6], w[1], w[9]);
+ round!(h, a, b, c, d, e, f, g, 0x78a5636f43172f60, w[9], w[7], w[2], w[10]);
+ round!(g, h, a, b, c, d, e, f, 0x84c87814a1f0ab72, w[10], w[8], w[3], w[11]);
+ round!(f, g, h, a, b, c, d, e, 0x8cc702081a6439ec, w[11], w[9], w[4], w[12]);
+ round!(e, f, g, h, a, b, c, d, 0x90befffa23631e28, w[12], w[10], w[5], w[13]);
+ round!(d, e, f, g, h, a, b, c, 0xa4506cebde82bde9, w[13], w[11], w[6], w[14]);
+ round!(c, d, e, f, g, h, a, b, 0xbef9a3f7b2c67915, w[14], w[12], w[7], w[15]);
+ round!(b, c, d, e, f, g, h, a, 0xc67178f2e372532b, w[15], w[13], w[8], w[0]);
+
+ round!(a, b, c, d, e, f, g, h, 0xca273eceea26619c, w[0], w[14], w[9], w[1]);
+ round!(h, a, b, c, d, e, f, g, 0xd186b8c721c0c207, w[1], w[15], w[10], w[2]);
+ round!(g, h, a, b, c, d, e, f, 0xeada7dd6cde0eb1e, w[2], w[0], w[11], w[3]);
+ round!(f, g, h, a, b, c, d, e, 0xf57d4f7fee6ed178, w[3], w[1], w[12], w[4]);
+ round!(e, f, g, h, a, b, c, d, 0x06f067aa72176fba, w[4], w[2], w[13], w[5]);
+ round!(d, e, f, g, h, a, b, c, 0x0a637dc5a2c898a6, w[5], w[3], w[14], w[6]);
+ round!(c, d, e, f, g, h, a, b, 0x113f9804bef90dae, w[6], w[4], w[15], w[7]);
+ round!(b, c, d, e, f, g, h, a, 0x1b710b35131c471b, w[7], w[5], w[0], w[8]);
+ round!(a, b, c, d, e, f, g, h, 0x28db77f523047d84, w[8], w[6], w[1], w[9]);
+ round!(h, a, b, c, d, e, f, g, 0x32caab7b40c72493, w[9], w[7], w[2], w[10]);
+ round!(g, h, a, b, c, d, e, f, 0x3c9ebe0a15c9bebc, w[10], w[8], w[3], w[11]);
+ round!(f, g, h, a, b, c, d, e, 0x431d67c49c100d4c, w[11], w[9], w[4], w[12]);
+ round!(e, f, g, h, a, b, c, d, 0x4cc5d4becb3e42b6, w[12], w[10], w[5], w[13]);
+ round!(d, e, f, g, h, a, b, c, 0x597f299cfc657e2a, w[13], w[11], w[6], w[14]);
+ round!(c, d, e, f, g, h, a, b, 0x5fcb6fab3ad6faec, w[14], w[12], w[7], w[15]);
+ round!(b, c, d, e, f, g, h, a, 0x6c44198c4a475817, w[15], w[13], w[8], w[0]);
+ let _ = w[15]; // silence "unnecessary assignment" lint in macro
+
+ state[0] = state[0].wrapping_add(a);
+ state[1] = state[1].wrapping_add(b);
+ state[2] = state[2].wrapping_add(c);
+ state[3] = state[3].wrapping_add(d);
+ state[4] = state[4].wrapping_add(e);
+ state[5] = state[5].wrapping_add(f);
+ state[6] = state[6].wrapping_add(g);
+ state[7] = state[7].wrapping_add(h);
}
-
- let mut a = state[0];
- let mut b = state[1];
- let mut c = state[2];
- let mut d = state[3];
- let mut e = state[4];
- let mut f = state[5];
- let mut g = state[6];
- let mut h = state[7];
-
- round!(a, b, c, d, e, f, g, h, 0x428a2f98d728ae22, w[0]);
- round!(h, a, b, c, d, e, f, g, 0x7137449123ef65cd, w[1]);
- round!(g, h, a, b, c, d, e, f, 0xb5c0fbcfec4d3b2f, w[2]);
- round!(f, g, h, a, b, c, d, e, 0xe9b5dba58189dbbc, w[3]);
- round!(e, f, g, h, a, b, c, d, 0x3956c25bf348b538, w[4]);
- round!(d, e, f, g, h, a, b, c, 0x59f111f1b605d019, w[5]);
- round!(c, d, e, f, g, h, a, b, 0x923f82a4af194f9b, w[6]);
- round!(b, c, d, e, f, g, h, a, 0xab1c5ed5da6d8118, w[7]);
- round!(a, b, c, d, e, f, g, h, 0xd807aa98a3030242, w[8]);
- round!(h, a, b, c, d, e, f, g, 0x12835b0145706fbe, w[9]);
- round!(g, h, a, b, c, d, e, f, 0x243185be4ee4b28c, w[10]);
- round!(f, g, h, a, b, c, d, e, 0x550c7dc3d5ffb4e2, w[11]);
- round!(e, f, g, h, a, b, c, d, 0x72be5d74f27b896f, w[12]);
- round!(d, e, f, g, h, a, b, c, 0x80deb1fe3b1696b1, w[13]);
- round!(c, d, e, f, g, h, a, b, 0x9bdc06a725c71235, w[14]);
- round!(b, c, d, e, f, g, h, a, 0xc19bf174cf692694, w[15]);
-
- round!(a, b, c, d, e, f, g, h, 0xe49b69c19ef14ad2, w[0], w[14], w[9], w[1]);
- round!(h, a, b, c, d, e, f, g, 0xefbe4786384f25e3, w[1], w[15], w[10], w[2]);
- round!(g, h, a, b, c, d, e, f, 0x0fc19dc68b8cd5b5, w[2], w[0], w[11], w[3]);
- round!(f, g, h, a, b, c, d, e, 0x240ca1cc77ac9c65, w[3], w[1], w[12], w[4]);
- round!(e, f, g, h, a, b, c, d, 0x2de92c6f592b0275, w[4], w[2], w[13], w[5]);
- round!(d, e, f, g, h, a, b, c, 0x4a7484aa6ea6e483, w[5], w[3], w[14], w[6]);
- round!(c, d, e, f, g, h, a, b, 0x5cb0a9dcbd41fbd4, w[6], w[4], w[15], w[7]);
- round!(b, c, d, e, f, g, h, a, 0x76f988da831153b5, w[7], w[5], w[0], w[8]);
- round!(a, b, c, d, e, f, g, h, 0x983e5152ee66dfab, w[8], w[6], w[1], w[9]);
- round!(h, a, b, c, d, e, f, g, 0xa831c66d2db43210, w[9], w[7], w[2], w[10]);
- round!(g, h, a, b, c, d, e, f, 0xb00327c898fb213f, w[10], w[8], w[3], w[11]);
- round!(f, g, h, a, b, c, d, e, 0xbf597fc7beef0ee4, w[11], w[9], w[4], w[12]);
- round!(e, f, g, h, a, b, c, d, 0xc6e00bf33da88fc2, w[12], w[10], w[5], w[13]);
- round!(d, e, f, g, h, a, b, c, 0xd5a79147930aa725, w[13], w[11], w[6], w[14]);
- round!(c, d, e, f, g, h, a, b, 0x06ca6351e003826f, w[14], w[12], w[7], w[15]);
- round!(b, c, d, e, f, g, h, a, 0x142929670a0e6e70, w[15], w[13], w[8], w[0]);
-
- round!(a, b, c, d, e, f, g, h, 0x27b70a8546d22ffc, w[0], w[14], w[9], w[1]);
- round!(h, a, b, c, d, e, f, g, 0x2e1b21385c26c926, w[1], w[15], w[10], w[2]);
- round!(g, h, a, b, c, d, e, f, 0x4d2c6dfc5ac42aed, w[2], w[0], w[11], w[3]);
- round!(f, g, h, a, b, c, d, e, 0x53380d139d95b3df, w[3], w[1], w[12], w[4]);
- round!(e, f, g, h, a, b, c, d, 0x650a73548baf63de, w[4], w[2], w[13], w[5]);
- round!(d, e, f, g, h, a, b, c, 0x766a0abb3c77b2a8, w[5], w[3], w[14], w[6]);
- round!(c, d, e, f, g, h, a, b, 0x81c2c92e47edaee6, w[6], w[4], w[15], w[7]);
- round!(b, c, d, e, f, g, h, a, 0x92722c851482353b, w[7], w[5], w[0], w[8]);
- round!(a, b, c, d, e, f, g, h, 0xa2bfe8a14cf10364, w[8], w[6], w[1], w[9]);
- round!(h, a, b, c, d, e, f, g, 0xa81a664bbc423001, w[9], w[7], w[2], w[10]);
- round!(g, h, a, b, c, d, e, f, 0xc24b8b70d0f89791, w[10], w[8], w[3], w[11]);
- round!(f, g, h, a, b, c, d, e, 0xc76c51a30654be30, w[11], w[9], w[4], w[12]);
- round!(e, f, g, h, a, b, c, d, 0xd192e819d6ef5218, w[12], w[10], w[5], w[13]);
- round!(d, e, f, g, h, a, b, c, 0xd69906245565a910, w[13], w[11], w[6], w[14]);
- round!(c, d, e, f, g, h, a, b, 0xf40e35855771202a, w[14], w[12], w[7], w[15]);
- round!(b, c, d, e, f, g, h, a, 0x106aa07032bbd1b8, w[15], w[13], w[8], w[0]);
-
- round!(a, b, c, d, e, f, g, h, 0x19a4c116b8d2d0c8, w[0], w[14], w[9], w[1]);
- round!(h, a, b, c, d, e, f, g, 0x1e376c085141ab53, w[1], w[15], w[10], w[2]);
- round!(g, h, a, b, c, d, e, f, 0x2748774cdf8eeb99, w[2], w[0], w[11], w[3]);
- round!(f, g, h, a, b, c, d, e, 0x34b0bcb5e19b48a8, w[3], w[1], w[12], w[4]);
- round!(e, f, g, h, a, b, c, d, 0x391c0cb3c5c95a63, w[4], w[2], w[13], w[5]);
- round!(d, e, f, g, h, a, b, c, 0x4ed8aa4ae3418acb, w[5], w[3], w[14], w[6]);
- round!(c, d, e, f, g, h, a, b, 0x5b9cca4f7763e373, w[6], w[4], w[15], w[7]);
- round!(b, c, d, e, f, g, h, a, 0x682e6ff3d6b2b8a3, w[7], w[5], w[0], w[8]);
- round!(a, b, c, d, e, f, g, h, 0x748f82ee5defb2fc, w[8], w[6], w[1], w[9]);
- round!(h, a, b, c, d, e, f, g, 0x78a5636f43172f60, w[9], w[7], w[2], w[10]);
- round!(g, h, a, b, c, d, e, f, 0x84c87814a1f0ab72, w[10], w[8], w[3], w[11]);
- round!(f, g, h, a, b, c, d, e, 0x8cc702081a6439ec, w[11], w[9], w[4], w[12]);
- round!(e, f, g, h, a, b, c, d, 0x90befffa23631e28, w[12], w[10], w[5], w[13]);
- round!(d, e, f, g, h, a, b, c, 0xa4506cebde82bde9, w[13], w[11], w[6], w[14]);
- round!(c, d, e, f, g, h, a, b, 0xbef9a3f7b2c67915, w[14], w[12], w[7], w[15]);
- round!(b, c, d, e, f, g, h, a, 0xc67178f2e372532b, w[15], w[13], w[8], w[0]);
-
- round!(a, b, c, d, e, f, g, h, 0xca273eceea26619c, w[0], w[14], w[9], w[1]);
- round!(h, a, b, c, d, e, f, g, 0xd186b8c721c0c207, w[1], w[15], w[10], w[2]);
- round!(g, h, a, b, c, d, e, f, 0xeada7dd6cde0eb1e, w[2], w[0], w[11], w[3]);
- round!(f, g, h, a, b, c, d, e, 0xf57d4f7fee6ed178, w[3], w[1], w[12], w[4]);
- round!(e, f, g, h, a, b, c, d, 0x06f067aa72176fba, w[4], w[2], w[13], w[5]);
- round!(d, e, f, g, h, a, b, c, 0x0a637dc5a2c898a6, w[5], w[3], w[14], w[6]);
- round!(c, d, e, f, g, h, a, b, 0x113f9804bef90dae, w[6], w[4], w[15], w[7]);
- round!(b, c, d, e, f, g, h, a, 0x1b710b35131c471b, w[7], w[5], w[0], w[8]);
- round!(a, b, c, d, e, f, g, h, 0x28db77f523047d84, w[8], w[6], w[1], w[9]);
- round!(h, a, b, c, d, e, f, g, 0x32caab7b40c72493, w[9], w[7], w[2], w[10]);
- round!(g, h, a, b, c, d, e, f, 0x3c9ebe0a15c9bebc, w[10], w[8], w[3], w[11]);
- round!(f, g, h, a, b, c, d, e, 0x431d67c49c100d4c, w[11], w[9], w[4], w[12]);
- round!(e, f, g, h, a, b, c, d, 0x4cc5d4becb3e42b6, w[12], w[10], w[5], w[13]);
- round!(d, e, f, g, h, a, b, c, 0x597f299cfc657e2a, w[13], w[11], w[6], w[14]);
- round!(c, d, e, f, g, h, a, b, 0x5fcb6fab3ad6faec, w[14], w[12], w[7], w[15]);
- round!(b, c, d, e, f, g, h, a, 0x6c44198c4a475817, w[15], w[13], w[8], w[0]);
- let _ = w[15]; // silence "unnecessary assignment" lint in macro
-
- state[0] = state[0].wrapping_add(a);
- state[1] = state[1].wrapping_add(b);
- state[2] = state[2].wrapping_add(c);
- state[3] = state[3].wrapping_add(d);
- state[4] = state[4].wrapping_add(e);
- state[5] = state[5].wrapping_add(f);
- state[6] = state[6].wrapping_add(g);
- state[7] = state[7].wrapping_add(h);
}
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.