pub struct Kmac256 { /* private fields */ }Expand description
SP 800-185 KMAC256, offering 256-bit security.
Implementations§
Source§impl Kmac256
impl Kmac256
Sourcepub fn new(key: &[u8], custom: &[u8]) -> Self
pub fn new(key: &[u8], custom: &[u8]) -> Self
Start a KMAC with key and a customization string.
Pass an empty custom when the key has only one use.
Sourcepub fn finalize(self, out: &mut [u8]) -> Result<()>
pub fn finalize(self, out: &mut [u8]) -> Result<()>
Produce a tag of exactly out.len() bytes.
The length is bound into the computation, so tags of different
lengths over the same input are unrelated. Refuses with
ModuleErrorState once the module has failed.
Sourcepub fn finalize_xof(self, out: &mut [u8]) -> Result<()>
pub fn finalize_xof(self, out: &mut [u8]) -> Result<()>
Produce an arbitrary-length stream instead of a fixed tag.
Encodes a length of zero, per SP 800-185 section 4.3.1. Refuses
with ModuleErrorState once the module has failed.
Sourcepub fn mac(key: &[u8], custom: &[u8], data: &[u8], out: &mut [u8]) -> Result<()>
pub fn mac(key: &[u8], custom: &[u8], data: &[u8], out: &mut [u8]) -> Result<()>
One-shot fixed-length tag.
Trait Implementations§
Source§impl SelfTest for Kmac256
impl SelfTest for Kmac256
Source§fn self_test() -> Result<()>
fn self_test() -> Result<()>
§Provenance
No pinned vector. The unit tests check KMAC against an independent construction from SP 800-185’s own definition — stronger evidence than a value this code produced — and cSHAKE beneath it is checked against a Keccak written from FIPS 202. docs/FIPS.md records that. What this adds at startup is that the code still computes what it computed when those tests last ran, and that its structural properties hold.