1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
use crate::InvalidOutputSize;
use core::fmt;
use generic_array::{ArrayLength, GenericArray};
mod ct_variable;
mod rt_variable;
mod update;
mod xof_reader;
pub use ct_variable::CtVariableCoreWrapper;
pub use rt_variable::RtVariableCoreWrapper;
pub use update::UpdateCoreWrapper;
pub use xof_reader::XofReaderCoreWrapper;
pub trait UpdateCore {
type BlockSize: ArrayLength<u8>;
fn update_blocks(&mut self, blocks: &[GenericArray<u8, Self::BlockSize>]);
}
pub trait FixedOutputCore: UpdateCore {
type OutputSize: ArrayLength<u8>;
fn finalize_fixed_core(
&mut self,
buffer: &mut block_buffer::BlockBuffer<Self::BlockSize>,
out: &mut GenericArray<u8, Self::OutputSize>,
);
}
pub trait ExtendableOutputCore: UpdateCore {
type ReaderCore: XofReaderCore;
fn finalize_xof_core(
&mut self,
buffer: &mut block_buffer::BlockBuffer<Self::BlockSize>,
) -> Self::ReaderCore;
}
pub trait XofReaderCore {
type BlockSize: ArrayLength<u8>;
fn read_block(&mut self) -> GenericArray<u8, Self::BlockSize>;
}
pub trait VariableOutputCore: UpdateCore + Sized {
type MaxOutputSize: ArrayLength<u8>;
fn new(output_size: usize) -> Result<Self, InvalidOutputSize>;
fn finalize_variable_core(
&mut self,
buffer: &mut block_buffer::BlockBuffer<Self::BlockSize>,
output_size: usize,
f: impl FnOnce(&[u8]),
);
}
pub trait AlgorithmName {
fn write_alg_name(f: &mut fmt::Formatter<'_>) -> fmt::Result;
}