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

Derives the output keying material of the desired length from the input key material using the provided salt and context information.

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

Syntax


public static void DeriveKey(
	HashAlgorithmName hashAlgorithmName,
	ReadOnlySpan<byte> ikm,
	Span<byte> output,
	ReadOnlySpan<byte> salt,
	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.
ikm
Type: ReadOnlySpan<(Of <(<'Byte>)>)>
The input key material.
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. The 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).
salt
Type: ReadOnlySpan<(Of <(<'Byte>)>)>
The salt value.
info
Type: ReadOnlySpan<(Of <(<'Byte>)>)>
The optional context-specific information. If the argument is an empty span, the key derivation is performed without context information.

Exceptions


ExceptionCondition
[ArgumentException]The length of the output is either too small or too large.
[ArgumentOutOfRangeException]The hash algorithm specified in the parameter hashAlgorithmName is not supported.

Remarks


This method performs the full HKDF cycle: first extracts a pseudorandom key from the input key material, then expands it into an output keying material.