Contents

HKDF

A standards-based implementation of an HMAC-based Key Derivation Function (HKDF).

Declaration

struct HKDF<H> where H : HashFunction

Overview

The key derivation functions allow you to derive one or more secrets of the size of your choice from a main key or passcode. The key derivation function is compliant with IETF RFC 5869. Use one of the deriveKey functions, such as deriveKey(inputKeyMaterial:outputByteCount:) or deriveKey(inputKeyMaterial:salt:info:outputByteCount:), to derive a key from a main secret or passcode in a single function.

To derive a key with more fine-grained control, use extract(inputKeyMaterial:salt:) to create cryptographically strong key material in the form of a hashed authentication code, then call expand(pseudoRandomKey:info:outputByteCount:) using that key material to generate a symmetric key of the length you specify.

Topics

Deriving a key

Controlling key derivation

Type Methods