h57451 s 00028/00096/00227 d D 1.7 97/12/09 15:24:48 luehe 8 7 c rm ,* e s 00004/00004/00319 d D 1.6 97/11/18 08:49:07 luehe 7 6 c replaced "Architecture" with "Extension" when referring to API Spec & Reference Guide e s 00004/00004/00319 d D 1.5 97/11/17 13:31:20 luehe 6 5 c removed "#ApplA" from anchor reference e s 00002/00002/00321 d D 1.4 97/10/22 15:29:59 luehe 5 4 c added tag e s 00003/00010/00320 d D 1.3 97/10/18 14:18:36 luehe 4 3 c moved javadocs example to JCESpec document (just to be safe ...) e s 00002/00003/00328 d D 1.2 97/10/10 12:42:07 luehe 3 1 c fixed getProvider javadocs e s 00000/00000/00000 d R 1.2 97/10/09 09:58:15 Codemgr 2 1 c SunPro Code Manager data about conflicts, renames, etc... c Name history : 1 0 security/JCE1.2/earlyaccess/javax.crypto.KeyGenerator.html e s 00331/00000/00000 d D 1.1 97/10/09 09:58:14 luehe 1 0 c date and time created 97/10/09 09:58:14 by luehe e u U f e 0 t T I 1 D 3 E 3 I 3 D 4 E 4 I 4 D 8 E 8 I 8 E 8 E 4 E 3 Class javax.crypto.KeyGenerator
D 4
All Packages  Class Hierarchy  This Package  Previous  Next  Index
E 4 I 4 D 8 All Packages Class Hierarchy This Package Previous Next Index E 8 I 8 All Packages Class Hierarchy This Package Previous Next Index E 8 E 4

Class javax.crypto.KeyGenerator

java.lang.Object
   |
   +----javax.crypto.KeyGenerator

D 8
public abstract class KeyGenerator E 8 I 8
public class KeyGenerator E 8
extends Object
This class provides the functionality of a (symmetric) key generator.

Key generators are constructed using the getInstance class method of this class. D 4

The following sequence of calls generates a (random) DES key:

 import java.security.KeyGenerator;
 KeyGenerator keygen = KeyGenerator.getInstance("DES");
 keygen.initialize(new SecureRandom());
 SecretKey key = keygen.generateKey();
 
E 4 D 8

The methods of KeyGenerator are divided into two groups:

KeyGenerator API (Application Program Interface)
These are the public methods which are visible to applications requesting access to a key generator.
KeyGenerator SPI (Service Provider Interface)
These are the (abstract) methods that must be implemented by providers of key generators. Each method in this group is prefixed by the keyword engine, and is called by a correspondingly-named public API method. For example, D 5 engineGenerateKey is called by generateKey. E 5 I 5 engineGenerateKey is called by generateKey.
E 8 I 8

KeyGenerator objects are reusable, i.e., after a key has been generated, the same KeyGenerator object can be re-used to generate further keys. E 8 E 5

See Also:
SecretKey, AlgorithmParameters, AlgorithmParameterSpec

Constructor Index

 o D 8 KeyGenerator(String)
Creates a KeyGenerator object for the specified algorithm. E 8 I 8 KeyGenerator(KeyGeneratorSpi, Provider, String)
Creates a KeyGenerator object. E 8

Method Index

 o D 8 engineGenerateKey()
SPI: Generates a secret key.
 o engineInit(AlgorithmParameterSpec, SecureRandom)
SPI: Initializes the key generator with the specified parameter set and a user-provided source of randomness.
 o engineInit(SecureRandom)
SPI: Initializes the key generator.
 o E 8 generateKey()
Generates a secret key.
 o getAlgorithm()
Returns the standard name of the key algorithm.
 o getInstance(String)
Generates a KeyGenerator object for the specified key algorithm.
 o getInstance(String, String)
Generates a KeyGenerator object for the specified key algorithm from the specified provider.
 o getProvider()
Returns the provider of this KeyGenerator object.
 o init(AlgorithmParameterSpec)
Initializes the key generator with the specified parameter set, using a system-provided source of randomness.
 o init(AlgorithmParameterSpec, SecureRandom)
Initializes the key generator with the specified parameter set and a user-provided source of randomness.
 o init(SecureRandom)
Initializes the key generator.

Constructors

D 8  o E 8 I 8  o E 8 KeyGenerator
D 8
 protected KeyGenerator(String algorithm)
E 8
I 8
 protected KeyGenerator(KeyGeneratorSpi keyGenSpi,
                        Provider provider,
                        String algorithm)
E 8
D 8
Creates a KeyGenerator object for the specified algorithm. E 8 I 8
Creates a KeyGenerator object. E 8

Parameters: D 8
algorithm - the standard name of the key algorithm. See Appendix A in the E 6 I 6 "../guide/security/CryptoSpec.html"> E 6 D 7 Java Cryptography Architecture API Specification & Reference E 7 I 7 Java Cryptography Extension API Specification & Reference E 7 for information about standard algorithm names. E 8 I 8
keyGenSpi - the delegate
provider - the provider
algorithm - the algorithm E 8

Methods

 o getAlgorithm
 public final String getAlgorithm()
Returns the standard name of the key algorithm. D 8 See Appendix A in the E 6 I 6 "../guide/security/CryptoSpec.html"> E 8 I 8 See Appendix A in the E 8 E 6 D 7 Java Cryptography Architecture API Specification & Reference E 7 I 7 Java Cryptography Extension API Specification & Reference E 7 for information about standard algorithm names.

Returns:
the standard algorithm name.
 o getInstance
D 8
 public static KeyGenerator getInstance(String algorithm) throws NoSuchAlgorithmException
E 8
I 8
 public static final KeyGenerator getInstance(String algorithm) throws NoSuchAlgorithmException
E 8
Generates a KeyGenerator object for the specified key algorithm.

Parameters:
algorithm - the standard name of the requested key algorithm. D 8 See Appendix A in the E 6 I 6 "../guide/security/CryptoSpec.html"> E 8 I 8 See Appendix A in the E 8 E 6 D 7 Java Cryptography Architecture API Specification & Reference E 7 I 7 Java Cryptography Extension API Specification & Reference E 7 for information about standard algorithm names.
Returns:
the new KeyGenerator object
Throws: NoSuchAlgorithmException
if a key generator for the requested algorithm is not available
 o getInstance
D 8
 public static KeyGenerator getInstance(String algorithm,
                                        String provider) throws NoSuchAlgorithmException, NoSuchProviderException
E 8
I 8
 public static final KeyGenerator getInstance(String algorithm,
                                              String provider) throws NoSuchAlgorithmException, NoSuchProviderException
E 8
Generates a KeyGenerator object for the specified key algorithm from the specified provider.

Parameters:
algorithm - the standard name of the requested key algorithm. D 8 See Appendix A in the E 6 I 6 "../guide/security/CryptoSpec.html"> E 8 I 8 See Appendix A in the E 8 E 6 D 7 Java Cryptography Architecture API Specification & Reference E 7 I 7 Java Cryptography Extension API Specification & Reference E 7 for information about standard algorithm names.
provider - the name of the provider
Returns:
the new KeyGenerator object
Throws: NoSuchAlgorithmException
if a key generator for the requested algorithm is not available from the provider
Throws: NoSuchProviderException
if the requested provider is not available
See Also:
Provider
 o getProvider
 public final Provider getProvider()
Returns the provider of this KeyGenerator object.

Returns: D 3
the provider of this KeyGenerator object, or null if the provider has not yet been set E 3 I 3
the provider of this KeyGenerator object E 3
 o init
D 8
 public void init(SecureRandom random)
E 8
I 8
 public final void init(SecureRandom random)
E 8
Initializes the key generator.

Parameters:
random - the source of randomness for this generator
D 8  o engineInit
 protected abstract void engineInit(SecureRandom random)
SPI: Initializes the key generator.

Parameters:
random - the source of randomness for this generator
E 8  o init
D 8
 public void init(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException
E 8
I 8
 public final void init(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException
E 8
Initializes the key generator with the specified parameter set, using a system-provided source of randomness.

Parameters:
params - the key generation parameters
Throws: InvalidAlgorithmParameterException
if the given parameters are inappropriate for this key generator
 o init
D 8
 public void init(AlgorithmParameterSpec params,
                  SecureRandom random) throws InvalidAlgorithmParameterException
E 8
I 8
 public final void init(AlgorithmParameterSpec params,
                        SecureRandom random) throws InvalidAlgorithmParameterException
E 8
Initializes the key generator with the specified parameter set and a user-provided source of randomness.

Parameters:
params - the key generation parameters
random - the source of randomness for this key generator
Throws: InvalidAlgorithmParameterException
if params is inappropriate for this key generator
D 8  o engineInit
 protected abstract void engineInit(AlgorithmParameterSpec params,
                                    SecureRandom random) throws InvalidAlgorithmParameterException
SPI: Initializes the key generator with the specified parameter set and a user-provided source of randomness.

Parameters:
params - the key generation parameters
random - the source of randomness for this key generator
Throws: InvalidAlgorithmParameterException
if params is inappropriate for this key generator
E 8  o generateKey
D 8
 public SecretKey generateKey()
E 8
I 8
 public final SecretKey generateKey()
E 8
Generates a secret key.

Returns:
the new key
D 8  o engineGenerateKey
 protected abstract SecretKey engineGenerateKey()
SPI: Generates a secret key.

Returns:
the new key
E 8
D 4
All Packages  Class Hierarchy  This Package  Previous  Next  Index
E 4 I 4 D 8 All Packages Class Hierarchy This Package Previous Next Index E 8 I 8 All Packages Class Hierarchy This Package Previous Next Index E 8 E 4 E 1