Decrypts a block of data using a private key and specified algorithm.


func SecKeyCreateDecryptedData(_ key: SecKey, _ algorithm: SecKeyAlgorithm, _ ciphertext: CFData, _ error: UnsafeMutablePointer<Unmanaged<CFError>?>?) -> CFData?



The private key to use to perform the decryption.


The algorithm that was used to encrypt the data in the first place. Use one of the encryption algorithms listed in SecKeyAlgorithm. You can use the SecKeyIsAlgorithmSupported(_:_:_:) function to test that the key is suitable for the algorithm.


The data, produced with the corresponding public key and a call to the SecKeyCreateEncryptedData(_:_:_:_:) function, that you want to decrypt.


The address of a CFError object. If an error occurs, this is set to point at an error instance that describes the failure.

Return Value

The decrypted data or nil on failure.

See Also


Using Keys for Encryption

Perform asymmetric and symmetric encryption and decryption using cryptographic keys.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software