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

Extracts a pseudorandom key from the provided input key material using the specified salt value.

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

Syntax


public static int Extract(
	HashAlgorithmName hashAlgorithmName,
	ReadOnlySpan<byte> ikm,
	ReadOnlySpan<byte> salt,
	Span<byte> prk
)

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.
salt
Type: ReadOnlySpan<(Of <(<'Byte>)>)>
The salt value.
prk
Type: Span<(Of <(<'Byte>)>)>
The buffer to receive the generated pseudorandom key. Must be at least the size of the hash output to accommodate the pseudorandom key, i.e.: for MD5 - minimum 16 bytes, SHA1 - 20, SHA256 - 32, SHA384 - 48, SHA512 - 64.

Return Value

The size of the extracted pseudorandom key in bytes.

Exceptions


ExceptionCondition
[ArgumentException]The size of the prk is smaller than the size of the output of hash algorithm.
[ArgumentOutOfRangeException]The hash algorithm specified in the parameter hashAlgorithmName is not supported.