pub struct CShake128 { /* private fields */ }Expand description
SP 800-185 cSHAKE128: SHAKE128 with a customization string.
Implementations§
Source§impl CShake128
impl CShake128
Sourcepub fn new(n: &[u8], s: &[u8]) -> Self
pub fn new(n: &[u8], s: &[u8]) -> Self
Start a cSHAKE with a function name n and customization s.
n is reserved for NIST-defined functions — KMAC passes
"KMAC". Application customization belongs in s.
With both empty this is plain SHAKE, per SP 800-185 section 3.3, including the domain separator.
Sourcepub fn finalize_xof(self, out: &mut [u8])
pub fn finalize_xof(self, out: &mut [u8])
Squeeze out.len() bytes.
Sourcepub fn absorb_bytepadded_string(&mut self, s: &[u8])
pub fn absorb_bytepadded_string(&mut self, s: &[u8])
Absorb bytepad(encode_string(s), RATE).
KMAC prefixes its message with the key encoded exactly this way.
It is exposed here rather than rebuilt in ic-mac because the
padding width is the sponge rate, which is cSHAKE’s property and
not the caller’s to know.
Trait Implementations§
Source§impl SelfTest for CShake128
impl SelfTest for CShake128
Source§fn self_test() -> Result<()>
fn self_test() -> Result<()>
Two checks, neither of which needs a vector this code produced.
With no customization cSHAKE must equal SHAKE exactly, and SHAKE has its own CAST against a published FIPS 202 answer — so this inherits that evidence. Then customization must change the output, which catches a build where the prefix was silently dropped and every customized call collapsed onto plain SHAKE.