Skip to main content

bmw_hash/
lib.rs

1#![no_std]
2
3mod compress;
4mod consts;
5mod state;
6
7pub use digest::Digest;
8
9use consts::IV512;
10use digest::consts::U64;
11use digest::{FixedOutput, HashMarker, Output, OutputSizeUser, Reset, Update};
12use state::BmwBigContext;
13
14#[derive(Clone)]
15pub struct Bmw512(BmwBigContext);
16
17impl Default for Bmw512 {
18    fn default() -> Self {
19        Self(BmwBigContext::new(&IV512))
20    }
21}
22
23impl HashMarker for Bmw512 {}
24
25impl OutputSizeUser for Bmw512 {
26    type OutputSize = U64;
27}
28
29impl Update for Bmw512 {
30    fn update(&mut self, data: &[u8]) {
31        self.0.update(data);
32    }
33}
34
35impl FixedOutput for Bmw512 {
36    fn finalize_into(self, out: &mut Output<Self>) {
37        let result = self.0.finalize();
38        out.copy_from_slice(&result);
39    }
40}
41
42impl Reset for Bmw512 {
43    fn reset(&mut self) {
44        self.0 = BmwBigContext::new(&IV512);
45    }
46}