Rebex
Products Downloads Buy Support Contact
Show / Hide Table of Contents

HKDF.DeriveKey Method

Namespace: Rebex.Security.Cryptography
Assembly: Rebex.Security.dll (version 7.0.9147)

DeriveKey(HashingAlgorithmId, Byte[], Int32, Byte[], Byte[])

Derives the output keying material using the Extract-and-Expand key derivation function (HKDF).

Declaration
public static byte[] DeriveKey(HashingAlgorithmId hashingAlgorithmId, byte[] ikm, int outputLength, byte[] salt = null, byte[] info = null)
Parameters
Type Name Description
HashingAlgorithmId hashingAlgorithmId

The hash algorithm for HMAC operations.

Byte[] ikm

A byte array that contains the input keying material.

Int32 outputLength

The length in bytes of the output keying material. The value must be between 1 and '255 * hash size of hashingAlgorithmId in bytes'.

Byte[] salt

A byte array that contains the salt. When null or empty salt is specified, this method will use a zero-filled salt with size equal to the hash size of hashingAlgorithmId.

Byte[] info

A byte array that contains the context and application-specific information. Can be null.

Returns
Type Description
Byte[]

A byte array that contains the output keying material.

Exceptions
Type Condition
ArgumentNullException

The ikm is null.

ArgumentException

The ikm is empty, or the outputLength is invalid, or the hashingAlgorithmId is not supported.

DeriveKey(HashingAlgorithmId, ArraySegment<Byte>, ArraySegment<Byte>, ArraySegment<Byte>, ArraySegment<Byte>)

Derives the output keying material using the Extract-and-Expand key derivation function (HKDF).

Declaration
public static void DeriveKey(HashingAlgorithmId hashingAlgorithmId, ArraySegment<byte> ikm, ArraySegment<byte> output, ArraySegment<byte> salt, ArraySegment<byte> info)
Parameters
Type Name Description
HashingAlgorithmId hashingAlgorithmId

The hash algorithm for HMAC operations.

ArraySegment<Byte> ikm

An ArraySegment<T> that contains the input keying material.

ArraySegment<Byte> output

An ArraySegment<T> that will receive the output keying material. The length of the output must be between 1 and '255 * hash size of hashingAlgorithmId in bytes'.

ArraySegment<Byte> salt

An ArraySegment<T> that contains the salt. When an empty salt is specified, this method will use a zero-filled salt with size equal to the hash size of hashingAlgorithmId.

ArraySegment<Byte> info

An ArraySegment<T> that contains the context and application-specific information. Can be empty.

Exceptions
Type Condition
ArgumentException

The ikm is empty, or the output has an invalid length, or the hashingAlgorithmId is not supported.

In This Article
  • DeriveKey(HashingAlgorithmId, Byte[], Int32, Byte[], Byte[])
  • DeriveKey(HashingAlgorithmId, ArraySegment<Byte>, ArraySegment<Byte>, ArraySegment<Byte>, ArraySegment<Byte>)
© REBEX ČR s.r.o. Back to top
Privacy policy
Manage cookies