Kmac Class

Computes the message authentication codes KMAC128 and KMAC256 (NIST SP 800-185).

public static class Kmac

Remarks

The requested length is part of the input of KMAC: a shorter code is not a prefix of a longer one. The implementation is fully managed: it does not depend on the cryptographic library of the operating system, so it is available on every platform.

Methods

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

HashData overloads

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

Kmac.cs

Computes the KMAC of data.

public static byte[] HashData(int securityStrength, ReadOnlySpan<byte> key, ReadOnlySpan<byte> source, int outputLength, ReadOnlySpan<byte> customization = default)
Parameters
securityStrength int
The security strength, in bits: 128 (KMAC128) or 256 (KMAC256).
key ReadOnlySpan<byte>
The key K.
source ReadOnlySpan<byte>
The data X to authenticate.
outputLength int
The length L of the code, in bytes.
customization ReadOnlySpan<byte>
The customization string S.
Returns

byte[] The code, of outputLength bytes.

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

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

Kmac.cs

Computes the KMAC of data into a buffer.

public static void HashData(int securityStrength, ReadOnlySpan<byte> key, ReadOnlySpan<byte> source, Span<byte> destination, ReadOnlySpan<byte> customization = default)
Parameters
securityStrength int
The security strength, in bits: 128 (KMAC128) or 256 (KMAC256).
key ReadOnlySpan<byte>
The key K.
source ReadOnlySpan<byte>
The data X to authenticate.
destination Span<byte>
The buffer that receives the code: its length is the length L of the code.
customization ReadOnlySpan<byte>
The customization string S.
Exceptions
ArgumentOutOfRangeException
securityStrength is not 128 or 256.