Message authentication codes

Kmac256

NIST's Keccak-based MAC from SP 800-185, with optional arbitrary-length output

standard Safe API Specified in a FIPS standard

About Kmac256

Kmac256 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. It is also known as kmac256-mac. 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–2016
  1. Specified 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

Message authentication in SHA-3-based systemsKeyed pseudo-random function and key derivationDomain-separated MACs via customisation strings

Sizes

FieldBytesMeaning
key1 – 268,435,456Secret key
tag16 – 1,024Authentication tag

Parameters

NameTypeRangeDefaultRequired
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", "kmac256", None, key, b"message", 0)[0]
ok  = ns.check("mac_verify", "kmac256", None, 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

3

Frequently asked questions

What is Kmac256?

Kmac256 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. It is also known as kmac256-mac.

What are the Kmac256 sizes?

In NextSSL, Kmac256 uses: key 1 to 268,435,456 bytes, tag 16 to 1,024 bytes.

Who designed Kmac256 and when?

Kmac256 belongs to the KMAC family, first published in 2016. Its origin: NIST SP 800-185.

Which standards define Kmac256?

Kmac256 is referenced by NIST SP 800-185. It is specified in a FIPS standard.

Is Kmac256 safe to use?

Kmac256 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, kmacxof128, kmacxof256 in the KMAC family.