libcrux_traits/lib.rs
1#![no_std]
2
3extern crate alloc;
4
5// NOTE: This Digest trait and the new `digest` trait APIs overlap to some extent.
6// See issue #1039
7/// A Hash algorithm returning hashes of length `HASH_LEN`.
8pub trait Digest<const HASH_LEN: usize> {
9 /// Writes the digest for the given input byte slice, into `digest` in immediate mode.
10 fn hash(digest: &mut [u8], payload: &[u8]);
11
12 /// Add the `payload` to the digest.
13 fn update(&mut self, payload: &[u8]);
14
15 /// Writes the digest into `digest`.
16 ///
17 /// Note that the digest state can be continued to be used, to extend the
18 /// digest.
19 fn finish(&self, digest: &mut [u8; HASH_LEN]);
20
21 /// Reset the digest state.
22 fn reset(&mut self);
23}
24
25pub mod aead;
26pub mod digest;
27pub mod ecdh;
28pub mod kem;
29
30pub use libcrux_secrets;