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

    config

    The configuration object for the authenticator.

  • The type of authenticator, specifically .applicationPin.

    Declaration

    Swift

    public override func type() -> DeviceBindingAuthenticationType
  • register() Asynchronous

    Generates 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.unknown if access control creation fails. CryptoKeyError if key generation fails.

    Declaration

    Swift

    public override func register() async throws -> KeyPair

    Return Value

    A KeyPair containing 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 Result containing the SecKey on success, or an Error on failure.

  • Checks if the authenticator is supported.

    Note

    Always returns false on simulator — LAContext.setCredential(_:type:) with .applicationPassword is not supported on simulator, so authentication always fails. Returning false here produces a consistent “Unsupported” error rather than the misleading “Abort” that would result from failing inside authenticate().

    Declaration

    Swift

    public override func isSupported(attestation: Attestation) -> Bool

    Parameters

    attestation

    The attestation type (currently ignored).

    Return Value

    true on real devices, false on simulator.

  • deleteKeys() Asynchronous

    Deletes all keys associated with the application PIN authenticator.

    Throws

    UserKeysStorageError or CryptoKeyError if deletion fails.

    Declaration

    Swift

    public override func deleteKeys() async throws