public static class KeyGenAlgorithmParaSpec.Builder extends Object
KeyGenAlgorithmParaSpec.
This class provides methods used to set key parameters and finally create a
KeyGenAlgorithmParaSpec object.
| 构造器 | 说明 |
|---|---|
Builder(String secKeyAlias) |
A constructor that uses the key alias to create a
Builder object. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
KeyGenAlgorithmParaSpec.Builder |
addSecKeyCryptoAttr(int secKeyCryptoAttrType,
String... attrs) |
Sets the values for the cryptographic attributes of a key, including the block cipher mode,
padding mode, and digest algorithm.
|
KeyGenAlgorithmParaSpec |
createKeyGenAlgorithmParaSpec() |
Creates a
KeyGenAlgorithmParaSpec object. |
KeyGenAlgorithmParaSpec.Builder |
setKeyExpireTime(Date expireTime) |
Sets the expiry date for the key.
|
KeyGenAlgorithmParaSpec.Builder |
setKeyInitiateTime(Date initiateTime) |
Sets the start date for the key.
|
KeyGenAlgorithmParaSpec.Builder |
setPublicKeyExpireTime(Date expireTime) |
Sets the expiry date for the public key.
|
KeyGenAlgorithmParaSpec.Builder |
setSecKeyAccessibleAttr(int secKeyAccessibleAttr) |
Sets the accessibility attribute set for a key, depending on how the key is meant to be used.
|
KeyGenAlgorithmParaSpec.Builder |
setSecKeyAlgorithmParameterSpec(AlgorithmParameterSpec spec) |
Sets algorithm parameters during key generation.
|
KeyGenAlgorithmParaSpec.Builder |
setSecKeyAuthDuration(int secKeyAuthDuration) |
Sets the validity period of user authentication for a key.
|
KeyGenAlgorithmParaSpec.Builder |
setSecKeySizeInBits(int secKeySizeInBits) |
Sets the length of the generated key.
|
KeyGenAlgorithmParaSpec.Builder |
setSecKeyUsagePurposes(int secKeyUsagePurposes) |
Sets the purposes for using a key.
|
KeyGenAlgorithmParaSpec.Builder |
setSecretKeyExpireTime(Date expireTime) |
Sets the expiry date for the private key.
|
KeyGenAlgorithmParaSpec.Builder |
setSelfSignedCertAttrs(Date expireTime,
Date initiateTime,
BigInteger serialNumber,
X500Principal subject) |
Sets the attributes for the self-signed certificate,
including the start date, expiry date, serial number, and subject.
|
public Builder(String secKeyAlias)
Builder object.secKeyAlias - Indicates the key alias to set.public KeyGenAlgorithmParaSpec.Builder addSecKeyCryptoAttr(int secKeyCryptoAttrType, String... attrs)
secKeyCryptoAttrType - Indicates the cryptographic attribute type, which can be
KeyStoreConstants#CRYPTO_PARAMETER_DIGEST,
KeyStoreConstants#CRYPTO_PARAMETER_ENCRYPT_PADDING,
KeyStoreConstants#CRYPTO_PARAMETER_BLOCK_MODE, or
KeyStoreConstants#CRYPTO_PARAMETER_SIGNATURE_PADDING.attrs - Indicates the attribute set.Builder object.public KeyGenAlgorithmParaSpec.Builder setSecKeyAuthDuration(int secKeyAuthDuration)
This method is valid only for keys that require user authentication to become accessible.
secKeyAuthDuration - Indicates the validity period of user authentication. By default, do not set it to
-1.Builder object.public KeyGenAlgorithmParaSpec.Builder setSecKeySizeInBits(int secKeySizeInBits)
The default key length will be used if secKeySizeInBits is not set.
secKeySizeInBits - Indicates the length of the generated key in bits. For example, the default length
of an AES key is 128 bits.Builder object.public KeyGenAlgorithmParaSpec.Builder setSecKeyUsagePurposes(int secKeyUsagePurposes)
Examples include encryption, decryption, signing, and signature verification.
secKeyUsagePurposes - Indicates the purposes for using the key, which can be
KeyStoreConstants#PURPOSE_CAN_ENCRYPT, KeyStoreConstants#PURPOSE_CAN_DECRYPT,
KeyStoreConstants#PURPOSE_CAN_SIGN, or KeyStoreConstants#PURPOSE_CAN_VERIFY.Builder object.public KeyGenAlgorithmParaSpec.Builder setSecKeyAlgorithmParameterSpec(AlgorithmParameterSpec spec)
The algorithm parameters depend on the key type.
spec - Indicates the AlgorithmParameterSpec object, which can be
RSAKeyGenParameterSpec or ECGenParameterSpec.Builder object.public KeyGenAlgorithmParaSpec.Builder setSecKeyAccessibleAttr(int secKeyAccessibleAttr)
secKeyAccessibleAttr - Indicates the accessibility attribute set for 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.Builder object.public KeyGenAlgorithmParaSpec.Builder setSelfSignedCertAttrs(Date expireTime, Date initiateTime, BigInteger serialNumber, X500Principal subject)
expireTime - Indicates the expiry date, after which the certificate will become invalid.
The default date is Jan 1 2048.InitiateTime - Indicates the start date, before which the certificate is invalid.
The default date is Jan 1 1970.serialNumber - Indicates the serial number of the certificate.
The default serial number is 1.subject - Indicates the subject of the certificate. The default subject is CN=fake.Builder object.public KeyGenAlgorithmParaSpec.Builder setKeyExpireTime(Date expireTime)
expireTime - Indicates the expiry date to set. After the expiry date, the key will become invalid.Builder object.setSecretKeyExpireTime(Date),
setPublicKeyExpireTime(Date)public KeyGenAlgorithmParaSpec.Builder setSecretKeyExpireTime(Date expireTime)
expireTime - Indicates the expiry date to set. After the expiry date,
the private key cannot be used for encryption or signing.Builder object.public KeyGenAlgorithmParaSpec.Builder setPublicKeyExpireTime(Date expireTime)
expireTime - Indicates the expiry date to set. After the expiry date,
the public key cannot be used for decryption or signature verification.Builder object.public KeyGenAlgorithmParaSpec.Builder setKeyInitiateTime(Date initiateTime)
initiateTime - Indicates the start date to set. Before the start date, the key is invalid.Builder object.public KeyGenAlgorithmParaSpec createKeyGenAlgorithmParaSpec()
KeyGenAlgorithmParaSpec object.
This method passes the parameters set in Builder to the constructor used to create a
KeyGenAlgorithmParaSpec object.
KeyGenAlgorithmParaSpec object created.