cryptokit

Implement cryptographic hashing, HMAC, encryption, signatures, and ECDH in Swift with CryptoKit.

Updated May 6, 2026
One-click install
npx skills add https://github.com/Roy-wonji/claude-config --skill cryptokit-roy-wonji
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cryptokit
Source: https://github.com/Roy-wonji/claude-config/tree/main/skills/swift-ios-skills/skills/cryptokit
Command: npx skills add https://github.com/Roy-wonji/claude-config --skill cryptokit-roy-wonji

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you implement correct, secure cryptography in Swift by providing vetted patterns for hashing, authentication (HMAC), authenticated encryption, digital signatures, and key agreement using Apple CryptoKit.

Core Features & Use Cases

  • Hashing with SHA256/SHA384/SHA512: Use one-shot or incremental hashing for data integrity and content fingerprints.
  • HMAC authentication codes: Generate and verify HMACs with constant-time verification for message authenticity.
  • Authenticated encryption (AES-GCM / ChaChaPoly): Encrypt and decrypt with automatic nonce handling and built-in authentication-tag verification.
  • Public-key signing and verification: Sign and verify using P256/P384/P521 (ECDSA) and Curve25519 (Ed25519).
  • Key agreement (ECDH) and key derivation: Derive symmetric keys from shared secrets via HKDF with proper sharedInfo binding.
  • Secure Enclave key storage: Use hardware-backed P256 keys with availability checks and Keychain persistence of dataRepresentation.

Quick Start

Use the cryptokit skill to implement AES-GCM encryption and decryption for confidential app payloads while ensuring authenticated tag verification and safe key handling.

Frequently Asked Questions about cryptokit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement AES-GCM encryption in Swift using CryptoKit?

To implement AES-GCM encryption in Swift with CryptoKit, use AES.GCM.seal to encrypt payloads with automatic random nonce generation and authenticated tag verification, then use AES.GCM.open to safely decrypt and verify integrity.

What is the best way to generate and verify HMAC in iOS?

The best way to generate and verify HMAC in iOS is using CryptoKit's HMAC<SHA256> to compute authentication codes, ensuring you use constant-time comparison via isValidSignature to prevent timing attacks and verify message authenticity.

Can I use Secure Enclave for P256 key storage in CryptoKit?

Yes, you can use Secure Enclave for P256 key storage in CryptoKit by creating keys with SecureEnclave.P256.KeyAgreement.PrivateKey, checking secure enclave availability, and persisting the key's dataRepresentation in the Keychain.

How do I derive symmetric keys from ECDH shared secrets in Swift?

To derive symmetric keys from ECDH shared secrets in Swift, use CryptoKit's key agreement methods to generate a SharedSecret, then derive a symmetric key via HKDF with a non-empty sharedInfo string to bind the derivation context.

Does CryptoKit support Ed25519 and ECDSA digital signatures?

Yes, CryptoKit supports digital signatures using Curve25519.Signing.PrivateKey for Ed25519, and P256, P384, or P521 ECDSA keys to sign data and verify signatures for authenticity and non-repudiation.

Why does CryptoKit require HKDF sharedInfo for key derivation?

CryptoKit requires HKDF sharedInfo for key derivation to bind the derived symmetric key to a specific application context, preventing key reuse across different protocols and ensuring cryptographic separation of derived keys.