Top Description Inners Fields Constructors Methods
sun.security.rsa

pack-priv abstract Class RSAKeyPairGenerator

extends KeyPairGeneratorSpi
Class Inheritance
Known Direct Subclasses
sun.security.rsa.RSAKeyPairGenerator.Legacy, sun.security.rsa.RSAKeyPairGenerator.PSS
Imports
java.math.BigInteger, java.security.*, java.security.spec.AlgorithmParameterSpec, .RSAKeyGenParameterSpec, sun.security.jca.JCAUtil, sun.security.rsa.RSAUtil.KeyType

RSA keypair generation. Standard algorithm, minimum key length 512 bit. We generate two random primes until we find two where phi is relative prime to the public exponent. Default exponent is 65537. It has only bit 0 and bit 4 set, which makes it particularly efficient.
Author
Andreas Sterbenz
Since
1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class

Field Summary

Modifier and TypeField and Description
private AlgorithmParameterSpec
private int
private BigInteger
private SecureRandom
private static final BigInteger
private static final BigInteger
private static final BigInteger
private final RSAUtil.KeyType
private boolean

Constructor Summary

AccessConstructor and Description
pack-priv
RSAKeyPairGenerator(RSAUtil.KeyType type, int defKeySize)

Method Summary

Modifier and TypeMethod and Description
private static KeyPair
public KeyPair
generateKeyPair()

Implements abstract java.security.KeyPairGeneratorSpi.generateKeyPair.

Generates a key pair.
private static BigInteger
getSqrt(int keySize)

public void
initialize(int
the keysize. This is an algorithm-specific metric, such as modulus length, specified in number of bits.
keySize
,
SecureRandom
the source of randomness for this generator.
random
)

Implements abstract java.security.KeyPairGeneratorSpi.initialize.

Initializes the key pair generator for a certain keysize, using the default parameter set.
public void
initialize(AlgorithmParameterSpec
the parameter set used to generate the keys.
params
,
SecureRandom
the source of randomness for this generator.
random
)

Overrides java.security.KeyPairGeneratorSpi.initialize.

Initializes the key pair generator using the specified parameter set and user-provided source of randomness.
private static boolean

Field Detail

keyParamsback to summary
private AlgorithmParameterSpec keyParams
keySizeback to summary
private int keySize
publicExponentback to summary
private BigInteger publicExponent
randomback to summary
private SecureRandom random
SQRT_2048back to summary
private static final BigInteger SQRT_2048
SQRT_3072back to summary
private static final BigInteger SQRT_3072
SQRT_4096back to summary
private static final BigInteger SQRT_4096
typeback to summary
private final RSAUtil.KeyType type
useNewback to summary
private boolean useNew

Constructor Detail

RSAKeyPairGeneratorback to summary
pack-priv RSAKeyPairGenerator(RSAUtil.KeyType type, int defKeySize)

Method Detail

createKeyPairback to summary
private static KeyPair createKeyPair(RSAUtil.KeyType type, AlgorithmParameterSpec keyParams, BigInteger n, BigInteger e, BigInteger p, BigInteger q)
generateKeyPairback to summary
public KeyPair generateKeyPair()

Implements abstract java.security.KeyPairGeneratorSpi.generateKeyPair.

Doc from java.security.KeyPairGeneratorSpi.generateKeyPair.

Generates a key pair. 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.

Returns:KeyPair

the newly generated KeyPair

getSqrtback to summary
private static BigInteger getSqrt(int keySize)
initializeback to summary
public void initialize(int keySize, SecureRandom random)

Implements abstract java.security.KeyPairGeneratorSpi.initialize.

Doc from java.security.KeyPairGeneratorSpi.initialize.

Initializes the key pair generator for a certain keysize, using the default parameter set.

Parameters
keySize:int

the keysize. This is an algorithm-specific metric, such as modulus length, specified in number of bits.

random:SecureRandom

the source of randomness for this generator.

initializeback to summary
public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException

Overrides java.security.KeyPairGeneratorSpi.initialize.

Doc from java.security.KeyPairGeneratorSpi.initialize.

Initializes the key pair generator using the specified parameter set and user-provided source of randomness.

This concrete method has been added to this previously-defined abstract class. (For backwards compatibility, it cannot be abstract.) It may be overridden by a provider to initialize the key pair generator. Such an override is expected to throw an InvalidAlgorithmParameterException if a parameter is inappropriate for this key pair generator. If this method is not overridden, it always throws an UnsupportedOperationException.

Parameters
params:AlgorithmParameterSpec

the parameter set used to generate the keys.

random:SecureRandom

the source of randomness for this generator.

Exceptions
InvalidAlgorithmParameterException:
if the given parameters are inappropriate for this key pair generator.
isRelativePrimeback to summary
private static boolean isRelativePrime(BigInteger e, BigInteger bi)
sun.security.rsa back to summary

public final Class RSAKeyPairGenerator.Legacy

extends RSAKeyPairGenerator
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from sun.security.rsa.RSAKeyPairGenerator:
generateKeyPairinitializeinitialize

Constructor Detail

Legacyback to summary
public Legacy()
sun.security.rsa back to summary

public final Class RSAKeyPairGenerator.PSS

extends RSAKeyPairGenerator
Class Inheritance

Constructor Summary

AccessConstructor and Description
public
PSS()

Method Summary

Inherited from sun.security.rsa.RSAKeyPairGenerator:
generateKeyPairinitializeinitialize

Constructor Detail

PSSback to summary
public PSS()