Trait universal_hash::UniversalHash
source · pub trait UniversalHash: Clone {
type BlockSize: ArrayLength<u8>;
// Required methods
fn update(&mut self, block: &Block<Self>);
fn reset(&mut self);
fn finalize(self) -> Output<Self>;
// Provided methods
fn update_padded(&mut self, data: &[u8]) { ... }
fn finalize_reset(&mut self) -> Output<Self> { ... }
fn verify(self, other: &Block<Self>) -> Result<(), Error> { ... }
}
Expand description
The UniversalHash
trait defines a generic interface for universal hash
functions.
Required Associated Types§
sourcetype BlockSize: ArrayLength<u8>
type BlockSize: ArrayLength<u8>
Size of the inputs to and outputs from the universal hash function
Required Methods§
sourcefn reset(&mut self)
fn reset(&mut self)
Reset UniversalHash
instance.
sourcefn finalize(self) -> Output<Self>
fn finalize(self) -> Output<Self>
Obtain the Output
of a UniversalHash
function and consume it.
Provided Methods§
sourcefn update_padded(&mut self, data: &[u8])
fn update_padded(&mut self, data: &[u8])
Input data into the universal hash function. If the length of the
data is not a multiple of the block size, the remaining data is
padded with zeroes up to the BlockSize
.
This approach is frequently used by AEAD modes which use Message Authentication Codes (MACs) based on universal hashing.
sourcefn finalize_reset(&mut self) -> Output<Self>
fn finalize_reset(&mut self) -> Output<Self>
Obtain the Output
of a UniversalHash
computation and reset it back
to its initial state.