Gets the public key associated with the given private key.


SecKeyRef SecKeyCopyPublicKey(SecKeyRef key);



The private key for which you want the corresponding public key.

Return Value

The public key corresponding to the given private key. Call the CFRelease function to free this key's memory when you are done with it.

See Also

Key Generation

Generating New Cryptographic Keys

Create both asymmetric and symmetric cryptographic keys.

Storing Keys in the Secure Enclave

Create an extra layer of security for your private keys.


Generates a new private/public key pair.

Key Generation Attributes

Use attribute dictionary keys during cryptographic key generation.

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