iaik.me.security
Class KeyPairGenerator

java.lang.Object
  |
  +--iaik.me.security.KeyPairGenerator
Direct Known Subclasses:
DSAKeyPairGenerator, RSAKeyPairGenerator

public abstract class KeyPairGenerator
extends Object

This class is used for generating keypairs for asymetric, cryptographic systems like RSA and DSA.
To create a keypair, just fetch an instance of a keypairgenerator and initialize it with the corresponding values:

KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(2048, null, secrandom);
CryptoBag keyPair = kpg.generateKeyPair();

Currently, the aliases RSA and DSA ( for RSA and DSA keypairgenerators) are supported.

If you want to use your own implementation of a keypairgenerator you can simply add it to the framework via:

register("RSA", "iaik.me.security.rsa.RSAKeyPairGenerator");

and use the implementation with the means described above.
Remeber, if you develop your own keypairgenerator you have to extend this class to be able to insert your generator into the framework.


Constructor Summary
protected KeyPairGenerator()
           
 
Method Summary
abstract  CryptoBag generateKeyPair()
          This method generates a new keypair with the previously initialized parameters and returns it as a CryptoBag object.
static KeyPairGenerator getInstance(String algorithm)
          This method instatiates a new KeyPairGenerator.
abstract  void initialize(int keyLength, Object parameter, SecureRandom random)
          This method initializes the keypairgenerator with specific parameters.
For the parameters, see the details of the RSA- and DSA keypairgenerator implementation ( RSAKeyPairGenerator and DSAKeyPairGenerator ).
static void register(String name, String clazz)
          This method registers new keypairgenerators for usage with the KeyPairGenerator.getInstance(...) method.
The generator can be added the following way:
KeyPairGenerator.register("MyOwn", "mycompany.mypackage.MyKeyPairGenerator");
KeyPairGenerator kpg = KeyPairGenerator.getInstance("MyOwn");
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyPairGenerator

protected KeyPairGenerator()
Method Detail

initialize

public abstract void initialize(int keyLength,
                                Object parameter,
                                SecureRandom random)
                         throws CryptoException
This method initializes the keypairgenerator with specific parameters.
For the parameters, see the details of the RSA- and DSA keypairgenerator implementation ( RSAKeyPairGenerator and DSAKeyPairGenerator ).
Since:
3.0
See Also:
RSAKeyPairGenerator, DSAKeyPairGenerator

generateKeyPair

public abstract CryptoBag generateKeyPair()
This method generates a new keypair with the previously initialized parameters and returns it as a CryptoBag object.
Since:
3.0
See Also:
CryptoBag

getInstance

public static KeyPairGenerator getInstance(String algorithm)
                                    throws CryptoException
This method instatiates a new KeyPairGenerator.

KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");

Generators are currently available for RSA and DSA.

Parameters:
algorithm - the algorithm of the asymetric keypairgenerator (may be RSA or DSA)
Returns:
the KeyPairGenerator instance
Throws:
CryptoException - if the specified keypairgenerator implementation is not available.
Since:
3.0

register

public static void register(String name,
                            String clazz)
This method registers new keypairgenerators for usage with the KeyPairGenerator.getInstance(...) method.
The generator can be added the following way:

KeyPairGenerator.register("MyOwn", "mycompany.mypackage.MyKeyPairGenerator");
KeyPairGenerator kpg = KeyPairGenerator.getInstance("MyOwn");

Parameters:
name - the alias for the keypairgenerator implementation.
clazz - the fully qualified classname, for e.g. : iaik.me.security.rsa.RSAKeyPairGenerator
Since:
3.0

This Javadoc may contain text parts from IETF Internet Standard specifications, see copyright note) and RSA Data Security Public-Key Cryptography Standards (see copyright note).

IAIK-JCE ME 3.04, (c) 2002 IAIK, (c) 2003 to 2006 Stiftung SIC