public abstract class PKCS11Mac extends javax.crypto.MacSpi implements PKCS11EngineClass
Modifier and Type | Field and Description |
---|---|
protected byte[] |
buffer_
Buffer to delay the first data block to be able to calculate the MAC in one step.
|
protected boolean |
currentKeyIsSoftwareKey_
Indiecates that the currently used key is a software key.
|
protected int |
defaultMacLength_
The mac length.
|
protected boolean |
initialized_
Indicates, if this object is initialized and ready for encryption or decryption.
|
protected IAIKPKCS11SecretKey |
key_
The key to use for encryption/decryption.
|
protected iaik.pkcs.pkcs11.objects.SecretKey |
keyObject_
The PKCS#11 key object of the current key.
|
protected PKCS11MacSpec |
params_
The params_.
|
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 javax.crypto.Mac |
softwareDelegate_
The software implementation, if the currently used key is not a PKCS#11 key.
|
protected TokenManager |
tokenManager_
Token manager used to login session, if required.
|
protected boolean |
updateUsed_
Indicates, if the currently active operation has already used any update function.
|
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 |
PKCS11Mac(iaik.pkcs.pkcs11.Mechanism macMechanism,
int defaultMacLength)
Instantiates a new pKC s11 mac.
|
protected |
PKCS11Mac(iaik.pkcs.pkcs11.Mechanism macMechanism,
iaik.pkcs.pkcs11.Mechanism macGeneralMechanism,
int defaultMacLength)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkKeyObject(iaik.pkcs.pkcs11.objects.Key keyObject)
Check the given key object, if it is acceptable for this cipher.
|
protected byte[] |
engineDoFinal()
Returns the calculated MAC value.
|
protected int |
engineGetMacLength()
Returns the length of the calculated MAC value in bytes.
|
protected void |
engineInit(java.security.Key key,
java.security.spec.AlgorithmParameterSpec params)
Initializes this Mac object with given secret key and algorithm parameter specification.
|
protected void |
engineReset()
Resets this Mac object for being able to be used for further MAC computations, either by using
the same secret key again, or using a new key by properly re-initializing this MAC object.
|
protected void |
engineUpdate(byte input)
Processes the given byte.
|
protected void |
engineUpdate(byte[] data,
int offset,
int length)
Processes the given number of bytes, supplied in a byte array starting at the given position.
|
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()
Get the JCA standard name of this signautre algorithm.
|
protected iaik.pkcs.pkcs11.Mechanism |
getMechanism()
Get the current mechanism of this cipher object.
|
protected iaik.pkcs.pkcs11.MechanismInfo[][] |
getUsedMechanismFeatures()
Returns an two-dimensional array of MechanismInfos that this engine class uses.
|
protected void |
initialize()
The internal initialization method, if all necessary member variables are set.
|
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()
Instantiate a new software cipher to delegate software keys operations.
|
boolean |
isSupportedBy(TokenManager tokenManager)
Check, if the current token of the given token manager supports the required features for this
engine class.
|
protected byte[] |
pkcs11DoFinal()
Returns the calculated MAC value.
|
protected int |
pkcs11GetMacLength()
Returns the length of the calculated MAC value in bytes.
|
protected void |
pkcs11Init(java.security.Key key,
java.security.spec.AlgorithmParameterSpec params)
Initializes this Mac object with given secret key and algorithm parameter specification.
|
protected void |
pkcs11Prepare()
Pkcs11 prepare.
|
protected void |
pkcs11Reset()
Resets this Mac object for being able to be used for further MAC computations, either by using
the same secret key again, or using a new key by properly re-initializing this MAC object.
|
protected void |
pkcs11Update(byte input)
Processes the given byte.
|
protected void |
pkcs11Update(byte[] data,
int offset,
int length)
Processes the given number of bytes, supplied in a byte array starting at the given position.
|
protected iaik.pkcs.pkcs11.Session session_
protected TokenManager tokenManager_
protected IAIKPKCS11SecretKey key_
protected iaik.pkcs.pkcs11.objects.SecretKey keyObject_
protected boolean initialized_
protected boolean pkcs11OperationInitialized_
protected boolean updateUsed_
protected byte[] buffer_
protected boolean currentKeyIsSoftwareKey_
protected javax.crypto.Mac softwareDelegate_
protected iaik.pkcs.pkcs11.Mechanism[] usedMechanisms_
protected iaik.pkcs.pkcs11.MechanismInfo[][] usedMechanismInfos_
protected PKCS11MacSpec params_
protected int defaultMacLength_
protected PKCS11Mac(iaik.pkcs.pkcs11.Mechanism macMechanism, int defaultMacLength)
macMechanism
- the mac mechanismdefaultMacLength
- the default mac lengthprotected PKCS11Mac(iaik.pkcs.pkcs11.Mechanism macMechanism, iaik.pkcs.pkcs11.Mechanism macGeneralMechanism, int defaultMacLength)
macMechanism
- the mac mechanismmacGeneralMechanism
- the mac general mechanismdefaultMacLength
- the default mac length for this mechanismprotected 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.protected void checkKeyObject(iaik.pkcs.pkcs11.objects.Key keyObject) throws java.security.InvalidKeyException
keyObject
- The key object to check.java.security.InvalidKeyException
- If this cipher cannot work with this type of key object.protected byte[] engineDoFinal() throws java.lang.IllegalStateException
After the MAC finally has been calculated, the MAC object is reset for being able to be used
for further MAC computations, either by using the same secret key again, or using a new key by
properly re-initializing this MAC object. This implementation delegates this call to the
software provider, if the current key is a software key. If the key is a key of this provider,
it delegates the call to the corresponding pkcs11 method with prefix pkcs11
instead of engine
.
engineDoFinal
in class javax.crypto.MacSpi
java.lang.IllegalStateException
- if this MAC is in not in a proper state for performing a engineDoFinal
operationprotected byte[] pkcs11DoFinal() throws java.lang.IllegalStateException
After the MAC finally has been calculated, the MAC object is reset for being able to be used for further MAC computations, either by using the same secret key again, or using a new key by properly re-initializing this MAC object.
java.lang.IllegalStateException
- if this MAC is in not in a proper state for performing a engineDoFinal
operationprotected int engineGetMacLength()
pkcs11
instead of engine
.engineGetMacLength
in class javax.crypto.MacSpi
protected int pkcs11GetMacLength()
protected void engineInit(java.security.Key key, java.security.spec.AlgorithmParameterSpec params) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
pkcs11
instead of engine
.engineInit
in class javax.crypto.MacSpi
key
- the secret key for initializing this MAC object.params
- the algorithm parameter specification.java.security.InvalidKeyException
- if the given key cannot be used for initializing this MAC objectjava.security.InvalidAlgorithmParameterException
- if the given algorithm parameters do not match to this MAC objectprotected void initializeSoftwareDelegate()
protected abstract java.lang.String getAlgorithmName()
protected void pkcs11Init(java.security.Key key, java.security.spec.AlgorithmParameterSpec params) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
key
- the secret key for initializing this MAC object.params
- the algorithm parameter specification.java.security.InvalidKeyException
- if the given key cannot be used for initializing this MAC objectjava.security.InvalidAlgorithmParameterException
- if the given algorithm parameters do not match to this MAC objectprotected void engineReset()
pkcs11
instead of engine
.engineReset
in class javax.crypto.MacSpi
protected void pkcs11Reset()
protected void pkcs11Prepare() throws java.lang.IllegalStateException, IAIKPkcs11Exception
java.lang.IllegalStateException
- if this MAC engine was not initialized yetIAIKPkcs11Exception
- if initialization of the underlying pkcs11 module failsprotected void engineUpdate(byte input) throws java.lang.IllegalStateException
pkcs11
instead of
engine
.engineUpdate
in class javax.crypto.MacSpi
input
- the byte to be processed.java.lang.IllegalStateException
- if this MAC is in not in a proper state for performing a engineUpdate
operationprotected void pkcs11Update(byte input) throws java.lang.IllegalStateException
input
- the byte to be processed.java.lang.IllegalStateException
- if this MAC is in not in a proper state for performing a engineUpdate
operationprotected void engineUpdate(byte[] data, int offset, int length) throws java.lang.IllegalStateException
pkcs11
instead of engine
.engineUpdate
in class javax.crypto.MacSpi
data
- the byte array holding the data to be processedoffset
- the offset indicating the start position within the input byte arraylength
- the number of bytes to be processedjava.lang.IllegalStateException
- if this MAC is in not in a proper state for performing a engineUpdate
operationprotected void pkcs11Update(byte[] data, int offset, int length) throws java.lang.IllegalStateException
data
- the byte array holding the data to be processedoffset
- the offset indicating the start position within the input byte arraylength
- the number of bytes to be processedjava.lang.IllegalStateException
- if this MAC is in not in a proper state for performing a engineUpdate
operationprotected iaik.pkcs.pkcs11.Mechanism getMechanism()
protected void initializeSession()
protected void initializePkcs11Operation() throws iaik.pkcs.pkcs11.TokenException
iaik.pkcs.pkcs11.TokenException
- If initializing the signing operation fails.protected void finalizePkcs11Operation()
protected void initialize() throws java.security.InvalidAlgorithmParameterException, java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
- If the parameter specs are invalid.java.security.InvalidKeyException
- If the key is invalid for this operation.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