# BiometricPrompt.CryptoObject

Artifact: [androidx.biometric:biometric](https://developer.android.com/jetpack/androidx/releases/biometric) [View Source](https://cs.android.com/search?q=file:androidx/biometric/BiometricPrompt.java+class:androidx.biometric.BiometricPrompt.CryptoObject) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

*** ** * ** ***


```
public class BiometricPrompt.CryptoObject
```

<br />

*** ** * ** ***

A wrapper class for the crypto objects supported by `https://developer.android.com/reference/androidx/biometric/BiometricPrompt`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#CryptoObject(javax.crypto.Cipher)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://docs.oracle.com/javase/8/docs/api/javax/crypto/Cipher.html cipher)` Creates a crypto object that wraps the given cipher object. |
| `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#R) [CryptoObject](https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#CryptoObject(android.security.identity.IdentityCredential))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/security/identity/IdentityCredential.html identityCredential)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#CryptoObject(android.security.identity.PresentationSession)` instead. <br /> |
| `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = https://developer.android.com/reference/android/os/Build.VERSION_CODES_FULL.html#BAKLAVA_1) https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#CryptoObject(javax.crypto.KeyAgreement)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://docs.oracle.com/javase/8/docs/api/javax/crypto/KeyAgreement.html keyAgreement)` Creates a crypto object that wraps the given key agreement object. |
| `https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#CryptoObject(javax.crypto.Mac)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://docs.oracle.com/javase/8/docs/api/javax/crypto/Mac.html mac)` Creates a crypto object that wraps the given MAC object. |
| `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#VANILLA_ICE_CREAM) https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#CryptoObject(long)(long operationHandle)` Create from an operation handle. |
| `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#TIRAMISU) https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#CryptoObject(android.security.identity.PresentationSession)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/security/identity/PresentationSession.html presentationSession)` Creates a crypto object that wraps the given presentation session object. |
| `https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#CryptoObject(java.security.Signature)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/security/Signature.html signature)` Creates a crypto object that wraps the given signature object. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://docs.oracle.com/javase/8/docs/api/javax/crypto/Cipher.html` | `https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#getCipher()()` Gets the cipher object associated with this crypto object. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/security/identity/IdentityCredential.html` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#R) [getIdentityCredential](https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#getIdentityCredential())()` **This method is deprecated.** Use `https://developer.android.com/reference/android/security/identity/PresentationSession.html` instead of `https://developer.android.com/reference/android/security/identity/IdentityCredential.html`. <br /> |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://docs.oracle.com/javase/8/docs/api/javax/crypto/KeyAgreement.html` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = https://developer.android.com/reference/android/os/Build.VERSION_CODES_FULL.html#BAKLAVA_1) https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#getKeyAgreement()()` Gets the key agreement object associated with this crypto object. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://docs.oracle.com/javase/8/docs/api/javax/crypto/Mac.html` | `https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#getMac()()` Gets the MAC object associated with this crypto object. |
| `long` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#VANILLA_ICE_CREAM) https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#getOperationHandle()()` Returns the `operationHandle` associated with this object or 0 if none. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/security/identity/PresentationSession.html` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#TIRAMISU) https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#getPresentationSession()()` Gets the presentation session object associated with this crypto object. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/security/Signature.html` | `https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#getSignature()()` Gets the signature object associated with this crypto object. |

## Public constructors

### CryptoObject

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
public CryptoObject(@NonNull Cipher cipher)
```

Creates a crypto object that wraps the given cipher object.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://docs.oracle.com/javase/8/docs/api/javax/crypto/Cipher.html cipher` | The cipher to be associated with this crypto object. |

### CryptoObject

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.1.0) Deprecated in [1.4.0-beta01](https://developer.android.com/jetpack/androidx/releases/biometric#1.4.0-beta01)

```
@RequiresApi(value = Build.VERSION_CODES.R)
public [CryptoObject](https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#CryptoObject(android.security.identity.IdentityCredential))(@NonNull IdentityCredential identityCredential)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#CryptoObject(android.security.identity.PresentationSession)` instead.

Creates a crypto object that wraps the given identity credential object.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/security/identity/IdentityCredential.html identityCredential` | The identity credential to be associated with this crypto object. |

### CryptoObject

Added in [1.4.0-beta01](https://developer.android.com/jetpack/androidx/releases/biometric#1.4.0-beta01)

```
@RequiresApi(value = Build.VERSION_CODES_FULL.BAKLAVA_1)
public CryptoObject(@NonNull KeyAgreement keyAgreement)
```

Creates a crypto object that wraps the given key agreement object.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://docs.oracle.com/javase/8/docs/api/javax/crypto/KeyAgreement.html keyAgreement` | The key agreement to be associated with this crypto object. |

### CryptoObject

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
public CryptoObject(@NonNull Mac mac)
```

Creates a crypto object that wraps the given MAC object.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://docs.oracle.com/javase/8/docs/api/javax/crypto/Mac.html mac` | The MAC to be associated with this crypto object. |

### CryptoObject

Added in [1.4.0-beta01](https://developer.android.com/jetpack/androidx/releases/biometric#1.4.0-beta01)

```
@RequiresApi(value = Build.VERSION_CODES.VANILLA_ICE_CREAM)
public CryptoObject(long operationHandle)
```

Create from an operation handle.

| Parameters |
|---|---|
| `long operationHandle` | the operation handle associated with this object. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#getOperationHandle()` |   |

### CryptoObject

Added in [1.4.0-beta01](https://developer.android.com/jetpack/androidx/releases/biometric#1.4.0-beta01)

```
@RequiresApi(value = Build.VERSION_CODES.TIRAMISU)
public CryptoObject(@NonNull PresentationSession presentationSession)
```

Creates a crypto object that wraps the given presentation session object.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/security/identity/PresentationSession.html presentationSession` | The presentation session to be associated with this crypto object. |

### CryptoObject

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
public CryptoObject(@NonNull Signature signature)
```

Creates a crypto object that wraps the given signature object.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/security/Signature.html signature` | The signature to be associated with this crypto object. |

## Public methods

### getCipher

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
public @Nullable Cipher getCipher()
```

Gets the cipher object associated with this crypto object.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://docs.oracle.com/javase/8/docs/api/javax/crypto/Cipher.html` | The cipher, or `null` if none is associated with this object. |

### getIdentityCredential

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.1.0) Deprecated in [1.4.0-beta01](https://developer.android.com/jetpack/androidx/releases/biometric#1.4.0-beta01)

```
@RequiresApi(value = Build.VERSION_CODES.R)
public @Nullable IdentityCredential [getIdentityCredential](https://developer.android.com/reference/androidx/biometric/BiometricPrompt.CryptoObject#getIdentityCredential())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/security/identity/PresentationSession.html` instead of `https://developer.android.com/reference/android/security/identity/IdentityCredential.html`.

Gets the identity credential object associated with this crypto object.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/security/identity/IdentityCredential.html` | The identity credential, or `null` if none is associated with this object. |

### getKeyAgreement

Added in [1.4.0-beta01](https://developer.android.com/jetpack/androidx/releases/biometric#1.4.0-beta01)

```
@RequiresApi(value = Build.VERSION_CODES_FULL.BAKLAVA_1)
public @Nullable KeyAgreement getKeyAgreement()
```

Gets the key agreement object associated with this crypto object.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://docs.oracle.com/javase/8/docs/api/javax/crypto/KeyAgreement.html` | The key agreement, or `null` if none is associated with this object. |

### getMac

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
public @Nullable Mac getMac()
```

Gets the MAC object associated with this crypto object.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://docs.oracle.com/javase/8/docs/api/javax/crypto/Mac.html` | The MAC, or `null` if none is associated with this object. |

### getOperationHandle

Added in [1.4.0-beta01](https://developer.android.com/jetpack/androidx/releases/biometric#1.4.0-beta01)

```
@RequiresApi(value = Build.VERSION_CODES.VANILLA_ICE_CREAM)
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 `https://developer.android.com/reference/android/os/Parcelable.html`. Hence, if the `CryptoObject` is constructed in one process, and needs to be propagated to another process, before calling the `authenticate()` API in the second process, the recommendation is to retrieve the `operationHandle` using this API, and then reconstruct the `CryptoObject`using the constructor that takes in an `
operationHandle`, and pass that in to the `authenticate` API mentioned above.

### getPresentationSession

Added in [1.4.0-beta01](https://developer.android.com/jetpack/androidx/releases/biometric#1.4.0-beta01)

```
@RequiresApi(value = Build.VERSION_CODES.TIRAMISU)
public @Nullable PresentationSession getPresentationSession()
```

Gets the presentation session object associated with this crypto object.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/security/identity/PresentationSession.html` | The presentation session, or `null` if none is associated with this object. |

### getSignature

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/biometric#1.0.0)

```
public @Nullable Signature getSignature()
```

Gets the signature object associated with this crypto object.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/security/Signature.html` | The signature, or `null` if none is associated with this object. |