public class RSAKeyPairGenerator
extends java.security.KeyPairGenerator
An RSA key generator is used to generate an RSA key pair, which consists of
an RSA public key and an RSA private key. This key pair can then be used with
RSA-based cryptographic algorithms (ex: RSA digital signatures -
RsaSignature).
The key size of an RSA key pair refers to the length of the modulus. When not
specified, a default key size of 1024-bits is used; when specified, a minimum
key size of 512-bits is enforced. Algorithm parameters are not supported by
this implementation; if provided during initialization they will be rejected.
When a public exponent is specified by a call to
initialize(int, BigInteger, SecureRandom), the public exponent must
be odd; when not specified, a default public exponent of 65537 is used.
An instance of this algorithm can be obtained using the Java Cryptography
Architecture (JCA), by requesting an 'RSA' key pair generator from the
Entrust cryptographic
service provider. This can be done using the following call:
KeyPairGenerator.getInstance("RSA", "Entrust");| Constructor and Description |
|---|
RSAKeyPairGenerator()
The constructor; creates a new instance of the RSA key pair generation
algorithm.
|
| Modifier and Type | Method and Description |
|---|---|
java.security.KeyPair |
generateKeyPair()
Generates a key pair.
|
void |
initialize(java.security.spec.AlgorithmParameterSpec params)
Initializes the key pair generator using the specified parameter set and
Entrust's default
SecureRandom implementation (see
Entrust.getDefaultSecureRandomInstance()). |
void |
initialize(java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
Initializes the key pair generator using the specified parameter set and
user-provided source of randomness.
|
void |
initialize(int keysize)
Initializes the key pair generator for a certain keysize using a default
parameter set and Entrust's default
SecureRandom
implementation (see
Entrust.getDefaultSecureRandomInstance()). |
void |
initialize(int keysize,
java.math.BigInteger publicExponent,
java.security.SecureRandom random)
Initializes the key pair generator for a certain keysize, public
exponent, and user-provided source of randomness.
|
void |
initialize(int keysize,
java.security.SecureRandom secureRandom)
Initializes the key pair generator for a certain keysize and
user-provided source of randomness.
|
public RSAKeyPairGenerator()
Applications should not use this constructor, instead the key pair
generation algorithm should be requested from the appropriate JCA/JCE
cryptographic service provider as follows:
KeyPairGenerator.getInstance("RSA", "Entrust").
public void initialize(java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
throws java.security.InvalidAlgorithmParameterException
initialize in class java.security.KeyPairGeneratorparams - [FIPS 140-2 data input] the parameter set used to generate the
keys.random - [FIPS 140-2 control input] the source of randomness for this
generator.java.security.InvalidAlgorithmParameterException - [FIPS 140-2 status output] if the given parameters are
inappropriate for this key pair generator.Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationspublic void initialize(java.security.spec.AlgorithmParameterSpec params)
throws java.security.InvalidAlgorithmParameterException
SecureRandom implementation (see
Entrust.getDefaultSecureRandomInstance()).
initialize in class java.security.KeyPairGeneratorparams - [FIPS 140-2 data input] the parameter set used to generate the
keys.java.security.InvalidAlgorithmParameterException - [FIPS 140-2 status output] if the given parameters are
inappropriate for this key pair generator.Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationspublic void initialize(int keysize)
SecureRandom
implementation (see
Entrust.getDefaultSecureRandomInstance()).
initialize in class java.security.KeyPairGeneratorkeysize - [FIPS 140-2 data input] the keysize. This is an
algorithm-specific metric, such as modulus length, specified
in number of bits.java.security.InvalidParameterException - [FIPS 140-2 status output] if the keysize is
not supported by this KeyPairGenerator object.Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationspublic void initialize(int keysize,
java.security.SecureRandom secureRandom)
initialize in class java.security.KeyPairGeneratorkeysize - [FIPS 140-2 data input] the keysize. This is an
algorithm-specific metric, such as modulus length, specified
in number of bits.secureRandom - [FIPS 140-2 control input] the source of randomness for this
generator.java.security.InvalidAlgorithmParameterException - [FIPS 140-2 status output] if the given parameters are
inappropriate for this key pair generator.Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationspublic void initialize(int keysize,
java.math.BigInteger publicExponent,
java.security.SecureRandom random)
throws java.security.InvalidParameterException
Typical values for the public exponent are the Fermat primes F4 and F0 (0x10001 and 0x11) and, less commonly, 17.
keysize - [FIPS 140-2 data input] the keysize. This is an
algorithm-specific metric, such as modulus length, specified
in number of bits.publicExponent - [FIPS 140-2 data input] the public exponent (must be odd)random - [FIPS 140-2 control input] the source of randomness for this
generator.Fips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationsjava.security.InvalidParameterExceptionpublic java.security.KeyPair generateKeyPair()
Unless an initialization method is called using a KeyPairGenerator interface, algorithm-specific defaults will be used. This will generate a new key pair every time it is called.
generateKeyPair in class java.security.KeyPairGeneratorFips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operations