pub struct Kmac256 { /* private fields */ }Expand description
KMAC256 implementation
Implementations§
Source§impl Kmac256
impl Kmac256
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) -> Kmac256Reader
pub fn xof(self) -> Kmac256Reader
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 Kmac256
impl AlgorithmName for Kmac256
Source§impl BlockSizeUser for Kmac256
impl BlockSizeUser for Kmac256
Source§impl BufferKindUser for Kmac256
impl BufferKindUser for Kmac256
Source§type BufferKind = Eager
type BufferKind = Eager
Source§impl CollisionResistance for Kmac256
impl CollisionResistance for Kmac256
impl HashMarker for Kmac256
Source§impl SerializableState for Kmac256
impl SerializableState for Kmac256
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 Kmac256
impl UpdateCore for Kmac256
Source§fn update_blocks(&mut self, blocks: &[Block<Self>])
fn update_blocks(&mut self, blocks: &[Block<Self>])
impl ZeroizeOnDrop for Kmac256
zeroize only.Auto Trait Implementations§
impl Freeze for Kmac256
impl RefUnwindSafe for Kmac256
impl Send for Kmac256
impl Sync for Kmac256
impl Unpin for Kmac256
impl UnsafeUnpin for Kmac256
impl UnwindSafe for Kmac256
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.