---
title: "deriveKey(inputKeyMaterial:outputByteCount:)"
framework: cryptokit
role: symbol
role_heading: Type Method
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/derivekey(inputkeymaterial:outputbytecount:)"
---

# deriveKey(inputKeyMaterial:outputByteCount:)

Derives a symmetric encryption key from a main key or passcode using HKDF key derivation.

## Declaration

```swift
static func deriveKey(inputKeyMaterial: SymmetricKey, outputByteCount: Int) -> SymmetricKey
```

## Parameters

- `inputKeyMaterial`: The main key or passcode the derivation function uses to derive a key.
- `outputByteCount`: The length in bytes of the resulting symmetric key.

## Return Value

Return Value The derived symmetric key.

## See Also

### Deriving a key

- [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)
