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;
}