org.mozilla.jss.pkcs11
Class PK11KeyGenerator
java.lang.Object
org.mozilla.jss.pkcs11.PK11KeyGenerator
- KeyGenerator
public final class PK11KeyGenerator
extends java.lang.Object
generate
public SymmetricKey generate()
throws IllegalStateException,
TokenException,
CharConversionException
Generates the key. This is the public interface, the actual
work is done by native methods.
- generate in interface KeyGenerator
generatePBE_IV
public byte[] generatePBE_IV()
throws TokenException,
CharConversionException
Generates an Initialization Vector using a PBE algorithm.
In order to call this method, the algorithm must be a PBE algorithm,
and the KeyGenerator must have been initialized with an instance
of PBEKeyGenParams
.
- generatePBE_IV in interface KeyGenerator
- The initialization vector derived from the password and salt
using the PBE algorithm.
initialize
public void initialize(AlgorithmParameterSpec parameters)
throws InvalidAlgorithmParameterException
- initialize in interface KeyGenerator
initialize
public void initialize(int strength)
throws InvalidAlgorithmParameterException
- initialize in interface KeyGenerator
strength
- Key size in bits. Must be evenly divisible by 8.
sensitiveKeys
public void sensitiveKeys(boolean sensitive)
Tells the generator to generate sensitive or insensitive keys.
Certain attributes of a sensitive key cannot be revealed in
plaintext outside the token. If this method is not called, the
default is token dependent.
- sensitiveKeys in interface KeyGenerator
setKeyUsages
public void setKeyUsages(SymmetricKey.Usage[] usages)
- setKeyUsages in interface KeyGenerator
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.
temporaryKeys
public void temporaryKeys(boolean temp)
Tells the generator to generate temporary or permanent keys.
Temporary keys are not written permanently to the token. They
are destroyed by the garbage collector. If this method is not
called, the default is temporary keys.
- temporaryKeys in interface KeyGenerator