Returns an external representation of the given key suitable for the key's type.
- iOS 10.0+
- macOS 10.12+
- Mac Catalyst 13.0+Beta
- tvOS 10.0+
- watchOS 3.0+
The key to export.
The address of a
CFErrorobject. If an error occurs, this is set to point at an error instance that describes the failure.
A data object representing the key in a format suitable for the key type or
nil on error.
The operation fails if the key is not exportable, for example if it is bound to a smart card or to the Secure Enclave. It also fails in macOS if the key has the attribute
k set to
The method returns data in the PKCS #1 format for an RSA key. For an elliptic curve public key, the format follows the ANSI X9.63 standard using a byte string of
04 || X || Y. For an elliptic curve private key, the output is formatted as the public key concatenated with the big endian encoding of the secret scalar, or
04 || X || Y || K. All of these representations use constant size integers, including leading zeros as needed.