Top Description Fields Constructors Methods
sun.security.pkcs11

pack-priv final Class P11KeyPairGenerator

extends KeyPairGeneratorSpi
Class Inheritance
Imports
java.math.BigInteger, java.security.*, java.security.spec.*, javax.crypto.spec.DHParameterSpec, sun.security.provider.ParameterCache, sun.security.pkcs11.wrapper.*, sun.security.rsa.RSAKeyFactory

KeyPairGenerator implementation class. This class currently supports RSA, DSA, DH, and EC. Note that for DSA and DH we rely on the Sun and SunJCE providers to obtain the parameters from.
Author
Andreas Sterbenz
Since
1.5

Field Summary

Modifier and TypeField and Description
private final String
private int
private final int
private final long
private final int
private AlgorithmParameterSpec
private SecureRandom
private BigInteger
private final Token

Constructor Summary

AccessConstructor and Description
pack-priv
P11KeyPairGenerator(Token token, String algorithm, long mechanism)

Method Summary

Modifier and TypeMethod and Description
private void
checkKeySize(int keySize, AlgorithmParameterSpec params)

public KeyPair
generateKeyPair()

Implements abstract java.security.KeyPairGeneratorSpi.generateKeyPair.

Generates a key pair.

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.

Field Detail

algorithmback to summary
private final String algorithm
keySizeback to summary
private int keySize
maxKeySizeback to summary
private final int maxKeySize
mechanismback to summary
private final long mechanism
minKeySizeback to summary
private final int minKeySize
paramsback to summary
private AlgorithmParameterSpec params
randomback to summary
private SecureRandom random
rsaPublicExponentback to summary
private BigInteger rsaPublicExponent
tokenback to summary
private final Token token

Constructor Detail

P11KeyPairGeneratorback to summary
pack-priv P11KeyPairGenerator(Token token, String algorithm, long mechanism) throws PKCS11Exception

Method Detail

checkKeySizeback to summary
private void checkKeySize(int keySize, AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException
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

Annotations
@Override
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.

Annotations
@Override
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.

Annotations
@Override
Exceptions
InvalidAlgorithmParameterException:
if the given parameters are inappropriate for this key pair generator.