Keys
Generate, store, and use cryptographic keys.
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
Key Generation
Generating New Cryptographic KeysProtecting keys with the Secure EnclaveSecKeyCreateRandomKey(_:_:)SecKeyCopyPublicKey(_:)Key Generation Attributes
Examining Keys
SecKeyIsAlgorithmSupported(_:_:_:)SecKeyGetBlockSize(_:)SecKeyCopyAttributes(_:)SecKeyAlgorithmSecKeyOperationType
Import and Export
Key Exchange
Encryption
Digital Signatures
Legacy iOS Key Operations
SecKeyGeneratePair(_:_:_:)SecKeyEncrypt(_:_:_:_:_:_:)SecKeyDecrypt(_:_:_:_:_:_:)SecKeyRawSign(_:_:_:_:_:_:)SecKeyRawVerify(_:_:_:_:_:_:)SecPadding