public interface KeyGenerator
Modifier and Type | Interface and Description |
---|---|
static interface |
KeyGenerator.CharToByteConverter
An interface for converting a password of Java characters into an array
of bytes.
|
Modifier and Type | Method and Description |
---|---|
SymmetricKey |
clone(SymmetricKey key)
Allows a SymmetricKey to be cloned on a different token.
|
SymmetricKey |
generate()
Generates a symmetric key.
|
byte[] |
generatePBE_IV()
Generates an Initialization Vector using a PBE algorithm.
|
void |
initialize(java.security.spec.AlgorithmParameterSpec parameters) |
void |
initialize(int strength) |
void |
sensitiveKeys(boolean sensitive)
Tells the generator to generate sensitive or insensitive keys.
|
void |
setCharToByteConverter(KeyGenerator.CharToByteConverter charToByte)
Sets the character to byte converter for passwords.
|
void |
setKeyUsages(SymmetricKey.Usage[] usages) |
void |
temporaryKeys(boolean temp)
Tells the generator to generate temporary or permanent keys.
|
void initialize(int strength) throws java.security.InvalidAlgorithmParameterException
strength
- Key size in bits. Must be evenly divisible by 8.java.security.InvalidAlgorithmParameterException
- If parameter is invalid.void initialize(java.security.spec.AlgorithmParameterSpec parameters) throws java.security.InvalidAlgorithmParameterException
java.security.InvalidAlgorithmParameterException
void setKeyUsages(SymmetricKey.Usage[] usages)
usages
- The operations the key will be used for after it is
generated. You have to specify these so that the key can be properly
marked with the operations it supports. Some PKCS #11 tokens require
that a key be marked for an operation before it can perform that
operation. The default is SymmetricKey.Usage.SIGN and
SymmetricKey.Usage.ENCRYPT.void temporaryKeys(boolean temp)
temp
- True to generate temporary key.void sensitiveKeys(boolean sensitive)
sensitive
- True to generate sensitive.SymmetricKey generate() throws java.lang.IllegalStateException, TokenException, java.io.CharConversionException
java.lang.IllegalStateException
- If key generation failed.TokenException
- If an error occurred in the token.java.io.CharConversionException
- If an encoding error occurred.byte[] generatePBE_IV() throws java.lang.IllegalStateException, TokenException, java.io.CharConversionException
PBEKeyGenParams
.java.lang.IllegalStateException
- If the algorithm is not a PBE
algorithm, or the KeyGenerator has not been initialized with
an instance of PBEKeyGenParams
.TokenException
- If an error occurs on the CryptoToken while
generating the IV.java.io.CharConversionException
- If an encoding error occurred.SymmetricKey clone(SymmetricKey key) throws SymmetricKey.NotExtractableException, java.security.InvalidKeyException, TokenException
key
- Symmetric key.SymmetricKey.NotExtractableException
- If the key material
cannot be extracted from the current token.java.security.InvalidKeyException
- If the owning token cannot process
the key to be cloned.TokenException
- If an error occurred in the token.void setCharToByteConverter(KeyGenerator.CharToByteConverter charToByte)
charToByte
- Character-to-byte converter.