Coverage Report

Created: 2026-12-01 06:53

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/sha1-0.10.7/src/compress.rs
Line
Count
Source
1
use crate::{Block, BlockSizeUser, Sha1Core};
2
use digest::typenum::Unsigned;
3
4
cfg_if::cfg_if! {
5
    if #[cfg(feature = "force-soft")] {
6
        mod soft;
7
        use soft::compress as compress_inner;
8
    } else if #[cfg(all(feature = "loongarch64_asm", target_arch = "loongarch64"))] {
9
        mod loongarch64_asm;
10
        use loongarch64_asm::compress as compress_inner;
11
    } else if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
12
        mod soft;
13
        mod x86;
14
        use x86::compress as compress_inner;
15
    } else {
16
        mod soft;
17
        use soft::compress as compress_inner;
18
    }
19
}
20
21
const BLOCK_SIZE: usize = <Sha1Core as BlockSizeUser>::BlockSize::USIZE;
22
23
/// SHA-1 compression function
24
#[cfg_attr(docsrs, doc(cfg(feature = "compress")))]
25
21.0M
pub fn compress(state: &mut [u32; 5], blocks: &[Block<Sha1Core>]) {
26
    // SAFETY: GenericArray<u8, U64> and [u8; 64] have
27
    // exactly the same memory layout
28
21.0M
    let blocks: &[[u8; BLOCK_SIZE]] =
29
21.0M
        unsafe { &*(blocks as *const _ as *const [[u8; BLOCK_SIZE]]) };
30
21.0M
    compress_inner(state, blocks);
31
21.0M
}