Overview | Package | Class | Tree | Deprecated | Index | Help
| JSS 3.1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mozilla.jss.crypto
Interface KeyGenerator

All Known Implementing Classes:
  PK11KeyGenerator

public interface KeyGenerator

Generates symmetric keys for encryption and decryption.

Inner Class Summary
`static interface` | `KeyGenerator.CharToByteConverter` An interface for converting a password of Java characters into an array of bytes.

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

Method Detail

### initialize

    public void initialize(int strength)
                    throws java.security.InvalidAlgorithmParameterException

  Parameters:
    `strength` - Key size in bits. Must be evenly divisible by 8.

### initialize

    public void initialize(java.security.spec.AlgorithmParameterSpec parameters)
                    throws java.security.InvalidAlgorithmParameterException

### generate

    public SymmetricKey generate()
                          throws java.lang.IllegalStateException,
                                 TokenException,
                                 java.io.CharConversionException

### generatePBE_IV

    public byte[] generatePBE_IV()
                          throws java.lang.IllegalStateException,
                                 TokenException,
                                 java.io.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.
  Throws:
    `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.

### clone

    public SymmetricKey clone(SymmetricKey key)
                       throws SymmetricKey.NotExtractableException,
                              java.security.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.
    `java.security.InvalidKeyException` - If the owning token cannot process the key to be cloned.

### setCharToByteConverter

    public void setCharToByteConverter(KeyGenerator.CharToByteConverter charToByte)

  Sets the character to byte converter for passwords. The default conversion is UTF8 with no null termination.

Overview | Package | Class | Tree | Deprecated | Index | Help
| JSS 3.1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD