SecKeyCreateSignature(_:_:_:_:)
Creates the cryptographic signature for a block of data using a private key and specified algorithm.
Declaration
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 Seckeyalgorithm. You can use the Seckeyisalgorithmsupported(_:_:_:) function to test that the key is suitable for the algorithm.
- dataToSign:
The data whose signature you want.
- error:
The address of a Cferror object. If an error occurs, this is set to point at an error instance that describes the failure.
Mentioned in
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
You later evaluate the combined data and signature with the corresponding public key and a call to the SecKeyVerifySignature(_:_:_:_:_:) function.