crate::ix!();
#[inline]
pub unsafe fn sha256_transform(
s: *mut u32,
mut chunk: *const u8,
mut blocks: usize,
) {
trace!(
target: "sha256",
total_blocks = blocks,
"sha256_transform: starting batch"
);
while blocks != 0 {
sha256_transform_block(s, chunk);
chunk = chunk.add(64);
blocks -= 1;
trace!(
target: "sha256",
remaining_blocks = blocks,
"sha256_transform: completed block"
);
}
}
#[cfg(test)]
mod sha256_transform_validation {
use super::*;
#[traced_test]
fn state_after_each_block_matches_reference() {
for blocks in 0..=8 {
let mut state = fixtures::INIT;
unsafe {
sha256_transform(
state.as_mut_ptr(),
fixtures::SELF_TEST_DATA.as_ptr().add(1), blocks,
);
}
assert_eq!(
state, fixtures::COMP_STATES[blocks],
"state mismatch after {} block(s)",
blocks
);
}
}
}