public abstract class PKCS11KeyPairGenerator extends java.security.KeyPairGeneratorSpi implements PKCS11EngineClass
Modifier and Type | Field and Description |
---|---|
protected boolean |
initialized_
Indicates that we have been already initialized.
|
protected PKCS11KeyPairGenerationSpec |
keyPairGenerationSpec_
The parameters for this key generator.
|
protected boolean |
pkcs11OperationInitialized_
Indicates, if the PKCS#11 signature/verify is already initialized for the next operation round.
|
protected iaik.pkcs.pkcs11.Session |
session_
The session this object works with.
|
protected TokenManager |
tokenManager_
Token manager used to login session, if required.
|
protected iaik.pkcs.pkcs11.MechanismInfo[][] |
usedMechanismInfos_
The mechanism info is the same for all digest mechanisms.
|
protected iaik.pkcs.pkcs11.Mechanism[] |
usedMechanisms_
The list of used mechanisms.
|
Modifier | Constructor and Description |
---|---|
protected |
PKCS11KeyPairGenerator()
Construct new generator.
|
Modifier and Type | Method and Description |
---|---|
protected IAIKPKCS11PrivateKey |
createPkcs11PrivateKey(TokenManager tokenManager,
iaik.pkcs.pkcs11.objects.PrivateKey privateKeyObject)
Create a new JCE RSA private key with the given PKCS#11 object.
|
protected IAIKPKCS11PublicKey |
createPkcs11PublicKey(TokenManager tokenManager,
iaik.pkcs.pkcs11.objects.PublicKey publicKeyObject)
Create a new JCE RSA public key with the given PKCS#11 object.
|
protected iaik.pkcs.pkcs11.objects.Object |
createPrivateKeyCreationTemplate(PKCS11KeyPairGenerationSpec keyPairGenerationSpec)
Create the public key template to use as input for the key-pair generation.
|
protected iaik.pkcs.pkcs11.objects.Object |
createPublicKeyCreationTemplate(PKCS11KeyPairGenerationSpec keyPairGenerationSpec)
Create the public key template to use as input for the key-pair generation.
|
protected void |
finalize()
Tries to close the used session.
|
protected void |
finalizePkcs11Operation()
The internal session finalization method, if the current operation has been finished.
|
java.security.KeyPair |
generateKeyPair()
Generate a new key pair.
|
protected abstract java.lang.String |
getAlgorithmName()
Get the JCA algorithm name, e.g.
|
protected abstract iaik.pkcs.pkcs11.Mechanism |
getMechanism()
Get the mechanism that this key-pair generator uses.
|
protected iaik.pkcs.pkcs11.MechanismInfo[][] |
getUsedMechanismFeatures()
Returns an two-dimensional array of MechanismInfos that this engine class uses.
|
protected iaik.pkcs.pkcs11.Mechanism[] |
getUsedMechanisms()
Returns an array of Mechanisms that this engine class uses.
|
void |
initialize(java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
Just throws an UnsupportedOperationException.
|
void |
initialize(int keysize,
java.security.SecureRandom random)
Just throws an UnsupportedOperationException.
|
protected void |
initializePkcs11Operation()
The internal session initialization method, if all necessary member variables are set.
|
protected void |
initializeSession()
Sets up an appropriate session.
|
boolean |
isSupportedBy(TokenManager tokenManager)
Check, if the current token of the given token manager supports the required features for this
engine class.
|
protected void |
validateAlgorithmParameterSpec(java.security.spec.AlgorithmParameterSpec parameters)
Check, if the given internal parameters are appropriate.
|
protected TokenManager tokenManager_
protected iaik.pkcs.pkcs11.Session session_
protected PKCS11KeyPairGenerationSpec keyPairGenerationSpec_
protected boolean initialized_
protected boolean pkcs11OperationInitialized_
protected iaik.pkcs.pkcs11.Mechanism[] usedMechanisms_
protected iaik.pkcs.pkcs11.MechanismInfo[][] usedMechanismInfos_
protected PKCS11KeyPairGenerator()
protected iaik.pkcs.pkcs11.Mechanism[] getUsedMechanisms()
getRequiredMechanismFeatures()
method.getUsedMechanismFeatures()
. May be empty, but must not be null.protected iaik.pkcs.pkcs11.MechanismInfo[][] getUsedMechanismFeatures()
getUsedMechanisms()
. The array at this index is the list of used feature
combinations used by this engine. The current token must at least support one mechanism and one
of the feature combinations (expressed as a MechanismInfo) of the same machanism.getUsedMechanisms()
. The token must at
least supprot one of these features.public boolean isSupportedBy(TokenManager tokenManager)
isSupportedBy
in interface PKCS11EngineClass
tokenManager
- The token manager. Used to get information about the current token.public void initialize(int keysize, java.security.SecureRandom random) throws java.security.InvalidParameterException
initialize
in class java.security.KeyPairGeneratorSpi
keysize
- The size of the keys in bits.random
- The source of randomness.java.security.InvalidParameterException
- If the key-size is unsupported.public void initialize(java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random) throws java.security.InvalidAlgorithmParameterException
initialize
in class java.security.KeyPairGeneratorSpi
params
- The algorithm parameters, which must be an instance of PKCS11KeyPairGenerationSpec and
must not be null.random
- The source of randomness. This implementation ignores this parameter.java.security.InvalidAlgorithmParameterException
- If the given parameters are invalid.public java.security.KeyPair generateKeyPair()
generateKeyPair
in class java.security.KeyPairGeneratorSpi
protected iaik.pkcs.pkcs11.objects.Object createPrivateKeyCreationTemplate(PKCS11KeyPairGenerationSpec keyPairGenerationSpec)
keyPairGenerationSpec
- The algorithm parameters provided by the application.protected iaik.pkcs.pkcs11.objects.Object createPublicKeyCreationTemplate(PKCS11KeyPairGenerationSpec keyPairGenerationSpec)
keyPairGenerationSpec
- The algorithm parameters provided by the application.protected IAIKPKCS11PrivateKey createPkcs11PrivateKey(TokenManager tokenManager, iaik.pkcs.pkcs11.objects.PrivateKey privateKeyObject)
tokenManager
- The token manager of the token the object resides on.privateKeyObject
- The PKCS#11 private key object.protected IAIKPKCS11PublicKey createPkcs11PublicKey(TokenManager tokenManager, iaik.pkcs.pkcs11.objects.PublicKey publicKeyObject)
tokenManager
- The token manager of the token the object resides on.publicKeyObject
- The PKCS#11 public key object.protected void initializeSession()
protected void initializePkcs11Operation()
protected void finalizePkcs11Operation()
protected abstract iaik.pkcs.pkcs11.Mechanism getMechanism()
protected abstract java.lang.String getAlgorithmName()
protected void validateAlgorithmParameterSpec(java.security.spec.AlgorithmParameterSpec parameters) throws java.security.InvalidAlgorithmParameterException
null
.parameters
- The parameters to check.java.security.InvalidAlgorithmParameterException
- If the parameters are inappropriate.protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
- If disposing the session fails.IAIK JavaSecurity Website https://jce.iaik.tugraz.at/
IAIK at Graz University of Technology, Austria, Europe
Copyright 2001-2023 IAIK, Graz University of Technology, Inffeldgasse 16a, 8010 Graz, Austria. All Rights Reserved. Version 1.9.4