pub struct Kmac128 { /* private fields */ }Expand description
KMAC128 implementation
Implementations§
Source§impl Kmac128
impl Kmac128
Sourcepub fn new(key: &[u8], custom: &[u8]) -> Self
pub fn new(key: &[u8], custom: &[u8]) -> Self
Creates a new KMAC instance with the given key and customization string
Sourcepub fn finalize(self, output: &mut [u8]) -> Option<()>
pub fn finalize(self, output: &mut [u8]) -> Option<()>
Finalize with specified output length.
output.len() must not exceed MAX_SP800185_FIXED_OUTPUT_BYTES. For longer
output, use Self::xof.
Returns None if output.len() is greater than
MAX_SP800185_FIXED_OUTPUT_BYTES.
Sourcepub fn verify(self, expected: &[u8]) -> Choice
pub fn verify(self, expected: &[u8]) -> Choice
Finalize and compare the MAC to expected in constant time.
The MAC output length is expected.len() (same encoding as Self::finalize
with an output buffer of that length). The computed MAC is zeroized before
returning.
If expected.len() is greater than MAX_SP800185_FIXED_OUTPUT_BYTES, this
returns a failed comparison without allocating (or finalizing with that length), so
attacker-controlled lengths cannot force large allocations.
Combine or inspect the result with subtle APIs before branching on validity if
control-flow timing is a concern.
Sourcepub fn finalize_with_length(self, output_len: usize) -> Option<Vec<u8>>
pub fn finalize_with_length(self, output_len: usize) -> Option<Vec<u8>>
Finalize with specified output length and return as Vec.
Returns None if output_len is greater than MAX_SP800185_FIXED_OUTPUT_BYTES
(no allocation). For longer output, use Self::xof.
Sourcepub fn xof(self) -> Kmac128Reader
pub fn xof(self) -> Kmac128Reader
Returns an XOF reader for variable-length output.
SP 800-185 encodes XOF mode with right_encode(0) (output bit length zero) before
squeezing.
This consumes self and finalizes the sponge; you cannot call Self::update
afterward on this value.
Trait Implementations§
Source§impl AlgorithmName for Kmac128
impl AlgorithmName for Kmac128
Source§impl BlockSizeUser for Kmac128
impl BlockSizeUser for Kmac128
Source§impl BufferKindUser for Kmac128
impl BufferKindUser for Kmac128
Source§type BufferKind = Eager
type BufferKind = Eager
Source§impl CollisionResistance for Kmac128
impl CollisionResistance for Kmac128
impl HashMarker for Kmac128
Source§impl SerializableState for Kmac128
impl SerializableState for Kmac128
Source§type SerializedStateSize = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>, B1>, B0>, B0>, B0>, B0>
type SerializedStateSize = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>, B1>, B0>, B0>, B0>, B0>
Source§fn serialize(&self) -> SerializedState<Self>
fn serialize(&self) -> SerializedState<Self>
Source§fn deserialize(
serialized_state: &SerializedState<Self>,
) -> Result<Self, DeserializeStateError>
fn deserialize( serialized_state: &SerializedState<Self>, ) -> Result<Self, DeserializeStateError>
Source§impl UpdateCore for Kmac128
impl UpdateCore for Kmac128
Source§fn update_blocks(&mut self, blocks: &[Block<Self>])
fn update_blocks(&mut self, blocks: &[Block<Self>])
impl ZeroizeOnDrop for Kmac128
zeroize only.Auto Trait Implementations§
impl Freeze for Kmac128
impl RefUnwindSafe for Kmac128
impl Send for Kmac128
impl Sync for Kmac128
impl Unpin for Kmac128
impl UnsafeUnpin for Kmac128
impl UnwindSafe for Kmac128
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SmallBlockSizeUser for T
impl<T> SmallBlockSizeUser for T
Source§type _BlockSize = <T as BlockSizeUser>::BlockSize
type _BlockSize = <T as BlockSizeUser>::BlockSize
<Self as BlockSizeUser>::BlockSize.