Hkdf..::..DeriveKey Method (HashAlgorithmName, array<Byte>[]()[][], Int32, array<Nullable<(Of <(<'Byte>)>)>>[]()[][], array<Nullable<(Of <(<'Byte>)>)>>[]()[][])

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

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

Syntax


public static byte[] DeriveKey(
	HashAlgorithmName hashAlgorithmName,
	byte[] ikm,
	int outputLength,
	Nullable<byte>[] salt,
	Nullable<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: array<Byte>[]()[][]
The input key material.
outputLength
Type: Int32
The desired length of the generated output keying material in bytes. Minimum value - 1. Maximum value - 255 times the size of the hash algorithm output, i.e.: MD5 - 4080, SHA1 - 5100, SHA256 - 8160, SHA384 - 12240, SHA512 - 16320.
salt
Type: array<Nullable<(Of <(<'Byte>)>)>>[]()[][]
The optional salt value. If the argument is omitted or its value is set to null, the key derivation is performed without a salt.
info
Type: array<Nullable<(Of <(<'Byte>)>)>>[]()[][]
The optional context-specific information. If the argument is omitted or its value is set to null, the key derivation is performed without context information.

Return Value

The output keying material.

Exceptions


ExceptionCondition
[ArgumentNullException]The argument ikm is null.
[ArgumentOutOfRangeException]The hash algorithm specified in the parameter hashAlgorithmName is not supported or the value of the parameter outputLength is invalid (either too small or too large).

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.