KeyStore.ProtectionParameterpublic class KeyStoreProtectionParameter extends Object implements KeyStore.ProtectionParameter
One example of such parameters is KeyStoreConstants#FLAG_KEY_ACCESSIBLE_NEEDED_USER_AUTH,
a constant indicating whether a key becomes accessible only after user authentication.
SystemCapability.Security#KEYSTORE_PROVIDER| 限定符和类型 | 类 | 说明 |
|---|---|---|
static class |
KeyStoreProtectionParameter.Builder |
A static inner class of
KeyGenAlgorithmParaSpec. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
int |
getSecKeyAuthDuration() |
Obtains the validity period for user authentication with a key.
|
String[] |
getSecKeyCryptoAttrs(int type) |
Obtains the cryptographic attribute set of a key, depending on the input parameters.
|
int |
getSecKeyUsagePurposes() |
Obtains the purposes for using a key.
|
boolean |
isKeyAccessible(int flag) |
Checks whether a key is accessible based on the input parameter.
|
public int getSecKeyUsagePurposes()
KeyStoreConstants.KeyStoreConstants#PURPOSE_CAN_ENCRYPT, KeyStoreConstants#PURPOSE_CAN_DECRYPT,
KeyStoreConstants#PURPOSE_CAN_SIGN, or KeyStoreConstants#PURPOSE_CAN_VERIFY.public String[] getSecKeyCryptoAttrs(int type)
A key-value set is used. The specific parameters depend on the value of type.
type - Indicates the attribute value ID, which can be KeyStoreConstants#CRYPTO_PARAMETER_DIGEST,
KeyStoreConstants#CRYPTO_PARAMETER_ENCRYPT_PADDING,
KeyStoreConstants#CRYPTO_PARAMETER_BLOCK_MODE, or
KeyStoreConstants#CRYPTO_PARAMETER_SIGNATURE_PADDING.public boolean isKeyAccessible(int flag)
flag - Indicates the purposes for using the key,
which can be KeyStoreConstants#FLAG_KEY_ACCESSIBLE_NEEDED_USER_AUTH,
KeyStoreConstants#FLAG_KEY_ACCESSIBLE_NEED_DEVICE_UNLOCK, or
KeyStoreConstants#FLAG_KEY_ACCESSIBLE_NEED_RANDOMIZED_ENCRYPTION.true if the key is accessible; returns false otherwise.public int getSecKeyAuthDuration()
If a key requires user authentication (see KeyStoreConstants#FLAG_KEY_ACCESSIBLE_NEEDED_USER_AUTH),
this method can be used to obtain the validity period of user authentication.
-1 if user authentication
is required every time the key is used.