org.mozilla.jss.pkcs11

Class PK11KeyGenerator

Implemented Interfaces:
KeyGenerator

public final class PK11KeyGenerator
extends java.lang.Object
implements KeyGenerator

Method Summary

SymmetricKey
clone(SymmetricKey key)
Allows a SymmetricKey to be cloned on a different token.
static SymmetricKey
clone(SymmetricKey key, PK11Token token)
Allows a SymmetricKey to be cloned on a different token.
SymmetricKey
generate()
Generates the key.
byte[]
generatePBE_IV()
Generates an Initialization Vector using a PBE algorithm.
void
initialize(AlgorithmParameterSpec parameters)
void
initialize(int strength)
void
setCharToByteConverter(KeyGenerator.CharToByteConverter charToByte)
Sets the character to byte converter for passwords.

Method Details

clone

public SymmetricKey clone(SymmetricKey key)
            throws SymmetricKey.NotExtractableException,
                   InvalidKeyException,
                   TokenException
Allows a SymmetricKey to be cloned on a different token.
Throws:
SymmetricKey.NotExtractableException - If the key material cannot be extracted from the current token.

clone

public static SymmetricKey clone(SymmetricKey key,
                                 PK11Token token)
            throws SymmetricKey.NotExtractableException,
                   InvalidKeyException,
                   TokenException
Allows a SymmetricKey to be cloned on a different token.
Parameters:
key - The key to clone.
token - The token on which to clone the key.
Throws:
SymmetricKey.NotExtractableException - If the key material cannot be extracted from the current token.

generate

public SymmetricKey generate()
            throws IllegalStateException,
                   TokenException,
                   CharConversionException
Generates the key. This is the public interface, the actual work is done by native methods.

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.
Returns:
The initialization vector derived from the password and salt using the PBE algorithm.

initialize

public void initialize(AlgorithmParameterSpec parameters)
            throws InvalidAlgorithmParameterException

initialize

public void initialize(int strength)
            throws InvalidAlgorithmParameterException
Parameters:
strength - Key size in bits. Must be evenly divisible by 8.

setCharToByteConverter

public void setCharToByteConverter(KeyGenerator.CharToByteConverter charToByte)
Sets the character to byte converter for passwords. The default conversion is UTF8 with no null termination.