Added in API level 28

CryptoObject

class CryptoObject
kotlin.Any
   ↳ android.hardware.biometrics.BiometricPrompt.CryptoObject

A wrapper class for the cryptographic operations supported by BiometricPrompt.

Currently the framework supports Signature, Cipher, Mac, IdentityCredential, PresentationSession and KeyAgreement.

Cryptographic operations in Android can be split into two categories: auth-per-use and time-based. This is specified during key creation via the timeout parameter of the setUserAuthenticationParameters(int, int) method of .

CryptoObjects are used to unlock auth-per-use keys via BiometricPrompt#authenticate(CryptoObject, CancellationSignal, Executor,, whereas time-based keys are unlocked for their specified duration any time the user authenticates with the specified authenticators (e.g. unlocking keyguard). If a time-based key is not available for use (i.e. none of the allowed authenticators have been unlocked recently), applications can prompt the user to authenticate via BiometricPrompt#authenticate(CancellationSignal, Executor, AuthenticationCallback)

Summary

Public constructors
CryptoObject(signature: Signature)

Create from a IdentityCredential object.

Public methods
Cipher?

Get Cipher object.

IdentityCredential?

Get IdentityCredential object.

Mac?

Get Mac object.

PresentationSession?

Get PresentationSession object.

Signature?

Get Signature object.

Public constructors

CryptoObject

Added in API level 28
CryptoObject(signature: Signature)
Parameters
signature Signature: This value cannot be null.

CryptoObject

Added in API level 28
CryptoObject(cipher: Cipher)
Parameters
cipher Cipher: This value cannot be null.

CryptoObject

Added in API level 28
CryptoObject(mac: Mac)
Parameters
mac Mac: This value cannot be null.

CryptoObject

Added in API level 28
CryptoObject(credential: IdentityCredential)

Deprecated: Use PresentationSession instead of IdentityCredential.

Create from a IdentityCredential object.

Parameters
credential IdentityCredential: a IdentityCredential object. This value cannot be null.

CryptoObject

Added in API level 28
CryptoObject(session: PresentationSession)
Parameters
session PresentationSession: This value cannot be null.

Public methods

getCipher

Added in API level 28
fun getCipher(): Cipher?

Get Cipher object.

Return
Cipher? Cipher object or null if this doesn't contain one.

getIdentityCredential

Added in API level 30
Deprecated in API level 33
fun getIdentityCredential(): IdentityCredential?

Deprecated: Use PresentationSession instead of IdentityCredential.

Get IdentityCredential object.

Return
IdentityCredential? IdentityCredential object or null if this doesn't contain one.

getMac

Added in API level 28
fun getMac(): Mac?

Get Mac object.

Return
Mac? Mac object or null if this doesn't contain one.

getPresentationSession

Added in API level 33
fun getPresentationSession(): PresentationSession?

Get PresentationSession object.

Return
PresentationSession? PresentationSession object or null if this doesn't contain one.

getSignature

Added in API level 28
fun getSignature(): Signature?

Get Signature object.

Return
Signature? Signature object or null if this doesn't contain one.