< prev index next >
src/java.base/share/classes/javax/crypto/KeyGenerator.java
Print this page
*** 36,46 ****
import sun.security.util.Debug;
/**
* This class provides the functionality of a secret (symmetric) key generator.
*
! * <p>Key generators are constructed using one of the <code>getInstance</code>
* class methods of this class.
*
* <p>KeyGenerator objects are reusable, i.e., after a key has been
* generated, the same KeyGenerator object can be re-used to generate further
* keys.
--- 36,46 ----
import sun.security.util.Debug;
/**
* This class provides the functionality of a secret (symmetric) key generator.
*
! * <p>Key generators are constructed using one of the {@code getInstance}
* class methods of this class.
*
* <p>KeyGenerator objects are reusable, i.e., after a key has been
* generated, the same KeyGenerator object can be re-used to generate further
* keys.
*** 55,100 ****
* <i>source of randomness</i>.
* There is an
* {@link #init(int, java.security.SecureRandom) init}
* method in this KeyGenerator class that takes these two universally
* shared types of arguments. There is also one that takes just a
! * <code>keysize</code> argument, and uses the SecureRandom implementation
* of the highest-priority installed provider as the source of randomness
* (or a system-provided source of randomness if none of the installed
* providers supply a SecureRandom implementation), and one that takes just a
* source of randomness.
*
* <p>Since no other parameters are specified when you call the above
! * algorithm-independent <code>init</code> methods, it is up to the
* provider what to do about the algorithm-specific parameters (if any) to be
* associated with each of the keys.
*
* <li><b>Algorithm-Specific Initialization</b>
* <p>For situations where a set of algorithm-specific parameters already
* exists, there are two
* {@link #init(java.security.spec.AlgorithmParameterSpec) init}
! * methods that have an <code>AlgorithmParameterSpec</code>
! * argument. One also has a <code>SecureRandom</code> argument, while the
* other uses the SecureRandom implementation
* of the highest-priority installed provider as the source of randomness
* (or a system-provided source of randomness if none of the installed
* providers supply a SecureRandom implementation).
* </ul>
*
* <p>In case the client does not explicitly initialize the KeyGenerator
! * (via a call to an <code>init</code> method), each provider must
* supply (and document) a default initialization.
*
* <p> Every implementation of the Java platform is required to support the
! * following standard <code>KeyGenerator</code> algorithms with the keysizes in
* parentheses:
* <ul>
! * <li><tt>AES</tt> (128)</li>
! * <li><tt>DES</tt> (56)</li>
! * <li><tt>DESede</tt> (168)</li>
! * <li><tt>HmacSHA1</tt></li>
! * <li><tt>HmacSHA256</tt></li>
* </ul>
* These algorithms are described in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyGenerator">
* KeyGenerator section</a> of the
* Java Cryptography Architecture Standard Algorithm Name Documentation.
--- 55,100 ----
* <i>source of randomness</i>.
* There is an
* {@link #init(int, java.security.SecureRandom) init}
* method in this KeyGenerator class that takes these two universally
* shared types of arguments. There is also one that takes just a
! * {@code keysize} argument, and uses the SecureRandom implementation
* of the highest-priority installed provider as the source of randomness
* (or a system-provided source of randomness if none of the installed
* providers supply a SecureRandom implementation), and one that takes just a
* source of randomness.
*
* <p>Since no other parameters are specified when you call the above
! * algorithm-independent {@code init} methods, it is up to the
* provider what to do about the algorithm-specific parameters (if any) to be
* associated with each of the keys.
*
* <li><b>Algorithm-Specific Initialization</b>
* <p>For situations where a set of algorithm-specific parameters already
* exists, there are two
* {@link #init(java.security.spec.AlgorithmParameterSpec) init}
! * methods that have an {@code AlgorithmParameterSpec}
! * argument. One also has a {@code SecureRandom} argument, while the
* other uses the SecureRandom implementation
* of the highest-priority installed provider as the source of randomness
* (or a system-provided source of randomness if none of the installed
* providers supply a SecureRandom implementation).
* </ul>
*
* <p>In case the client does not explicitly initialize the KeyGenerator
! * (via a call to an {@code init} method), each provider must
* supply (and document) a default initialization.
*
* <p> Every implementation of the Java platform is required to support the
! * following standard {@code KeyGenerator} algorithms with the keysizes in
* parentheses:
* <ul>
! * <li>{@code AES} (128)</li>
! * <li>{@code DES} (56)</li>
! * <li>{@code DESede} (168)</li>
! * <li>{@code HmacSHA1}</li>
! * <li>{@code HmacSHA256}</li>
* </ul>
* These algorithms are described in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyGenerator">
* KeyGenerator section</a> of the
* Java Cryptography Architecture Standard Algorithm Name Documentation.
*** 175,198 ****
this.provider.getName());
}
}
/**
! * Returns the algorithm name of this <code>KeyGenerator</code> object.
*
* <p>This is the same name that was specified in one of the
! * <code>getInstance</code> calls that created this
! * <code>KeyGenerator</code> object.
*
! * @return the algorithm name of this <code>KeyGenerator</code> object.
*/
public final String getAlgorithm() {
return this.algorithm;
}
/**
! * Returns a <code>KeyGenerator</code> object that generates secret keys
* for the specified algorithm.
*
* <p> This method traverses the list of registered security Providers,
* starting with the most preferred Provider.
* A new KeyGenerator object encapsulating the
--- 175,198 ----
this.provider.getName());
}
}
/**
! * Returns the algorithm name of this {@code KeyGenerator} object.
*
* <p>This is the same name that was specified in one of the
! * {@code getInstance} calls that created this
! * {@code KeyGenerator} object.
*
! * @return the algorithm name of this {@code KeyGenerator} object.
*/
public final String getAlgorithm() {
return this.algorithm;
}
/**
! * Returns a {@code KeyGenerator} object that generates secret keys
* for the specified algorithm.
*
* <p> This method traverses the list of registered security Providers,
* starting with the most preferred Provider.
* A new KeyGenerator object encapsulating the
*** 206,216 ****
* See the KeyGenerator section in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyGenerator">
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
! * @return the new <code>KeyGenerator</code> object.
*
* @exception NullPointerException if the specified algorithm is null.
*
* @exception NoSuchAlgorithmException if no Provider supports a
* KeyGeneratorSpi implementation for the
--- 206,216 ----
* See the KeyGenerator section in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyGenerator">
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
! * @return the new {@code KeyGenerator} object.
*
* @exception NullPointerException if the specified algorithm is null.
*
* @exception NoSuchAlgorithmException if no Provider supports a
* KeyGeneratorSpi implementation for the
*** 222,232 ****
throws NoSuchAlgorithmException {
return new KeyGenerator(algorithm);
}
/**
! * Returns a <code>KeyGenerator</code> object that generates secret keys
* for the specified algorithm.
*
* <p> A new KeyGenerator object encapsulating the
* KeyGeneratorSpi implementation from the specified provider
* is returned. The specified provider must be registered
--- 222,232 ----
throws NoSuchAlgorithmException {
return new KeyGenerator(algorithm);
}
/**
! * Returns a {@code KeyGenerator} object that generates secret keys
* for the specified algorithm.
*
* <p> A new KeyGenerator object encapsulating the
* KeyGeneratorSpi implementation from the specified provider
* is returned. The specified provider must be registered
*** 241,262 ****
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
* @param provider the name of the provider.
*
! * @return the new <code>KeyGenerator</code> object.
*
* @exception NullPointerException if the specified algorithm is null.
*
* @exception NoSuchAlgorithmException if a KeyGeneratorSpi
* implementation for the specified algorithm is not
* available from the specified provider.
*
* @exception NoSuchProviderException if the specified provider is not
* registered in the security provider list.
*
! * @exception IllegalArgumentException if the <code>provider</code>
* is null or empty.
*
* @see java.security.Provider
*/
public static final KeyGenerator getInstance(String algorithm,
--- 241,262 ----
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
* @param provider the name of the provider.
*
! * @return the new {@code KeyGenerator} object.
*
* @exception NullPointerException if the specified algorithm is null.
*
* @exception NoSuchAlgorithmException if a KeyGeneratorSpi
* implementation for the specified algorithm is not
* available from the specified provider.
*
* @exception NoSuchProviderException if the specified provider is not
* registered in the security provider list.
*
! * @exception IllegalArgumentException if the {@code provider}
* is null or empty.
*
* @see java.security.Provider
*/
public static final KeyGenerator getInstance(String algorithm,
*** 267,277 ****
return new KeyGenerator((KeyGeneratorSpi)instance.impl,
instance.provider, algorithm);
}
/**
! * Returns a <code>KeyGenerator</code> object that generates secret keys
* for the specified algorithm.
*
* <p> A new KeyGenerator object encapsulating the
* KeyGeneratorSpi implementation from the specified Provider
* object is returned. Note that the specified Provider object
--- 267,277 ----
return new KeyGenerator((KeyGeneratorSpi)instance.impl,
instance.provider, algorithm);
}
/**
! * Returns a {@code KeyGenerator} object that generates secret keys
* for the specified algorithm.
*
* <p> A new KeyGenerator object encapsulating the
* KeyGeneratorSpi implementation from the specified Provider
* object is returned. Note that the specified Provider object
*** 283,301 ****
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
* @param provider the provider.
*
! * @return the new <code>KeyGenerator</code> object.
*
* @exception NullPointerException if the specified algorithm is null.
*
* @exception NoSuchAlgorithmException if a KeyGeneratorSpi
* implementation for the specified algorithm is not available
* from the specified Provider object.
*
! * @exception IllegalArgumentException if the <code>provider</code>
* is null.
*
* @see java.security.Provider
*/
public static final KeyGenerator getInstance(String algorithm,
--- 283,301 ----
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
* @param provider the provider.
*
! * @return the new {@code KeyGenerator} object.
*
* @exception NullPointerException if the specified algorithm is null.
*
* @exception NoSuchAlgorithmException if a KeyGeneratorSpi
* implementation for the specified algorithm is not available
* from the specified Provider object.
*
! * @exception IllegalArgumentException if the {@code provider}
* is null.
*
* @see java.security.Provider
*/
public static final KeyGenerator getInstance(String algorithm,
*** 305,317 ****
return new KeyGenerator((KeyGeneratorSpi)instance.impl,
instance.provider, algorithm);
}
/**
! * Returns the provider of this <code>KeyGenerator</code> object.
*
! * @return the provider of this <code>KeyGenerator</code> object
*/
public final Provider getProvider() {
synchronized (lock) {
disableFailover();
return provider;
--- 305,317 ----
return new KeyGenerator((KeyGeneratorSpi)instance.impl,
instance.provider, algorithm);
}
/**
! * Returns the provider of this {@code KeyGenerator} object.
*
! * @return the provider of this {@code KeyGenerator} object
*/
public final Provider getProvider() {
synchronized (lock) {
disableFailover();
return provider;
*** 435,445 ****
* set and a user-provided source of randomness.
*
* @param params the key generation parameters
* @param random the source of randomness for this key generator
*
! * @exception InvalidAlgorithmParameterException if <code>params</code> is
* inappropriate for this key generator
*/
public final void init(AlgorithmParameterSpec params, SecureRandom random)
throws InvalidAlgorithmParameterException
{
--- 435,445 ----
* set and a user-provided source of randomness.
*
* @param params the key generation parameters
* @param random the source of randomness for this key generator
*
! * @exception InvalidAlgorithmParameterException if {@code params} is
* inappropriate for this key generator
*/
public final void init(AlgorithmParameterSpec params, SecureRandom random)
throws InvalidAlgorithmParameterException
{
< prev index next >