---
title: "SecKeyCreateDecryptedData(_:_:_:_:)"
framework: security
role: symbol
role_heading: Function
path: "security/seckeycreatedecrypteddata(_:_:_:_:)"
---

# SecKeyCreateDecryptedData(_:_:_:_:)

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

## Declaration

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

## Parameters

- `key`: The private key to use to perform the decryption.
- `algorithm`: The algorithm that was used to encrypt the data in the first place. Use one of the encryption algorithms listed in doc://com.apple.security/documentation/Security/SecKeyAlgorithm. You can use the doc://com.apple.security/documentation/Security/SecKeyIsAlgorithmSupported(_:_:_:) function to test that the key is suitable for the algorithm.
- `ciphertext`: The data, produced with the corresponding public key and a call to the doc://com.apple.security/documentation/Security/SecKeyCreateEncryptedData(_:_:_:_:) function, that you want to decrypt.
- `error`: The address of a doc://com.apple.documentation/documentation/CoreFoundation/CFError object. If an error occurs, this is set to point at an error instance that describes the failure.

## Mentioned in

Generating New Cryptographic Keys Using Keys for Encryption

## Return Value

Return Value The decrypted data or NULL on failure. In Objective-C, call the CFRelease function to free the data’s memory when you are done with it.
