AppPinAuthenticator
public class AppPinAuthenticator : DefaultDeviceAuthenticator
An authenticator that uses an application PIN for user verification. This class provides an implementation for generating PIN-protected keys and authenticating the user by prompting for the PIN.
-
Initializes the authenticator with an
AppPinConfig.Declaration
Swift
public init(config: AppPinConfig)Parameters
configThe configuration object for the authenticator.
-
The type of authenticator, specifically
.applicationPin.Declaration
Swift
public override func type() -> DeviceBindingAuthenticationType -
register()AsynchronousGenerates a new cryptographic key pair protected by an application PIN. The key’s access control is configured to require an application password, which will be the PIN provided by the user.
Throws
DeviceBindingError.unknownif access control creation fails.CryptoKeyErrorif key generation fails.Declaration
Swift
public override func register() async throws -> KeyPairReturn Value
A
KeyPaircontaining the newly generated public and private keys. -
authenticate(keyTag:Asynchronous) Declaration
Swift
public override func authenticate(keyTag: String) async -> Result<SecKey, Error>Return Value
A
Resultcontaining theSecKeyon success, or anErroron failure. -
Checks if the authenticator is supported.
Note
Always returnsfalseon simulator —LAContext.setCredential(_:type:)with.applicationPasswordis not supported on simulator, so authentication always fails. Returningfalsehere produces a consistent “Unsupported” error rather than the misleading “Abort” that would result from failing insideauthenticate().Declaration
Swift
public override func isSupported(attestation: Attestation) -> BoolParameters
attestationThe attestation type (currently ignored).
Return Value
trueon real devices,falseon simulator. -
deleteKeys()AsynchronousDeletes all keys associated with the application PIN authenticator.
Throws
UserKeysStorageErrororCryptoKeyErrorif deletion fails.Declaration
Swift
public override func deleteKeys() async throws
View on GitHub