CryptoKey
public class CryptoKey
A class for managing cryptographic keys in the Keychain. This class provides methods for generating, retrieving, and deleting key pairs.
-
The tag that uniquely identifies the key in the Keychain.
Declaration
Swift
public let keyTag: String -
Initializes a new
CryptoKeywith the given key tag.Declaration
Swift
public init(keyTag: String)Parameters
keyTagThe key tag to use.
-
Generates a new elliptic curve key pair and stores it in the Secure Enclave.
Throws
ADeviceBindingErrorif the key generation fails.Declaration
Swift
public func generateKeyPair(attestation: Attestation, accessControl: SecAccessControl? = nil, keySizeInBits: Int = 256, pin: String? = nil) throws -> KeyPairParameters
attestationThe attestation type. Currently, this parameter is not used.
accessControlThe access control flags for the key. If nil, a default will be used.
keySizeInBitsThe key size in bits (256 for P-256, 521 for P-521). Defaults to 256.
Return Value
The generated
KeyPair. -
Gets the public key from the Keychain.
Throws
ADeviceBindingError.deviceNotRegisteredif the key is not found.Declaration
Swift
public func getPublicKey() throws -> SecKeyReturn Value
The public key as a
SecKey. -
Deletes the key pair from the Keychain.
Throws
ADeviceBindingError.unknownif the deletion fails for any reason other than the item not being found.Declaration
Swift
public func deleteKeyPair() throws
View on GitHub