TurboShake Class

Computes the extendable-output functions TurboSHAKE128 and TurboSHAKE256 (RFC 9861).

public static class TurboShake

Remarks

TurboSHAKE is the sponge of SHAKE with 12 rounds of the permutation instead of 24, which makes it about twice as fast.

Methods

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

HashData overloads

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

TurboShake.cs

Computes the output of TurboSHAKE for data.

public static byte[] HashData(int securityStrength, ReadOnlySpan<byte> source, int outputLength, byte domainSeparation = 31)
Parameters
securityStrength int
The security strength, in bits: 128 (TurboSHAKE128) or 256 (TurboSHAKE256).
source ReadOnlySpan<byte>
The data to hash.
outputLength int
The length of the output, in bytes.
domainSeparation byte
The domain separation byte D, in the range 0x01 to 0x7F.
Returns

byte[] The output, of outputLength bytes.

Exceptions
ArgumentOutOfRangeException
securityStrength is not 128 or 256, outputLength is negative, or domainSeparation is not in the range 0x01 to 0x7F.

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

TurboShake.cs

Computes the output of TurboSHAKE for data into a buffer.

public static void HashData(int securityStrength, ReadOnlySpan<byte> source, Span<byte> destination, byte domainSeparation = 31)
Parameters
securityStrength int
The security strength, in bits: 128 (TurboSHAKE128) or 256 (TurboSHAKE256).
source ReadOnlySpan<byte>
The data to hash.
destination Span<byte>
The buffer to fill with the output.
domainSeparation byte
The domain separation byte D, in the range 0x01 to 0x7F.
Exceptions
ArgumentOutOfRangeException
securityStrength is not 128 or 256, or domainSeparation is not in the range 0x01 to 0x7F.

Constants

NameDescription
DefaultDomainSeparationThe default domain separation byte D.

DefaultDomainSeparation

The default domain separation byte D.

public const byte DefaultDomainSeparation = 31