1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! SHA-512 RISC-V Zknh kernel.
//!
//! Uses the RISC-V Scalar Cryptographic Hash extension (Zknh) instructions
//! `sha512sig0`, `sha512sig1`, `sha512sum0`, `sha512sum1` to accelerate the
//! sigma/sum operations in SHA-512 compression. Each replaces a 3-instruction
//! rotate-shift-xor sequence with a single dedicated instruction.
//!
//! Expected speedup: ~1.4-1.75x over the portable scalar implementation.
//!
//! # Safety
//!
//! All functions require the `zknh` target feature.
// Fixed-size arrays + compression schedule
use ;
use BLOCK_LEN;
// Safe wrappers for the unsafe Zknh intrinsics.
// SAFETY: only called from within `compress_blocks_zknh` which has
// `#[target_feature(enable = "zknh")]`, guaranteeing the feature is available.
/// SHA-512 multi-block compression using Zknh scalar crypto instructions.
///
/// # Safety
///
/// Caller must ensure `zknh` CPU feature is available.
pub unsafe