Function

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.

Return Value

The digital signature or nil on failure.

Discussion

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

See Also

Digital Signatures

Signing and Verifying

Create and evaluate digital signatures to establish the validity of code or data.

func SecKeyVerifySignature(SecKey, SecKeyAlgorithm, CFData, CFData, UnsafeMutablePointer<Unmanaged<CFError>?>?) -> Bool

Verifies the cryptographic signature of a block of data using a public key and specified algorithm.