libcrux_traits/
lib.rs

1#![no_std]
2
3extern crate alloc;
4
5/// A Hash algorithm returning hashes of length `HASH_LEN`.
6pub trait Digest<const HASH_LEN: usize> {
7    /// Writes the digest for the given input byte slice, into `digest` in immediate mode.
8    fn hash(digest: &mut [u8], payload: &[u8]);
9
10    /// Add the `payload` to the digest.
11    fn update(&mut self, payload: &[u8]);
12
13    /// Writes the digest into `digest`.
14    ///
15    /// Note that the digest state can be continued to be used, to extend the
16    /// digest.
17    fn finish(&self, digest: &mut [u8; HASH_LEN]);
18
19    /// Reset the digest state.
20    fn reset(&mut self);
21}
22
23pub mod kem;