lib.rs (1011B)
1 // Copyright 2023 Cryspen Sarl 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 9 #![no_std] 10 11 extern crate alloc; 12 13 // NOTE: This Digest trait and the new `digest` trait APIs overlap to some extent. 14 // See issue #1039 15 /// A Hash algorithm returning hashes of length `HASH_LEN`. 16 pub trait Digest<const HASH_LEN: usize> { 17 /// Writes the digest for the given input byte slice, into `digest` in immediate mode. 18 fn hash(digest: &mut [u8], payload: &[u8]); 19 20 /// Add the `payload` to the digest. 21 fn update(&mut self, payload: &[u8]); 22 23 /// Writes the digest into `digest`. 24 /// 25 /// Note that the digest state can be continued to be used, to extend the 26 /// digest. 27 fn finish(&self, digest: &mut [u8; HASH_LEN]); 28 29 /// Reset the digest state. 30 fn reset(&mut self); 31 } 32 33 pub mod digest; 34 pub mod kem;