AppPinAuthenticator

A PIN-based device authenticator that generates and manages RSA key pairs protected by user PIN.

This authenticator creates software-based RSA key pairs and stores them in a password-protected keystore file. The private keys are encrypted using the user's PIN and persisted to secure storage.

Key features:

  • Software-based RSA key generation with configurable key size

  • PIN-protected keystore storage with retry mechanism

  • Secure key persistence using encrypted storage

  • Support for key deletion and cleanup

Security considerations:

  • Keys are stored in software keystore, not hardware security module

  • Keystore is encrypted with hardware-backed encryption if available

  • PIN protection provides encryption for stored keys

  • Uses RSA with SHA256 for certificate signing

Example usage:

val authenticator = AppPinAuthenticator {
pinRetry = 3
keystoreType = "PKCS12"
pinCollector = { prompt -> getUserPin(prompt) }
}

// Register new device
val result = authenticator.register(context, Attestation.None)

// Authenticate existing device
val authResult = authenticator.authenticate(context)

Since

1.0.0

Parameters

config

Configuration object containing PIN collection strategy, storage settings, retry limits, and other authenticator-specific options

See also

Constructors

Link copied to clipboard
constructor(config: AppPinConfig)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override var cryptoKey: CryptoKey

Gets or sets the cryptographic key configuration. Setting this property automatically updates the storage filename to include the key alias for proper key isolation.

Link copied to clipboard

The type of device binding authentication provided by this authenticator. Always returns DeviceBindingAuthenticationType.APPLICATION_PIN.

Functions

Link copied to clipboard
open suspend override fun authenticate(context: Context): Result<Pair<PrivateKey, BiometricPrompt.CryptoObject?>>

Authenticates the device by retrieving the stored private key.

Link copied to clipboard
open suspend override fun deleteKeys()

Deletes all stored keys and associated data for this device.

Link copied to clipboard
open override fun isSupported(context: Context, attestation: Attestation): Boolean

Checks if this authenticator supports the given attestation type.

Link copied to clipboard
open suspend override fun register(context: Context, attestation: Attestation): Result<KeyPair>

Registers a new device by generating a fresh RSA key pair protected by user PIN.