javax.crypto
Class KeyGeneratorSpi

java.lang.Object
  |
  +--javax.crypto.KeyGeneratorSpi
Direct Known Subclasses:
iaik.pkcs.pkcs12.KeyMaterialGenerator, PBKDF2, iaik.security.cipher.VarLengthKeyGenerator

public abstract class KeyGeneratorSpi
extends Object

Service Provider Interface (SPI) for the KeyGenerator class.


Attention:  This is not a SUN implementation!

This class has been developed by IAIK according to the documentation publicly available.
For SUNīs documentation of this class see http://java.sun.com/security/JCE1.2/spec/apidoc/index.html


This SPI class gives a set of abstract methods that have to be implemented by a particular provider for every symmetric algorithm that will need some key generation mechanism for creating secret keys.

The corresponding API class actually used by an application for secret key generation is the javax.crypto.KeyGenerator class. For creating a KeyGenerator object, an application shall use one of the KeyGenerator.getInstance method, supplied with the particular symmetric algorithm in mind and (optionally) a particular provider.

For instance:

 KeyGenerator key_gen = KeyGenerator.getInstance("DES");
 

For actually generating the requested secret key from the KeyGenerator object just created (and initialized with one of the init methods), use the generateKey method:

for instance: SecretKey des_key = key_gen.generateKey();

Initializing the key generator maybe done either algorithm-independently with some random seed, or algorithm-specific with some particular algorithm parameter specification. If no explicit initialization is done at all, it is left to the actual provider implementation to take default settings.

Version:
File Revision 15
See Also:
KeyGenerator, SecretKey

Constructor Summary
KeyGeneratorSpi()
          Default Constructor for creating a KeyGeneratorSpi object.
 
Method Summary
protected abstract  SecretKey engineGenerateKey()
          Actually generates a secret key from this KeyGenerator object.
protected abstract  void engineInit(AlgorithmParameterSpec params, SecureRandom random)
          Initializes this key generator with given algorithm parameters and random seed.
protected abstract  void engineInit(int strength, SecureRandom random)
          Initializes this key generator for the given strength with the given random seed
protected abstract  void engineInit(SecureRandom random)
          Initializes the key generator with the given random seed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyGeneratorSpi

public KeyGeneratorSpi()
Default Constructor for creating a KeyGeneratorSpi object.
Method Detail

engineInit

protected abstract void engineInit(SecureRandom random)
Initializes the key generator with the given random seed.
Parameters:
random - the random seed
See Also:
KeyGenerator.init(java.security.SecureRandom)

engineInit

protected abstract void engineInit(int strength,
                                   SecureRandom random)
Initializes this key generator for the given strength with the given random seed
Parameters:
strength - the strength of the key to be created
random - the random seed

engineInit

protected abstract void engineInit(AlgorithmParameterSpec params,
                                   SecureRandom random)
                            throws InvalidAlgorithmParameterException
Initializes this key generator with given algorithm parameters and random seed.
Parameters:
params - the algorithm parameters
random - the random seed
Throws:
InvalidAlgorithmParameterException - if the given algorithm parameters do not match to this KeyGenerator
See Also:
KeyGenerator.init(java.security.SecureRandom)

engineGenerateKey

protected abstract SecretKey engineGenerateKey()
Actually generates a secret key from this KeyGenerator object.
Returns:
the generated secret key
See Also:
KeyGenerator.generateKey()

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK