KangarooTwelve Class

Computes the extendable-output functions KT128 and KT256 (KangarooTwelve, RFC 9861).

public static class KangarooTwelve

Remarks

KangarooTwelve is a tree hash over TurboSHAKE: the data is split in chunks of 8 KiB, whose hashes are combined.

Methods

NameDescription
HashData(int, ReadOnlySpan<byte>, int, ReadOnlySpan<byte>)Computes the output of KangarooTwelve for data.
HashData(int, ReadOnlySpan<byte>, Span<byte>, ReadOnlySpan<byte>)Computes the output of KangarooTwelve for data into a buffer.

HashData overloads

HashData(int, ReadOnlySpan<byte>, int, ReadOnlySpan<byte>)

KangarooTwelve.cs

Computes the output of KangarooTwelve for data.

public static byte[] HashData(int securityStrength, ReadOnlySpan<byte> source, int outputLength, ReadOnlySpan<byte> customization = default)
Parameters
securityStrength int
The security strength, in bits: 128 (KT128) or 256 (KT256).
source ReadOnlySpan<byte>
The data to hash.
outputLength int
The length of the output, in bytes.
customization ReadOnlySpan<byte>
The customization string C.
Returns

byte[] The output, of outputLength bytes.

Exceptions
ArgumentOutOfRangeException
securityStrength is not 128 or 256, or outputLength is negative.

HashData(int, ReadOnlySpan<byte>, Span<byte>, ReadOnlySpan<byte>)

KangarooTwelve.cs

Computes the output of KangarooTwelve for data into a buffer.

public static void HashData(int securityStrength, ReadOnlySpan<byte> source, Span<byte> destination, ReadOnlySpan<byte> customization = default)
Parameters
securityStrength int
The security strength, in bits: 128 (KT128) or 256 (KT256).
source ReadOnlySpan<byte>
The data to hash.
destination Span<byte>
The buffer to fill with the output.
customization ReadOnlySpan<byte>
The customization string C.
Exceptions
ArgumentOutOfRangeException
securityStrength is not 128 or 256.