BiometricPrompt.CryptoObject
  public
  static
  final
  
  class
  BiometricPrompt.CryptoObject
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | 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 KeyGenParameterSpec.Builder.
 
CryptoObjects are used to unlock auth-per-use keys via
 BiometricPrompt.authenticate(CryptoObject, CancellationSignal, Executor,
 AuthenticationCallback), 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(IdentityCredential credential)
      
      This constructor is deprecated.
    Use  | |
| 
      CryptoObject(PresentationSession session)
      Create from a  | |
| 
      CryptoObject(Signature signature)
      Create from a  | |
| 
      CryptoObject(Cipher cipher)
      Create from a  | |
| 
      CryptoObject(KeyAgreement keyAgreement)
      Create from a  | |
| 
      CryptoObject(Mac mac)
      Create from a  | |
| 
      CryptoObject(long operationHandle)
      Create from an operation handle. | |
| Public methods | |
|---|---|
| 
        
        
        
        
        
        Cipher | 
      getCipher()
      Get  | 
| 
        
        
        
        
        
        IdentityCredential | 
      getIdentityCredential()
      
      This method was deprecated
      in API level 33.
    Use  | 
| 
        
        
        
        
        
        KeyAgreement | 
      getKeyAgreement()
      Get  | 
| 
        
        
        
        
        
        Mac | 
      getMac()
      Get  | 
| 
        
        
        
        
        
        long | 
      getOperationHandle()
      Returns the  | 
| 
        
        
        
        
        
        PresentationSession | 
      getPresentationSession()
      Get  | 
| 
        
        
        
        
        
        Signature | 
      getSignature()
      Get  | 
| Inherited methods | |
|---|---|
Public constructors
CryptoObject
public CryptoObject (IdentityCredential credential)
      This constructor is deprecated.
    Use PresentationSession instead of IdentityCredential.
  
Create from a IdentityCredential object.
| Parameters | |
|---|---|
| credential | IdentityCredential: aIdentityCredentialobject.
 This value cannot benull. | 
CryptoObject
public CryptoObject (PresentationSession session)
Create from a PresentationSession object.
| Parameters | |
|---|---|
| session | PresentationSession: aPresentationSessionobject.
 This value cannot benull. | 
CryptoObject
public CryptoObject (Signature signature)
Create from a Signature object.
| Parameters | |
|---|---|
| signature | Signature: aSignatureobject.
 This value cannot benull. | 
CryptoObject
public CryptoObject (Cipher cipher)
Create from a Cipher object.
| Parameters | |
|---|---|
| cipher | Cipher: aCipherobject.
 This value cannot benull. | 
CryptoObject
public CryptoObject (KeyAgreement keyAgreement)
Create from a KeyAgreement object.
| Parameters | |
|---|---|
| keyAgreement | KeyAgreement: aKeyAgreementobject.
 This value cannot benull. | 
CryptoObject
public CryptoObject (Mac mac)
Create from a Mac object.
| Parameters | |
|---|---|
| mac | Mac: aMacobject.
 This value cannot benull. | 
CryptoObject
public CryptoObject (long operationHandle)
Create from an operation handle.
| Parameters | |
|---|---|
| operationHandle | long: the operation handle associated with this object. | 
See also:
Public methods
getCipher
public Cipher getCipher ()
Get Cipher object.
| Returns | |
|---|---|
| Cipher | Cipherobject or null if this doesn't contain one. | 
getIdentityCredential
public IdentityCredential getIdentityCredential ()
      This method was deprecated
      in API level 33.
    Use PresentationSession instead of IdentityCredential.
  
Get IdentityCredential object.
| Returns | |
|---|---|
| IdentityCredential | IdentityCredentialobject or null if this doesn't contain one. | 
getKeyAgreement
public KeyAgreement getKeyAgreement ()
Get KeyAgreement object.
| Returns | |
|---|---|
| KeyAgreement | KeyAgreementobject or null if this doesn't contain one. | 
getMac
public Mac getMac ()
Get Mac object.
| Returns | |
|---|---|
| Mac | Macobject or null if this doesn't contain one. | 
getOperationHandle
public long getOperationHandle ()
Returns the operationHandle associated with this object or 0 if none.
 The operationHandle is the underlying identifier associated with
 the CryptoObject.
 
 The operationHandle can be used to reconstruct a CryptoObject
 instance. This is useful for any cross-process communication as the CryptoObject
 class is not Parcelable. Hence, if the CryptoObject is
 constructed in one process, and needs to be propagated to another process,
 before calling the
 BiometricPrompt.authenticate(CryptoObject, CancellationSignal, Executor,
 AuthenticationCallback) API in the second process, the recommendation is to retrieve the
 operationHandle using this API, and then reconstruct the
 CryptoObjectusing the constructor that takes in an operationHandle, and
 pass that in to the authenticate API mentioned above.
| Returns | |
|---|---|
| long | |
getPresentationSession
public PresentationSession getPresentationSession ()
Get PresentationSession object.
| Returns | |
|---|---|
| PresentationSession | PresentationSessionobject or null if this doesn't contain one. | 
getSignature
public Signature getSignature ()
Get Signature object.
| Returns | |
|---|---|
| Signature | Signatureobject or null if this doesn't contain one. | 
