]>
KangarooTwelveRadboud UniversityToernooiveld 212NijmegenThe Netherlandsb.viguier@cs.ru.nlFacebookdavidwong.crypto@gmail.comSTMicroelectronicsgilles.vanassche@st.comNational Institute of Standards and Technologyquynh.dang@nist.govRadboud Universityjoan@cs.ru.nlCrypto ForumKeccakSakuraKangarooTwelveCryptographic HasheXtendable Output FunctionThis document defines the KangarooTwelve eXtendable Output Function (XOF),
a hash function with output of arbitrary length.
It provides an efficient and secure hashing primitive, which is able to
exploit the parallelism of the implementation in a scalable way.
It uses tree hashing over a round-reduced version of SHAKE128 as underlying
primitive.This document builds up on the definitions of the permutations and of the
sponge construction in [FIPS 202], and is meant to serve as a stable reference
and an implementation guide.This document defines the KangarooTwelve eXtendable Output Function (XOF)
, i.e. a generalization of a hash function that
can return an output of arbitrary length.
KangarooTwelve is based on a Keccak-p permutation specified in and has a higher speed than SHAKE and SHA-3.The SHA-3 functions process data in a serial manner and are unable to
optimally exploit parallelism available in modern CPU architectures.
Similar to ParallelHash , KangarooTwelve splits
the input message into fragments to exploit available parallelism. It then
applies an inner hash function F on each of them separately before applying
F again on the concatenation of the digests.
It makes use of Sakura coding for ensuring soundness of the tree hashing
mode .
The inner hash function F is a sponge function and uses a round-reduced
version of the permutation Keccak-f used in SHA-3, making it faster than
ParallelHash.
Its security builds up on the scrutiny that Keccak has received since its
publication .With respect to and
functions, KangarooTwelve features the following advantages:Unlike SHA3-224, SHA3-256, SHA3-384, SHA3-512, KangarooTwelve has an
extendable output.Unlike any defined function, similarly to
functions defined in , KangarooTwelve
allows the use of a customization string.Unlike any and
functions but ParallelHash, KangarooTwelve splits the input message into
fragments to exploit available parallelism.Unlike ParallelHash, KangarooTwelve does not have overhead when
processing short messages.The Keccak-f permutation in KangarooTwelve has half the number of rounds
of the one used in SHA3, making it faster than any function defined in
and .The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in RFC 2119 .The following notations are used throughout the document:denotes a string of bytes given in
hexadecimal. For example, `0B 80`.denotes the length of a byte string `s`.
For example, |`FF FF`| = 2.denotes a byte string consisting of the concatenation
of b bytes `00`. For example, `00`^7 = `00 00 00 00 00 00 00`.denotes the empty byte-string.denotes the concatenation of two strings a and b.
For example, `10`||`F1` = `10 F1`denotes the selection of bytes from n (inclusive) to m
(exclusive) of a string s. The indexing of a byte-string starts at 0.
For example, for s = `A5 C6 D7`, s[0:1] = `A5` and s[1:3] = `C6 D7`.denotes the selection of bytes from n to the end of
a string s.
For example, for s = `A5 C6 D7`, s[0:] = `A5 C6 D7` and s[2:] = `D7`.In the following, x and y are byte strings of equal length: denotes x takes the value x XOR y. denotes x AND y.In the following, x and y are integers: denotes x takes the value x + y. denotes x takes the value x - y. denotes the exponentiation of x by y.KangarooTwelve is an eXtendable Output Function (XOF).
It takes as input two byte-strings (M, C) and a positive integer L
where byte-string, is the Message and byte-string, is an OPTIONAL Customization string and positive integer, the requested number of output bytes.The Customization string MAY serve as domain separation.
It is typically a short string such as a name or an identifier (e.g. URI,
ODI...)By default, the Customization string is the empty string. For an API that
does not support a customization string input, C MUST be the empty string.The inner function F makes use of the permutation
Keccak-p[1600,n_r=12], i.e., a version of the permutation Keccak-f[1600]
used in SHAKE and SHA-3 instances reduced to its last n_r=12 rounds and
specified in FIPS 202, sections 3.3 and 3.4 .
KP denotes this permutation.F is a sponge function calling this permutation KP with a rate of 168 bytes
or 1344 bits. It follows that F has a capacity of 1600 - 1344 = 256 bits
or 32 bytes.The sponge function F takes: byte-string of positive length, the input bytes and positive integer, the length of the output in bytesFirst non-multiple of 168-bytes-length inputs are padded with zeroes to the next
multiple of 168 bytes while inputs multiple of 168 bytes are kept as is.
Then a byte `80` is XORed to the last byte of the padded message
and the resulting string is split into a sequence of 168-byte blocks.Inputs of length 0 bytes do not happen as a result of the tree hashing mode defined in section 2.2.As defined by the sponge construction, the process operates on a state
and consists of two phases: the absorbing phase that processes the input
and the squeezing phase that produces the output.In the absorbing phase the state is initialized to all-zero. The
message blocks are XORed into the first 168 bytes of the state.
Each block absorbed is followed with an application of KP to the state.In the squeezing phase output is formed by taking the first 168 bytes
of the state, repeated as many times as necessary until outputByteLen
bytes are obtained, interleaved with the application of KP to the state.The definition of the function F equivalently implements the pad10*1 rule.
It assumes an at least one-byte-long input where the last byte is in the `01`-`7F` range,
and this is the case in KangarooTwelve.
This last byte serves as domain separation and integrates the first bit of padding
of the pad10*1 rule (hence it cannot be `00`).
Additionally, it must leave room for the second bit of padding
(hence it cannot have the MSB set to 1), should it be the last byte of the block.
For more details, refer to Section 6.1 of .A pseudocode version is available as follows:On top of the sponge function F, KangarooTwelve uses a
Sakura-compatible tree hash mode .
First, merge M and the OPTIONAL C to a single input string S in a
reversible way. length_encode( |C| ) gives the length in bytes of C as a
byte-string.
See .Then, split S into n chunks of 8192 bytes.From S_1 .. S_(n-1), compute the 32-byte Chaining Values CV_1 .. CV_(n-1).
In order to be optimally efficient, this computation SHOULD exploit the
parallelism available on the platform such as SIMD instructions.Compute the final node: FinalNode.
If |S| <= 8192 bytes, FinalNode = SOtherwise compute FinalNode as follows:Finally, KangarooTwelve output is retrieved:
If |S| <= 8192 bytes, from F( FinalNode||`07`, L )Otherwise from F( FinalNode||`06`, L )The following figure illustrates the computation flow of KangarooTwelve
for |S| <= 8192 bytes:The following figure illustrates the computation flow of KangarooTwelve
for |S| > 8192 bytes and where length_encode( x ) is abbreviated as l_e( x ):A pseudocode version is provided in .The table below gathers the values of the domain separation
bytes used by the tree hash mode:The function length_encode takes as inputs a non negative integer x
< 256**255 and outputs a string of bytes x_(n-1) || .. || x_0 || n whereand where n is the smallest non-negative integer such that x < 256**n.
n is also the length of x_(n-1) || .. || x_0.As example, length_encode(0) = `00`, length_encode(12) = `0C 01` and
length_encode(65538) = `01 00 02 03`A pseudocode version is as follows.Test vectors are based on the repetition of the pattern `00 01 .. FA`
with a specific length. ptn(n) defines a string by repeating the pattern
`00 01 .. FA` as many times as necessary and truncated to n bytes e.g.
None.This document is meant to serve as a stable reference and an
implementation guide for the KangarooTwelve eXtendable Output Function.
It relies on the cryptanalysis of Keccak and provides with the same security
strength as SHAKE128, i.e., 128 bits of security against all attacks.
To be more precise, KangarooTwelve is made of two layers:
The inner function F. This layer relies on cryptanalysis.
KangarooTwelve's F function is exactly Keccak[r=1344, c=256] (as in SHAKE128)
reduced to 12 rounds. Any reduced-round cryptanalysis on Keccak
is also a reduced-round cryptanalysis of KangarooTwelve's F
(provided the number of rounds attacked is not higher than 12).The tree hashing over F. This layer is a mode on top
of F that does not introduce any vulnerability thanks to
the use of Sakura coding proven secure in .This reasoning is detailed and formalized in .To achieve 128-bit security strength, the output L must be chosen long
enough so that there are no generic attacks that violate 128-bit security.
So for 128-bit (second) preimage security the output should be at least 128 bits,
for 128-bit of security against multi-target preimage attacks with T targets
the output should be at least 128+log_2(T) bits
and for 128-bit collision security the output should be at least 256 bits.Furthermore, when the output length is at least 256 bits,
KangarooTwelve achieves NIST's post-quantum security level 2 .Implementing a MAC with KangarooTwelve SHOULD use a HASH-then-MAC construction.
This document recommends a method called HopMAC, defined as follows:Similarly to HMAC, HopMAC consists of two calls: an inner call compressing the
message M and the optional customization string C to a digest,
and an outer call computing the tag from the key and the digest.Unlike HMAC, the inner call to KangarooTwelve in HopMAC is keyless
and does not require additional protection against side channel attacks (SCA).
Consequently, in an implementation that has to protect the HopMAC key
against SCA only the outer call does need protection,
and this amounts to a single execution of the underlying permutation.
&rfc2119;
FIPS PUB 202 - SHA-3 Standard: Permutation-Based Hash and
Extendable-Output FunctionsNational Institute of Standards and Technology
NIST Special Publication 800-185 SHA-3 Derived Functions:
cSHAKE, KMAC, TupleHash and ParallelHashNational Institute of Standards and Technology
KangarooTwelve: fast hashing based on Keccak-pSakura: a flexible coding for tree hashingSummary of Third-party cryptanalysis of KeccakKeccak TeameXtended Keccak Code PackageSubmission Requirements and Evaluation Criteria for the Post-Quantum Cryptography Standardization ProcessNational Institute of Standards and Technology
The sub-sections of this appendix contain pseudocode definitions of
KangarooTwelve. A standalone Python version is also available in the
Keccak Code Package and in where ROL64(x, y) is a rotation of the 'x' 64-bit word toward the bits
with higher indexes by 'y' positions. The 8-bytes byte-string x is
interpreted as a 64-bit word in little-endian format.