---
title: "SecKeyCreateSignature(_:_:_:_:)"
framework: security
role: symbol
role_heading: Function
path: "security/seckeycreatesignature(_:_:_:_:)"
---

# SecKeyCreateSignature(_:_:_:_:)

Creates the cryptographic signature for a block of data using a private key and specified algorithm.

## Declaration

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

## Parameters

- `key`: The private key to use in creating the signature.
- `algorithm`: The signing algorithm to use. Use one of the signing 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.
- `dataToSign`: The data whose signature you want.
- `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

Signing and Verifying

## Return Value

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

## Discussion

Discussion You later evaluate the combined data and signature with the corresponding public key and a call to the SecKeyVerifySignature(_:_:_:_:_:) function.
