Kmac Class
Computes the message authentication codes KMAC128 and KMAC256 (NIST SP 800-185).
public static class KmacRemarks
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
| Name | Description |
|---|---|
| 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.csComputes the KMAC of data.
public static byte[] HashData(int securityStrength, ReadOnlySpan<byte> key, ReadOnlySpan<byte> source, int outputLength, ReadOnlySpan<byte> customization = default)Parameters
securityStrengthint- The security strength, in bits: 128 (KMAC128) or 256 (KMAC256).
keyReadOnlySpan<byte>- The key K.
sourceReadOnlySpan<byte>- The data X to authenticate.
outputLengthint- The length L of the code, in bytes.
customizationReadOnlySpan<byte>- The customization string S.
Returns
byte[] The code, of outputLength bytes.
Exceptions
ArgumentOutOfRangeExceptionsecurityStrengthis not 128 or 256, oroutputLengthis negative.
HashData(int, ReadOnlySpan<byte>, ReadOnlySpan<byte>, Span<byte>, ReadOnlySpan<byte>)
Kmac.csComputes 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
securityStrengthint- The security strength, in bits: 128 (KMAC128) or 256 (KMAC256).
keyReadOnlySpan<byte>- The key K.
sourceReadOnlySpan<byte>- The data X to authenticate.
destinationSpan<byte>- The buffer that receives the code: its length is the length L of the code.
customizationReadOnlySpan<byte>- The customization string S.
Exceptions
ArgumentOutOfRangeExceptionsecurityStrengthis not 128 or 256.