libcrux_traits/digest/
arrayref.rs1#[derive(Debug, PartialEq)]
6pub enum HashError {
8 InvalidPayloadLength,
10 Unknown,
12}
13
14impl core::fmt::Display for HashError {
15 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
16 let text = match self {
17 HashError::InvalidPayloadLength => "the length of the provided payload is invalid",
18 HashError::Unknown => "indicates an unknown error",
19 };
20
21 f.write_str(text)
22 }
23}
24
25#[cfg(feature = "error-in-core")]
26mod error_in_core {
27
28 impl core::error::Error for super::HashError {}
29}
30
31pub trait DigestIncremental<const OUTPUT_LEN: usize>: super::DigestIncrementalBase {
33 fn finish(state: &mut Self::IncrementalState, digest: &mut [u8; OUTPUT_LEN]);
37}
38
39pub trait Hash<const OUTPUT_LEN: usize> {
41 fn hash(digest: &mut [u8; OUTPUT_LEN], payload: &[u8]) -> Result<(), HashError>;
43}