---
title: Keys
framework: security
role: collectionGroup
role_heading: API Collection
path: security/keys
---

# Keys

Generate, store, and use cryptographic keys.

## Overview

Overview Cryptographic keys are strings of bytes that you combine with other data in specialized mathematical operations to enhance security. At the lowest level, this usually means participating in either encryption and decryption or digital signing and verification. You can use these basic operations directly, such as when you encrypt data before sending it through an insecure channel. You also use them implicitly, such as when you verify the digital signature on a certificate as a byproduct of a trust evaluation. Keys vary based on the operations they support. For example, you use public and private key pairs to perform asymmetric encryption, whereas you use symmetric keys to conduct symmetric encryption. Similarly, one key might work for a 1024-bit RSA algorithm, while another might be suitable for a 256-bit elliptic curve algorithm. Use the functions in this section when you need to handle cryptographic keys.

## Topics

### Essentials

- [Getting an Existing Key](security/getting-an-existing-key.md)
- [Storing Keys in the Keychain](security/storing-keys-in-the-keychain.md)
- [SecKey](security/seckey.md)
- [SecKeyGetTypeID()](security/seckeygettypeid().md)

### Key Generation

- [Generating New Cryptographic Keys](security/generating-new-cryptographic-keys.md)
- [Protecting keys with the Secure Enclave](security/protecting-keys-with-the-secure-enclave.md)
- [SecKeyCreateRandomKey(_:_:)](security/seckeycreaterandomkey(_:_:).md)
- [SecKeyCopyPublicKey(_:)](security/seckeycopypublickey(_:).md)
- [Key Generation Attributes](security/key-generation-attributes.md)

### Examining Keys

- [SecKeyIsAlgorithmSupported(_:_:_:)](security/seckeyisalgorithmsupported(_:_:_:).md)
- [SecKeyGetBlockSize(_:)](security/seckeygetblocksize(_:).md)
- [SecKeyCopyAttributes(_:)](security/seckeycopyattributes(_:).md)
- [SecKeyAlgorithm](security/seckeyalgorithm.md)
- [SecKeyOperationType](security/seckeyoperationtype.md)

### Import and Export

- [Storing Keys as Data](security/storing-keys-as-data.md)
- [SecKeyCopyExternalRepresentation(_:_:)](security/seckeycopyexternalrepresentation(_:_:).md)
- [SecKeyCreateWithData(_:_:_:)](security/seckeycreatewithdata(_:_:_:).md)

### Key Exchange

- [SecKeyCopyKeyExchangeResult(_:_:_:_:_:)](security/seckeycopykeyexchangeresult(_:_:_:_:_:).md)
- [SecKeyKeyExchangeParameter](security/seckeykeyexchangeparameter.md)

### Encryption

- [Using Keys for Encryption](security/using-keys-for-encryption.md)
- [SecKeyCreateEncryptedData(_:_:_:_:)](security/seckeycreateencrypteddata(_:_:_:_:).md)
- [SecKeyCreateDecryptedData(_:_:_:_:)](security/seckeycreatedecrypteddata(_:_:_:_:).md)

### Digital Signatures

- [Signing and Verifying](security/signing-and-verifying.md)
- [SecKeyCreateSignature(_:_:_:_:)](security/seckeycreatesignature(_:_:_:_:).md)
- [SecKeyVerifySignature(_:_:_:_:_:)](security/seckeyverifysignature(_:_:_:_:_:).md)

### Legacy iOS Key Operations

- [SecKeyGeneratePair(_:_:_:)](security/seckeygeneratepair(_:_:_:).md)
- [SecKeyEncrypt(_:_:_:_:_:_:)](security/seckeyencrypt(_:_:_:_:_:_:).md)
- [SecKeyDecrypt(_:_:_:_:_:_:)](security/seckeydecrypt(_:_:_:_:_:_:).md)
- [SecKeyRawSign(_:_:_:_:_:_:)](security/seckeyrawsign(_:_:_:_:_:_:).md)
- [SecKeyRawVerify(_:_:_:_:_:_:)](security/seckeyrawverify(_:_:_:_:_:_:).md)
- [SecPadding](security/secpadding.md)

### Legacy macOS Key Operations

- [SecKeyGeneratePairAsync(_:_:_:)](security/seckeygeneratepairasync(_:_:_:).md)
- [SecKeyGenerateSymmetric(_:_:)](security/seckeygeneratesymmetric(_:_:).md)
- [SecKeyCreateFromData(_:_:_:)](security/seckeycreatefromdata(_:_:_:).md)
- [SecKeyDeriveFromPassword(_:_:_:)](security/seckeyderivefrompassword(_:_:_:).md)
- [SecKeyWrapSymmetric(_:_:_:_:)](security/seckeywrapsymmetric(_:_:_:_:).md)
- [SecKeyUnwrapSymmetric(_:_:_:_:)](security/seckeyunwrapsymmetric(_:_:_:_:).md)
- [SecKeySizes](security/seckeysizes.md)
- [SecKeyUsage](security/seckeyusage.md)
- [SecPublicKeyHash](security/secpublickeyhash.md)
- [SecKeyGeneratePairBlock](security/seckeygeneratepairblock.md)
- [SecCredentialType](security/seccredentialtype.md)
