AlgorithmParameterSpecpublic class KeyGenAlgorithmParaSpec extends Object implements AlgorithmParameterSpec
The following parameters can be set: key alias, length, usage(purposes), parameter set for key encryption, attribute set for key access control, and key accessibility period after user authentication.
SystemCapability.Security#KEYSTORE_PROVIDER| 限定符和类型 | 类 | 说明 |
|---|---|---|
static class |
KeyGenAlgorithmParaSpec.Builder |
A static inner class of
KeyGenAlgorithmParaSpec. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
Date |
getKeyInitiateTime() |
Obtains the start date of the key.
|
Date |
getPublicKeyExpireTime() |
Obtains the expiry date of the public key.
|
AlgorithmParameterSpec |
getSecKeyAlgorithmParameterSpec() |
Obtains the algorithm parameter specification used for key generation.
|
String |
getSecKeyAlias() |
Obtains the key alias.
|
int |
getSecKeyAuthDuration() |
Obtains the validity period of user authentication for a key.
|
String[] |
getSecKeyCryptoAttr(int type) |
Obtains the cryptographic attribute set of a key.
|
int |
getSecKeySizeInBits() |
Obtains the key length.
|
int |
getSecKeyUsagePurposes() |
Obtains the purposes for using a key.
|
Date |
getSecretKeyExpireTime() |
Obtains the expiry date of the private key.
|
Date |
getSelfSignedCertExpireTime() |
Obtains the expiry date of the self-signed certificate.
|
Date |
getSelfSignedCertInitiateTime() |
Obtains the start date of the self-signed certificate.
|
BigInteger |
getSelfSignedCertSerialNumber() |
Obtains the serial number of the self-signed certificate.
|
X500Principal |
getSelfSignedCertSubject() |
Obtains the subject of the self-signed certificate.
|
boolean |
isKeyAccessible(int flag) |
Checks whether a key is accessible.
|
public AlgorithmParameterSpec getSecKeyAlgorithmParameterSpec()
AlgorithmParameterSpec, which is null by default.public int getSecKeySizeInBits()
This method returns the default value if the key length is not specified during key generation.
public String getSecKeyAlias()
This alias can be used to retrieve the key entry in the KeyStore.
public String[] getSecKeyCryptoAttr(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. The value ID can be
KeyStoreConstants#CRYPTO_PARAMETER_DIGEST,
KeyStoreConstants#CRYPTO_PARAMETER_ENCRYPT_PADDING,
KeyStoreConstants#CRYPTO_PARAMETER_BLOCK_MODE, or
KeyStoreConstants#CRYPTO_PARAMETER_SIGNATURE_PADDING.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.public int getSecKeyUsagePurposes()
KeyStoreConstants#PURPOSE_CAN_ENCRYPT,
KeyStoreConstants#PURPOSE_CAN_DECRYPT, KeyStoreConstants#PURPOSE_CAN_SIGN,
or KeyStoreConstants#PURPOSE_CAN_VERIFY.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 Date getSelfSignedCertExpireTime()
The default expiry date is Jan 1 2048.
public Date getSelfSignedCertInitiateTime()
The default start date is Jan 1 1970.
public BigInteger getSelfSignedCertSerialNumber()
The default serial number is 1.
public X500Principal getSelfSignedCertSubject()
The default subject is CN=fake.
public Date getSecretKeyExpireTime()
After the expiry date, the private key cannot be used for encryption or signing.
public Date getPublicKeyExpireTime()
After the expiry date, the public key cannot be used for decryption or signature verification.
public Date getKeyInitiateTime()
Before the start date, the key is invalid.