public final class PK11KeyPairGenerator extends KeyPairGeneratorSpi
PQGParams
KeyPairGeneratorSpi.Usage
Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
logger |
static PQGParams |
PQG1024
Pre-cooked PQG values for 1024-bit keypairs, along with the seed,
counter, and H values needed to verify them.
|
static PQGParams |
PQG512
Pre-cooked PQG values for 512-bit keypairs, along with the seed,
counter, and H values needed to verify them.
|
static PQGParams |
PQG768
Pre-cooked PQG values for 768-bit keypairs, along with the seed,
counter, and H values needed to verify them.
|
Constructor and Description |
---|
PK11KeyPairGenerator(PK11Token token,
KeyPairAlgorithm algorithm)
Constructor for PK11KeyPairGenerator.
|
Modifier and Type | Method and Description |
---|---|
void |
extractablePairs(boolean extractable) |
java.security.KeyPair |
generateKeyPair()
Generates a key pair on a token.
|
int |
getCurveCodeByName(java.lang.String curveName) |
void |
initialize(java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
Initializes this KeyPairGenerator with the given algorithm-specific
parameters.
|
void |
initialize(int strength,
java.security.SecureRandom random)
Initializes this KeyPairGenerator with the given key strength.
|
boolean |
keygenOnInternalToken() |
void |
sensitivePairs(boolean sensitive) |
void |
setKeyPairUsages(KeyPairGeneratorSpi.Usage[] usages,
KeyPairGeneratorSpi.Usage[] usages_mask)
Sets the requested key usages desired for the
generated key pair.
|
void |
temporaryPairs(boolean temp) |
public static org.slf4j.Logger logger
public static final PQGParams PQG1024
public static final PQGParams PQG768
public static final PQGParams PQG512
public PK11KeyPairGenerator(PK11Token token, KeyPairAlgorithm algorithm) throws java.security.NoSuchAlgorithmException, TokenException
token
- The PKCS #11 token that the keypair will be generated on.algorithm
- The type of key that will be generated. Currently,
KeyPairAlgorithm.RSA
,
KeyPairAlgorithm.DSA
and
KeyPairAlgorithm.EC
are supported.java.security.NoSuchAlgorithmException
TokenException
public void initialize(int strength, java.security.SecureRandom random) throws java.security.InvalidParameterException
For DSA key generation, pre-cooked PQG values will be used be used if the key size is 512, 768, or 1024. Otherwise, an InvalidParameterException will be thrown.
initialize
in class KeyPairGeneratorSpi
strength
- The strength (size) of the keys that will be generated.random
- Ignoredjava.security.InvalidParameterException
- If the key strength is not
supported by the algorithm or this implementation.public void initialize(java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random) throws java.security.InvalidAlgorithmParameterException
initialize
in class KeyPairGeneratorSpi
params
- The algorithm-specific parameters that will govern
key pair generation.random
- Ignoredjava.security.InvalidAlgorithmParameterException
- If the parameters
are inappropriate for the key type or are not supported by
this implementation.public java.security.KeyPair generateKeyPair() throws TokenException
initialize
, otherwise uses defaults.generateKeyPair
in class KeyPairGeneratorSpi
TokenException
public boolean keygenOnInternalToken()
keygenOnInternalToken
in class KeyPairGeneratorSpi
public void temporaryPairs(boolean temp)
temporaryPairs
in class KeyPairGeneratorSpi
public void sensitivePairs(boolean sensitive)
sensitivePairs
in class KeyPairGeneratorSpi
public void extractablePairs(boolean extractable)
extractablePairs
in class KeyPairGeneratorSpi
public void setKeyPairUsages(KeyPairGeneratorSpi.Usage[] usages, KeyPairGeneratorSpi.Usage[] usages_mask)
setKeyPairUsages
in class KeyPairGeneratorSpi
usages
- List of desired key usages.usages_mask
- Corresponding mask for the key usages.
if a usages is desired, make sure it is in the mask as well.public int getCurveCodeByName(java.lang.String curveName) throws java.security.InvalidParameterException
getCurveCodeByName
in class KeyPairGeneratorSpi
java.security.InvalidParameterException