KMAC
NIST's Keccak-based MAC from SP 800-185, with optional arbitrary-length output
Overview
KMAC is a keyed message authentication code defined by NIST in SP 800-185, built directly on cSHAKE. Because the Keccak sponge is not vulnerable to length-extension, KMAC needs only a single pass over the key and message rather than HMAC's nested structure.
KMAC prefixes the encoded key, padded to the sponge rate, to the message, appends the requested output length, and hashes the result with cSHAKE using the function name "KMAC" and an optional customisation string for domain separation. Because the output length is part of the input, requesting a different length produces an unrelated tag rather than a prefix.
NextSSL includes KMAC128 and KMAC256, based on cSHAKE128 and cSHAKE256, and their XOF variants KMACXOF128 and KMACXOF256, which encode the output length as zero so that arbitrary-length output can be read as a stream. KMAC is simpler and often faster than HMAC-SHA3, since the key is processed once in a padded prefix block and no outer hash is needed. It can also serve as a key derivation function, as NIST SP 800-108 allows.
History
2016–2016Specified in NIST SP 800-185
Security notes
KMAC inherits its security from Keccak, with no known weaknesses. The key should be at least as long as the target security level: 128 bits for KMAC128 and 256 bits for KMAC256.
Typical uses
Variants in NextSSL
4| Algorithm | Tier | Sizes (bytes) | Standards | API |
|---|---|---|---|---|
| Kmac128 kmac128 |
standard FIPS | key 1–268435456 · tag 16–1024 | NIST SP 800-185 | safe |
| Kmac256 kmac256 |
standard FIPS | key 1–268435456 · tag 16–1024 | NIST SP 800-185 | safe |
| Kmacxof128 kmacxof128 |
standard FIPS | key 1–268435456 · tag 16–1024 | NIST SP 800-185 | safe |
| Kmacxof256 kmacxof256 |
standard FIPS | key 1–268435456 · tag 16–1024 | NIST SP 800-185 | safe |
Frequently asked questions
Which KMAC variants does NextSSL include?
NextSSL registers 4 KMAC variants: kmac128, kmac256, kmacxof128, kmacxof256.
Families with similar names
Other message authentication codes
All 30Related
NIST SP 800-90A deterministic random bit generator built on HMAC
ParallelHashAn SP 800-185 hash that splits input into blocks so cSHAKE can process them in parallel
SHA-3 and KeccakThe Keccak sponge, standardised by NIST in FIPS 202 as a structural alternative to SHA-2
HMACThe standard way to build a MAC from a cryptographic hash (RFC 2104, FIPS 198-1)
cSHAKECustomisable SHAKE from SP 800-185, adding function-name and customisation strings
SHA-3 and KeccakThe Keccak sponge, standardised by NIST in FIPS 202 as a structural alternative to SHA-2