cryptokitlisted
Install: claude install-skill dpearson2699/swift-ios-skills
# CryptoKit
Apple CryptoKit provides a Swift-native API for cryptographic operations:
hashing, message authentication, symmetric encryption, public-key signing,
key agreement, and Secure Enclave key storage. Available on iOS 13+.
Prefer CryptoKit over CommonCrypto or raw Security framework APIs in all
new code targeting Swift 6.3+.
## Contents
- [Hashing](#hashing)
- [HMAC](#hmac)
- [Symmetric Encryption](#symmetric-encryption)
- [Public-Key Signing](#public-key-signing)
- [Key Agreement](#key-agreement)
- [Secure Enclave](#secure-enclave)
- [Common Mistakes](#common-mistakes)
- [Review Checklist](#review-checklist)
- [References](#references)
## Hashing
CryptoKit provides SHA256, SHA384, and SHA512 hash functions. All conform
to the `HashFunction` protocol.
### One-shot hashing
```swift
import CryptoKit
let data = Data("Hello, world!".utf8)
let digest = SHA256.hash(data: data)
let hex = digest.compactMap { String(format: "%02x", $0) }.joined()
```
SHA384 and SHA512 work identically -- substitute the type name.
### Incremental hashing
For large data or streaming input, hash incrementally:
```swift
var hasher = SHA256()
hasher.update(data: chunk1)
hasher.update(data: chunk2)
let digest = hasher.finalize()
```
### Digest comparison
CryptoKit digests use constant-time comparison by default. Direct `==`
checks between digests are safe against timing attacks.
```swift
let expected = SHA256.hash(data: reference)
let actual = SHA256.hash(data: received)
if expected ==