Hkdf..::..Expand Method (HashAlgorithmName, ReadOnlySpan<(Of <(<'Byte>)>)>, Span<(Of <(<'Byte>)>)>, ReadOnlySpan<(Of <(<'Byte>)>)>)

Expands the provided pseudorandom key into an output keying material of the desired length using optional context information.

Namespace:  SecretNET.Crypto
Assembly:  SecretNET (in SecretNET.dll)

Syntax


public static void Expand(
	HashAlgorithmName hashAlgorithmName,
	ReadOnlySpan<byte> prk,
	Span<byte> output,
	ReadOnlySpan<byte> info
)

Parameters

hashAlgorithmName
Type: HashAlgorithmName
The hash algorithm to be used by the HMAC primitive. Supported hash functions: MD5, SHA1, SHA256, SHA384, SHA512.
prk
Type: ReadOnlySpan<(Of <(<'Byte>)>)>
The pseudorandom key. Must be at least as long as the output of the hash algorithm, i.e.: MD5 - 16 bytes, SHA1 - 20, SHA256 - 32, SHA384 - 48, SHA512 - 64.
output
Type: Span<(Of <(<'Byte>)>)>
The buffer to receive the generated output keying material (OKM). The OKM produced is of the same size as the buffer. Minimum buffer size - 1 byte, maximum buffer size - 255 times the size of the hash algorithm output in bytes (i.e., MD5 - 4080, SHA1 - 5100, SHA256 - 8160, SHA384 - 12240, SHA512 - 16320).
info
Type: ReadOnlySpan<(Of <(<'Byte>)>)>
The optional context-specific information. If the argument is an empty span, the expansion is performed without context information.

Exceptions


ExceptionCondition
[ArgumentException]The size of the prk is smaller than the size of the output of hash algorithm or the size of the output is invalid (either too small or too large).
[ArgumentOutOfRangeException]The hash algorithm specified in the parameter hashAlgorithmName is not supported.