Kmacxof256
NIST's Keccak-based MAC from SP 800-185, with optional arbitrary-length output
About Kmacxof256
Kmacxof256 is one of 4 KMAC variants in the NextSSL registry, a message authentication code. It uses a 1–268,435,456-byte key and a 16–1,024-byte authentication tag. It takes the parameter custom. Its registry entry cites NIST SP 800-185. NextSSL lists it in the standard tier and exposes it through the safe API.
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
Sizes
| Field | Bytes | Meaning |
|---|---|---|
| key | 1 – 268,435,456 | Secret key |
| tag | 16 – 1,024 | Authentication tag |
Parameters
| Name | Type | Range | Default | Required |
|---|---|---|---|---|
| custom | bytes | 0 – 65536 | — | no |
Parameters are passed as a string, for example nextssl_mac("hmac", "hash=sha512", …). Omitted parameters take their declared default.
Use it
from nextssl_demo import NextSSL
ns = NextSSL() # safe API: safe and standard tiers
key = ns.random(1)
tag = ns.call("mac", "kmacxof256", None, key, b"message", 0)[0]
ok = ns.check("mac_verify", "kmacxof256", None, key, b"message", tag)
nextssl_mac("kmacxof256", NULL, key, data, 0, tag);
nextssl_mac_verify("kmacxof256", NULL, key, data, tag);
use nextssl_core::Params;
use nextssl_registry::{self as reg, Policy};
let alg = reg::new_mac_in(reg::all(), Policy::Safe, "kmacxof256", &Params::new())?;
let tag = alg.tag(&key, b"message")?;
let ok = alg.verify(&key, b"message", &tag)?;
Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.
Other KMAC variants
3More message authentication codes
All 30Frequently asked questions
What is Kmacxof256?
Kmacxof256 is a MAC in the KMAC family. KMAC is a keyed message authentication code defined by NIST in SP 800-185, built directly on cSHAKE.
What are the Kmacxof256 sizes?
In NextSSL, Kmacxof256 uses: key 1 to 268,435,456 bytes, tag 16 to 1,024 bytes.
Who designed Kmacxof256 and when?
Kmacxof256 belongs to the KMAC family, first published in 2016. Its origin: NIST SP 800-185.
Which standards define Kmacxof256?
Kmacxof256 is referenced by NIST SP 800-185. It is specified in a FIPS standard.
Is Kmacxof256 safe to use?
Kmacxof256 is in the standard tier. Standardised and sound. Reachable from the safe API. It can be called from the safe API.
What other KMAC variants are there?
NextSSL also registers kmac128, kmac256, kmacxof128 in the KMAC family.
Related families
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