public abstract class PKCS11KeyFactory extends java.security.KeyFactorySpi implements PKCS11EngineClass
Modifier and Type | Field and Description |
---|---|
protected PKCS11KeySpec |
pkcs11KeySpec_
The specification how to generate the key.
|
protected boolean |
pkcs11OperationInitialized_
Indicates, if the PKCS#11 signature/verify is already initialized for the next operation round.
|
static int |
PKCS8_VERSION
The PKCS#8 version field in the ASN.1 encoding.
|
protected iaik.pkcs.pkcs11.Session |
session_
The session this object works with.
|
protected java.security.KeyFactory |
softwareDelegate_
This is the software delegate object to use, if the provided key spec is not the key spec for a
PKCS#11 key.
|
protected TokenManager |
tokenManager_
Token manager used to login session, if required.
|
Constructor and Description |
---|
PKCS11KeyFactory()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected java.security.Key |
createKey(iaik.pkcs.pkcs11.objects.Object keyCreationTemplate)
This method creates a Java key from the given key creation template.
|
protected java.security.PrivateKey |
engineGeneratePrivate(java.security.spec.KeySpec keySpec)
Generates a private key object from the provided key specification (key material).
|
protected java.security.PublicKey |
engineGeneratePublic(java.security.spec.KeySpec keySpec)
Generates a public key object from the provided key specification (key material).
|
protected java.security.spec.KeySpec |
engineGetKeySpec(java.security.Key key,
java.lang.Class keySpecClass)
Returns a specification (key material) of the given key object.
|
protected java.security.Key |
engineTranslateKey(java.security.Key key)
Translates a key object, whose provider may be unknown or potentially untrusted, into a
corresponding key object of this key factory.
|
protected void |
finalize()
Tries to close the used session.
|
protected void |
finalizePkcs11Operation()
The internal session finalization method, if the current operation has been finished.
|
protected abstract java.lang.String |
getAlgorithmName()
Return the JCA standard name of this key factory algorithm.
|
protected abstract java.lang.String |
getSoftwareDelegateAlgorithm()
Return the name of the software algorithm to use, if this object must use a softwre delegation
object.
|
protected void |
initializePkcs11Operation()
The internal session initialization method, if all necessary member variables are set.
|
protected void |
initializeSession()
Sets up an appropriate session.
|
protected void |
initializeSoftwareDelegate()
Initialize the software delegate secure random and store a reference in
softwareDelegate_ . |
protected boolean |
isSessionAppropriate(iaik.pkcs.pkcs11.Session session,
PKCS11KeySpec pkcs11KeySpec)
Checks, if the given session is appropriate for use accodring to the given key spec.
|
boolean |
isSupportedBy(TokenManager tokenManager)
Check, if the current token of the given token manager supports the required features for this
engine class.
|
protected abstract java.security.PrivateKey |
pkcs11GeneratePrivate(java.security.spec.KeySpec keySpec)
Generates a private key object from the provided key specification (key material).
|
protected abstract java.security.PublicKey |
pkcs11GeneratePublic(java.security.spec.KeySpec keySpec)
Generates a public key object from the provided key specification (key material).
|
protected abstract java.security.spec.KeySpec |
pkcs11GetKeySpec(java.security.Key key,
java.lang.Class keySpecClass)
Returns a specification (key material) of the given key object.
|
protected java.security.Key |
pkcs11TranslateKey(java.security.Key key)
Translates a key object, whose provider may be unknown or potentially untrusted, into a
corresponding key object of this key factory.
|
public static final int PKCS8_VERSION
protected TokenManager tokenManager_
protected iaik.pkcs.pkcs11.Session session_
protected boolean pkcs11OperationInitialized_
protected PKCS11KeySpec pkcs11KeySpec_
protected java.security.KeyFactory softwareDelegate_
public boolean isSupportedBy(TokenManager tokenManager)
isSupportedBy
in interface PKCS11EngineClass
tokenManager
- The token manager. Used to get information about the current token.protected java.security.PublicKey engineGeneratePublic(java.security.spec.KeySpec keySpec) throws java.security.spec.InvalidKeySpecException
engineGeneratePublic
in class java.security.KeyFactorySpi
keySpec
- the specification (key material) of the public key.java.security.spec.InvalidKeySpecException
- if the given key specification is inappropriate for this key factory to produce a
public key.protected java.security.PrivateKey engineGeneratePrivate(java.security.spec.KeySpec keySpec) throws java.security.spec.InvalidKeySpecException
engineGeneratePrivate
in class java.security.KeyFactorySpi
keySpec
- the specification (key material) of the private key.java.security.spec.InvalidKeySpecException
- if the given key specification is inappropriate for this key factory to produce a
private key.protected java.security.spec.KeySpec engineGetKeySpec(java.security.Key key, java.lang.Class keySpecClass) throws java.security.spec.InvalidKeySpecException
keySpec
identifies
the specification class in which the key material should be returned. It could, for example, be
DSAPublicKeySpec.class
, to indicate that the key material should be returned in an
instance of the DSAPublicKeySpec
class.engineGetKeySpec
in class java.security.KeyFactorySpi
key
- The key.keySpecClass
- The specification class in which the key material should be returned.java.security.spec.InvalidKeySpecException
- if the requested key specification is inappropriate for the given key, or the
given key cannot be dealt with (e.g., the given key has an unrecognized format).protected java.security.Key engineTranslateKey(java.security.Key key) throws java.security.InvalidKeyException
engineTranslateKey
in class java.security.KeyFactorySpi
key
- the key whose provider is unknown or untrusted.java.security.InvalidKeyException
- if the given key cannot be processed by this key factory.protected abstract java.lang.String getSoftwareDelegateAlgorithm()
protected abstract java.lang.String getAlgorithmName()
protected void initializeSession()
protected void initializePkcs11Operation()
protected void finalizePkcs11Operation()
protected void initializeSoftwareDelegate()
softwareDelegate_
.protected boolean isSessionAppropriate(iaik.pkcs.pkcs11.Session session, PKCS11KeySpec pkcs11KeySpec) throws iaik.pkcs.pkcs11.TokenException
session
- The seesion to check.pkcs11KeySpec
- The key spec to check against.iaik.pkcs.pkcs11.TokenException
- If getting the necessary information about the session fails.protected java.security.Key createKey(iaik.pkcs.pkcs11.objects.Object keyCreationTemplate) throws java.security.spec.InvalidKeySpecException
keyCreationTemplate
- The template for the PKCS#11 key object.java.security.spec.InvalidKeySpecException
- If creating the PKCS#11 key fails.protected abstract java.security.PublicKey pkcs11GeneratePublic(java.security.spec.KeySpec keySpec) throws java.security.spec.InvalidKeySpecException
keySpec
- the specification (key material) of the public key.java.security.spec.InvalidKeySpecException
- if the given key specification is inappropriate for this key factory to produce a
public key.protected abstract java.security.PrivateKey pkcs11GeneratePrivate(java.security.spec.KeySpec keySpec) throws java.security.spec.InvalidKeySpecException
keySpec
- the specification (key material) of the private key.java.security.spec.InvalidKeySpecException
- if the given key specification is inappropriate for this key factory to produce a
private key.protected abstract java.security.spec.KeySpec pkcs11GetKeySpec(java.security.Key key, java.lang.Class keySpecClass) throws java.security.spec.InvalidKeySpecException
keySpec
identifies
the specification class in which the key material should be returned. It could, for example, be
DSAPublicKeySpec.class
, to indicate that the key material should be returned in an
instance of the DSAPublicKeySpec
class.key
- The key.keySpecClass
- The specification class in which the key material should be returned.java.security.spec.InvalidKeySpecException
- if the requested key specification is inappropriate for the given key, or the
given key cannot be dealt with (e.g., the given key has an unrecognized format).protected java.security.Key pkcs11TranslateKey(java.security.Key key) throws java.security.InvalidKeyException
key
- the key whose provider is unknown or untrusted.java.security.InvalidKeyException
- if the given key cannot be processed by this key factory.protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
- If finalization 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