Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/security/keystore/KeyInfo#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/security/keystore/KeyInfo#inhmethods)

# KeyInfo

*** ** * ** ***

` public class KeyInfo `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/java/security/spec/KeySpec `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.security.keystore.KeyInfo |

<br />

*** ** * ** ***

Information about a key from the [Android Keystore system](https://developer.android.com/training/articles/keystore). This class describes whether the key material is available in plaintext outside of secure hardware, whether user authentication is required for using the key and whether this requirement is enforced by secure hardware, the key's origin, what uses the key is authorized for (e.g., only in `GCM` mode, or signing only), whether the key should be encrypted at rest, the key's and validity start and end dates.

Instances of this class are immutable.

<br />

### Example: Symmetric Key

The following example illustrates how to obtain a `KeyInfo` describing the provided Android Keystore `https://developer.android.com/reference/javax/crypto/SecretKey`.

    SecretKey key = ...; // Android Keystore key

    SecretKeyFactory factory = SecretKeyFactory.getInstance(key.getAlgorithm(), "AndroidKeyStore");
    KeyInfo keyInfo;
    try {
        keyInfo = (KeyInfo) factory.getKeySpec(key, KeyInfo.class);
    } catch (InvalidKeySpecException e) {
        // Not an Android KeyStore key.
    }

<br />

### Example: Private Key

The following example illustrates how to obtain a `KeyInfo` describing the provided Android KeyStore `https://developer.android.com/reference/java/security/PrivateKey`.

    PrivateKey key = ...; // Android KeyStore key

    KeyFactory factory = KeyFactory.getInstance(key.getAlgorithm(), "AndroidKeyStore");
    KeyInfo keyInfo;
    try {
        keyInfo = factory.getKeySpec(key, KeyInfo.class);
    } catch (InvalidKeySpecException e) {
        // Not an Android KeyStore key.
    }

<br />

## Summary

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#getBlockModes()() ` Gets the set of block modes (e.g., `GCM`, `CBC`) with which the key can be used when encrypting/decrypting. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#getDigests()() ` Gets the set of digest algorithms (e.g., `SHA-256`, `SHA-384`) with which the key can be used. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#getEncryptionPaddings()() ` Gets the set of padding schemes (e.g., `PKCS7Padding`, `PKCS1Padding`, `NoPadding`) with which the key can be used when encrypting/decrypting. |
| ` int` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#getKeySize()() ` Gets the size of the key in bits. |
| ` https://developer.android.com/reference/java/util/Date` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#getKeyValidityForConsumptionEnd()() ` Gets the time instant after which the key is no long valid for decryption and verification. |
| ` https://developer.android.com/reference/java/util/Date` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#getKeyValidityForOriginationEnd()() ` Gets the time instant after which the key is no long valid for encryption and signing. |
| ` https://developer.android.com/reference/java/util/Date` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#getKeyValidityStart()() ` Gets the time instant before which the key is not yet valid. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#getKeystoreAlias()() ` Gets the entry alias under which the key is stored in the `AndroidKeyStore`. |
| ` int` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#getOrigin()() ` Gets the origin of the key. |
| ` int` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#getPurposes()() ` Gets the set of purposes (e.g., encrypt, decrypt, sign) for which the key can be used. |
| ` int` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#getRemainingUsageCount()() ` Returns the remaining number of times the key is allowed to be used or `https://developer.android.com/reference/android/security/keystore/KeyProperties#UNRESTRICTED_USAGE_COUNT` if there's no restriction on the number of times the key can be used. |
| ` int` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#getSecurityLevel()() ` Returns the security level that the key is protected by. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#getSignaturePaddings()() ` Gets the set of padding schemes (e.g., `PSS`, `PKCS#1`) with which the key can be used when signing/verifying. |
| ` int` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#getUserAuthenticationType()() ` Gets the acceptable user authentication types for which this key can be authorized to be used. |
| ` int` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#getUserAuthenticationValidityDurationSeconds()() ` Gets the duration of time (seconds) for which this key is authorized to be used after the user is successfully authenticated. |
| ` boolean` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#isInsideSecureHardware()() ` *This method was deprecated in API level 31. This method is superseded by @see getSecurityLevel.* |
| ` boolean` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#isInvalidatedByBiometricEnrollment()() ` Returns `true` if the key will be invalidated by enrollment of a new fingerprint or removal of all fingerprints. |
| ` boolean` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#isTrustedUserPresenceRequired()() ` Returns `true` if the key can only be only be used if a test for user presence has succeeded since Signature.initSign() has been called. |
| ` boolean` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#isUnlockedDeviceRequired()() ` Returns `true` if the key is authorized to be used only while the device is unlocked. |
| ` boolean` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#isUserAuthenticationRequired()() ` Returns `true` if the key is authorized to be used only if the user has been authenticated. |
| ` boolean` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#isUserAuthenticationRequirementEnforcedBySecureHardware()() ` Returns `true` if the requirement that this key can only be used if the user has been authenticated is enforced by secure hardware (e.g., Trusted Execution Environment (TEE) or Secure Element (SE)). |
| ` boolean` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#isUserAuthenticationValidWhileOnBody()() ` Returns `true` if this key will become unusable when the device is removed from the user's body. |
| ` boolean` | ` https://developer.android.com/reference/android/security/keystore/KeyInfo#isUserConfirmationRequired()() ` Returns `true` if the key is authorized to be used only for messages confirmed by the user. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public methods

### getBlockModes

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String[] getBlockModes ()
```

Gets the set of block modes (e.g., `GCM`, `CBC`) with which the key can be used when encrypting/decrypting. Attempts to use the key with any other block modes will be rejected.

See `https://developer.android.com/reference/android/security/keystore/KeyProperties`.`BLOCK_MODE` constants.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | This value cannot be `null`. Value is one of the following: - `https://developer.android.com/reference/android/security/keystore/KeyProperties#BLOCK_MODE_ECB` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#BLOCK_MODE_CBC` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#BLOCK_MODE_CTR` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#BLOCK_MODE_GCM` |

### getDigests

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String[] getDigests ()
```

Gets the set of digest algorithms (e.g., `SHA-256`, `SHA-384`) with which the key can be used.

See `https://developer.android.com/reference/android/security/keystore/KeyProperties`.`DIGEST` constants.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | This value cannot be `null`. Value is one of the following: - `https://developer.android.com/reference/android/security/keystore/KeyProperties#DIGEST_NONE` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#DIGEST_MD5` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#DIGEST_SHA1` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#DIGEST_SHA224` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#DIGEST_SHA256` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#DIGEST_SHA384` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#DIGEST_SHA512` |

### getEncryptionPaddings

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String[] getEncryptionPaddings ()
```

Gets the set of padding schemes (e.g., `PKCS7Padding`, `PKCS1Padding`, `NoPadding`) with which the key can be used when encrypting/decrypting. Attempts to use the key with any other padding scheme will be rejected.

See `https://developer.android.com/reference/android/security/keystore/KeyProperties`.`ENCRYPTION_PADDING` constants.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | This value cannot be `null`. Value is one of the following: - `https://developer.android.com/reference/android/security/keystore/KeyProperties#ENCRYPTION_PADDING_NONE` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#ENCRYPTION_PADDING_PKCS7` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#ENCRYPTION_PADDING_RSA_PKCS1` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#ENCRYPTION_PADDING_RSA_OAEP` |

### getKeySize

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getKeySize ()
```

Gets the size of the key in bits.

<br />

| Returns ||
|---|---|
| `int` | `-1` for ML-DSA keys, otherwise the key size in bits. <br /> |

### getKeyValidityForConsumptionEnd

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Date getKeyValidityForConsumptionEnd ()
```

Gets the time instant after which the key is no long valid for decryption and verification.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Date` | instant or `null` if not restricted. <br /> |

### getKeyValidityForOriginationEnd

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Date getKeyValidityForOriginationEnd ()
```

Gets the time instant after which the key is no long valid for encryption and signing.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Date` | instant or `null` if not restricted. <br /> |

### getKeyValidityStart

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Date getKeyValidityStart ()
```

Gets the time instant before which the key is not yet valid.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Date` | instant or `null` if not restricted. <br /> |

### getKeystoreAlias

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getKeystoreAlias ()
```

Gets the entry alias under which the key is stored in the `AndroidKeyStore`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### getOrigin

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getOrigin ()
```

Gets the origin of the key. See `https://developer.android.com/reference/android/security/keystore/KeyProperties`.`ORIGIN` constants.

<br />

| Returns ||
|---|---|
| `int` | Value is one of the following: - `https://developer.android.com/reference/android/security/keystore/KeyProperties#ORIGIN_GENERATED` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#ORIGIN_IMPORTED` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#ORIGIN_UNKNOWN` |

### getPurposes

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getPurposes ()
```

Gets the set of purposes (e.g., encrypt, decrypt, sign) for which the key can be used. Attempts to use the key for any other purpose will be rejected.

See `https://developer.android.com/reference/android/security/keystore/KeyProperties`.`PURPOSE` flags.

<br />

| Returns ||
|---|---|
| `int` | Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/security/keystore/KeyProperties#PURPOSE_ENCRYPT` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#PURPOSE_DECRYPT` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#PURPOSE_SIGN` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#PURPOSE_VERIFY` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#PURPOSE_WRAP_KEY` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#PURPOSE_AGREE_KEY` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#PURPOSE_ATTEST_KEY` |

### getRemainingUsageCount

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getRemainingUsageCount ()
```

Returns the remaining number of times the key is allowed to be used or `https://developer.android.com/reference/android/security/keystore/KeyProperties#UNRESTRICTED_USAGE_COUNT` if there's no restriction on the number of times the key can be used. Note that this gives a best effort count and need not be accurate (as there might be usages happening in parallel and the count maintained here need not be in sync with the usage).

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### getSecurityLevel

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getSecurityLevel ()
```

Returns the security level that the key is protected by. `KeyProperties.SecurityLevelEnum.TRUSTED_ENVIRONMENT` and `KeyProperties.SecurityLevelEnum.STRONGBOX` indicate that the key material resides in secure hardware. Key material of such keys is available in plaintext only inside the secure hardware and is not exposed outside of it.

See `https://developer.android.com/reference/android/security/keystore/KeyProperties`.`SecurityLevelEnum` constants.

<br />

| Returns ||
|---|---|
| `int` | Value is one of the following: - `https://developer.android.com/reference/android/security/keystore/KeyProperties#SECURITY_LEVEL_UNKNOWN` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#SECURITY_LEVEL_UNKNOWN_SECURE` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#SECURITY_LEVEL_SOFTWARE` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#SECURITY_LEVEL_TRUSTED_ENVIRONMENT` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#SECURITY_LEVEL_STRONGBOX` |

### getSignaturePaddings

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String[] getSignaturePaddings ()
```

Gets the set of padding schemes (e.g., `PSS`, `PKCS#1`) with which the key can be used when signing/verifying. Attempts to use the key with any other padding scheme will be rejected.

See `https://developer.android.com/reference/android/security/keystore/KeyProperties`.`SIGNATURE_PADDING` constants.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | This value cannot be `null`. Value is one of the following: - `https://developer.android.com/reference/android/security/keystore/KeyProperties#SIGNATURE_PADDING_RSA_PKCS1` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#SIGNATURE_PADDING_RSA_PSS` |

### getUserAuthenticationType

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getUserAuthenticationType ()
```

Gets the acceptable user authentication types for which this key can be authorized to be used. This has effect only if user authentication is required (see `https://developer.android.com/reference/android/security/keystore/KeyInfo#isUserAuthenticationRequired()`).

This authorization applies only to secret key and private key operations. Public key operations are not restricted.

<br />

| Returns ||
|---|---|
| `int` | integer representing the accepted forms of user authentication for this key. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/security/keystore/KeyProperties#AUTH_BIOMETRIC_STRONG` - `https://developer.android.com/reference/android/security/keystore/KeyProperties#AUTH_DEVICE_CREDENTIAL` |

**See also:**

- `https://developer.android.com/reference/android/security/keystore/KeyInfo#isUserAuthenticationRequired()`

### getUserAuthenticationValidityDurationSeconds

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getUserAuthenticationValidityDurationSeconds ()
```

Gets the duration of time (seconds) for which this key is authorized to be used after the user is successfully authenticated. This has effect only if user authentication is required (see `https://developer.android.com/reference/android/security/keystore/KeyInfo#isUserAuthenticationRequired()`).

This authorization applies only to secret key and private key operations. Public key operations are not restricted.

<br />

| Returns ||
|---|---|
| `int` | duration in seconds or `-1` if authentication is required for every use of the key. <br /> |

**See also:**

- `https://developer.android.com/reference/android/security/keystore/KeyInfo#isUserAuthenticationRequired()`

### isInsideSecureHardware

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isInsideSecureHardware ()
```

<br />

**This method was deprecated in API level 31.**   

This method is superseded by @see getSecurityLevel.

Returns `true` if the key resides inside secure hardware (e.g., Trusted Execution Environment (TEE) or Secure Element (SE)). Key material of such keys is available in plaintext only inside the secure hardware and is not exposed outside of it.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isInvalidatedByBiometricEnrollment

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isInvalidatedByBiometricEnrollment ()
```

Returns `true` if the key will be invalidated by enrollment of a new fingerprint or removal of all fingerprints.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isTrustedUserPresenceRequired

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isTrustedUserPresenceRequired ()
```

Returns `true` if the key can only be only be used if a test for user presence has succeeded since Signature.initSign() has been called.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isUnlockedDeviceRequired

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public boolean isUnlockedDeviceRequired ()
```

Returns `true` if the key is authorized to be used only while the device is unlocked.

This authorization applies only to secret key and private key operations. Public key operations are not restricted.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/security/keystore/KeyGenParameterSpec.Builder#setUnlockedDeviceRequired(boolean)`
- `https://developer.android.com/reference/android/security/keystore/KeyProtection.Builder#setUnlockedDeviceRequired(boolean)`

### isUserAuthenticationRequired

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isUserAuthenticationRequired ()
```

Returns `true` if the key is authorized to be used only if the user has been authenticated.

This authorization applies only to secret key and private key operations. Public key operations are not restricted.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/security/keystore/KeyInfo#getUserAuthenticationValidityDurationSeconds()`
- `https://developer.android.com/reference/android/security/keystore/KeyGenParameterSpec.Builder#setUserAuthenticationRequired(boolean)`
- `https://developer.android.com/reference/android/security/keystore/KeyProtection.Builder#setUserAuthenticationRequired(boolean)`

### isUserAuthenticationRequirementEnforcedBySecureHardware

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isUserAuthenticationRequirementEnforcedBySecureHardware ()
```

Returns `true` if the requirement that this key can only be used if the user has been authenticated is enforced by secure hardware (e.g., Trusted Execution Environment (TEE) or Secure Element (SE)).

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/security/keystore/KeyInfo#isUserAuthenticationRequired()`

### isUserAuthenticationValidWhileOnBody

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isUserAuthenticationValidWhileOnBody ()
```

Returns `true` if this key will become unusable when the device is removed from the user's body. This is possible only for keys with a specified validity duration, and only on devices with an on-body sensor. Always returns `false` on devices that lack an on-body sensor.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isUserConfirmationRequired

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isUserConfirmationRequired ()
```

Returns `true` if the key is authorized to be used only for messages confirmed by the user. Confirmation is separate from user authentication (see `https://developer.android.com/reference/android/security/keystore/KeyInfo#isUserAuthenticationRequired()`). Keys can be created that require confirmation but not user authentication, or user authentication but not confirmation, or both. Confirmation verifies that some user with physical possession of the device has approved a displayed message. User authentication verifies that the correct user is present and has authenticated.

This authorization applies only to secret key and private key operations. Public key operations are not restricted.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/security/keystore/KeyGenParameterSpec.Builder#setUserConfirmationRequired(boolean)`
- `https://developer.android.com/reference/android/security/keystore/KeyProtection.Builder#setUserConfirmationRequired(boolean)`