pub struct Polyval(/* private fields */);Expand description
An implementation of POLYVAL.
POLYVAL is similar to GHASH. It operates in GF(2¹²⁸)
defined by the irreducible polynomial
x^128 + x^127 + x^126 + x^121 + 1The field has characteristic 2, so addition is performed with XOR. Multiplication is polynomial multiplication reduced modulo the polynomial.
For more information on POLYVAL, see RFC 8452.
Implementations§
Source§impl Polyval
impl Polyval
Sourcepub fn new(key: &[u8; 16]) -> Option<Self>
pub fn new(key: &[u8; 16]) -> Option<Self>
Creates a new hash instance.
It returns None if key is all zeroes.
Sourcepub fn new_unchecked(key: &[u8; 16]) -> Self
pub fn new_unchecked(key: &[u8; 16]) -> Self
Creates a hash instance from a known non-zero key.
§Warning
Only use this method if key is known to be
non-zero. Using an all zero key fixes the output
to zero, regardless of the input.
Sourcepub fn update_block(&mut self, block: &[u8; 16])
pub fn update_block(&mut self, block: &[u8; 16])
Writes a single block to the running hash.
Sourcepub fn update_blocks(&mut self, blocks: &[[u8; 16]])
pub fn update_blocks(&mut self, blocks: &[[u8; 16]])
Writes one or more blocks to the running hash.
Sourcepub fn update_padded(&mut self, blocks: &[u8])
pub fn update_padded(&mut self, blocks: &[u8])
Writes one or more blocks to the running hash.
If the length of blocks is non-zero, it’s
padded to the lowest multiple of
BLOCK_SIZE.
Sourcepub fn verify(self, expected_tag: &Tag) -> Choice
pub fn verify(self, expected_tag: &Tag) -> Choice
Reports whether the current authentication tag matches
expected_tag.
Sourcepub fn export(&self) -> PolyvalState
Available on crate feature experimental only.
pub fn export(&self) -> PolyvalState
experimental only.Exports the current state.
Sourcepub fn reset(&mut self, state: &PolyvalState)
Available on crate feature experimental only.
pub fn reset(&mut self, state: &PolyvalState)
experimental only.Resets the hash to state.
Sourcepub fn current_tag(&self) -> Tag
Available on crate feature experimental only.
pub fn current_tag(&self) -> Tag
experimental only.Returns the current authentication tag without consuming the hash.
Trait Implementations§
impl ZeroizeOnDrop for Polyval
zeroize only.