Trait digest::core_api::VariableOutputCore
source · [−]pub trait VariableOutputCore: UpdateCore + OutputSizeUser + BufferKindUser + Sized where
Self::BlockSize: IsLess<U256>,
Le<Self::BlockSize, U256>: NonZero, {
const TRUNC_SIDE: TruncSide;
fn new(output_size: usize) -> Result<Self, InvalidOutputSize>;
fn finalize_variable_core(
&mut self,
buffer: &mut Buffer<Self>,
out: &mut Output<Self>
);
}
Expand description
Core trait for hash functions with variable output size.
Maximum output size is equal to OutputSizeUser::OutputSize
.
Users are expected to truncate result returned by the
finalize_variable_core
to output_size
passed to the new
method
during construction. Truncation side is defined by the TRUNC_SIDE
associated constant.
Required Associated Constants
const TRUNC_SIDE: TruncSide
const TRUNC_SIDE: TruncSide
Side which should be used in a truncated result.
Required Methods
fn new(output_size: usize) -> Result<Self, InvalidOutputSize>
fn new(output_size: usize) -> Result<Self, InvalidOutputSize>
Initialize hasher state for given output size.
Returns InvalidOutputSize
if output_size
is not valid for
the algorithm, e.g. if it’s bigger than the OutputSize
associated type.
fn finalize_variable_core(
&mut self,
buffer: &mut Buffer<Self>,
out: &mut Output<Self>
)
fn finalize_variable_core(
&mut self,
buffer: &mut Buffer<Self>,
out: &mut Output<Self>
)
Finalize hasher and write full hashing result into the out
buffer.
The result must be truncated to output_size
used during hasher
construction. Truncation side is defined by the TRUNC_SIDE
associated constant.