Coverage Report

Created: 2026-02-14 06:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/sha2-0.10.8/src/sha512.rs
Line
Count
Source
1
use digest::{generic_array::GenericArray, typenum::U128};
2
3
cfg_if::cfg_if! {
4
    if #[cfg(feature = "force-soft")] {
5
        mod soft;
6
        use soft::compress;
7
    } else if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
8
        #[cfg(not(feature = "asm"))]
9
        mod soft;
10
        #[cfg(feature = "asm")]
11
        mod soft {
12
            pub(crate) fn compress(state: &mut [u64; 8], blocks: &[[u8; 128]]) {
13
                sha2_asm::compress512(state, blocks);
14
            }
15
        }
16
        mod x86;
17
        use x86::compress;
18
    } else if #[cfg(all(feature = "asm", target_arch = "aarch64"))] {
19
        mod soft;
20
        mod aarch64;
21
        use aarch64::compress;
22
    } else if #[cfg(all(feature = "loongarch64_asm", target_arch = "loongarch64"))] {
23
        mod loongarch64_asm;
24
        use loongarch64_asm::compress;
25
    } else {
26
        mod soft;
27
        use soft::compress;
28
    }
29
}
30
31
/// Raw SHA-512 compression function.
32
///
33
/// This is a low-level "hazmat" API which provides direct access to the core
34
/// functionality of SHA-512.
35
#[cfg_attr(docsrs, doc(cfg(feature = "compress")))]
36
0
pub fn compress512(state: &mut [u64; 8], blocks: &[GenericArray<u8, U128>]) {
37
    // SAFETY: GenericArray<u8, U64> and [u8; 64] have
38
    // exactly the same memory layout
39
0
    let p = blocks.as_ptr() as *const [u8; 128];
40
0
    let blocks = unsafe { core::slice::from_raw_parts(p, blocks.len()) };
41
0
    compress(state, blocks)
42
0
}