register

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

Registers a new device by generating biometric and device credential protected key pairs.

This method creates a new RSA key pair in the Android Keystore with protection that requires either biometric authentication or device credential for access. The key generation process configures the key with appropriate security parameters, hardware backing preferences, and authentication requirements for both biometric and credential-based access.

Return

Result containing KeyPair with public key, private key reference, and key alias on success, or failure with appropriate exception

Parameters

context

Android context for accessing system services and checking device capabilities

attestation

Attestation configuration specifying hardware verification requirements. Attestation.Default enables hardware attestation with challenge verification. Attestation.None generates keys without attestation.

See also

KeyGenParameterSpec

Throws

if key generation fails due to hardware limitations, invalid parameters, or system security policy violations