---
title: HKDF
framework: cryptokit
role: symbol
role_heading: Structure
platforms: [iOS 14.0+, iPadOS 14.0+, Mac Catalyst 14.0+, macOS 11.0+, tvOS 14.0+, visionOS 1.0+, watchOS 7.0+]
path: cryptokit/hkdf
---

# HKDF

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

## Declaration

```swift
struct HKDF<H> where H : HashFunction
```

## Overview

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

- [deriveKey(inputKeyMaterial:outputByteCount:)](cryptokit/hkdf/derivekey(inputkeymaterial:outputbytecount:).md)
- [deriveKey(inputKeyMaterial:info:outputByteCount:)](cryptokit/hkdf/derivekey(inputkeymaterial:info:outputbytecount:).md)
- [deriveKey(inputKeyMaterial:salt:outputByteCount:)](cryptokit/hkdf/derivekey(inputkeymaterial:salt:outputbytecount:).md)
- [deriveKey(inputKeyMaterial:salt:info:outputByteCount:)](cryptokit/hkdf/derivekey(inputkeymaterial:salt:info:outputbytecount:).md)

### Controlling key derivation

- [expand(pseudoRandomKey:info:outputByteCount:)](cryptokit/hkdf/expand(pseudorandomkey:info:outputbytecount:).md)

### Type Methods

- [deriveKey(inputKeyMaterial:salt:info:output:)](cryptokit/hkdf/derivekey(inputkeymaterial:salt:info:output:).md)
- [expand(pseudoRandomKey:info:into:)](cryptokit/hkdf/expand(pseudorandomkey:info:into:).md)
- [extract(inputKeyMaterial:salt:)](cryptokit/hkdf/extract(inputkeymaterial:salt:)-4f5wf.md)
- [extract(inputKeyMaterial:salt:)](cryptokit/hkdf/extract(inputkeymaterial:salt:)-7qmzj.md)

## Relationships

### Conforms To

- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
