public abstract class PKCS11Hash extends java.security.MessageDigest implements PKCS11EngineClass
getProvider()
. It binds to the token of this provider instance.Modifier and Type | Field and Description |
---|---|
protected int |
hashValueLength_
The length of the hash value produced by this hash.
|
protected boolean |
initialized_
Indicate that this object is initialized.
|
protected iaik.pkcs.pkcs11.Mechanism |
mechanism_
The current cryptoki mechanism to use.
|
protected boolean |
pkcs11OperationInitialized_
Indicates, if the PKCS#11 session is already initialized for the next operation round.
|
protected iaik.pkcs.pkcs11.Session |
session_
The session this object works with.
|
protected java.security.MessageDigest |
softwareDelegate_
If the current token does not support the required mechanism and software delegation is
enabled, this variable holds the software delegate.
|
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.
|
protected boolean |
useSoftwareDelegate_
If set to true, this engine uses the software delegate.
|
Modifier | Constructor and Description |
---|---|
protected |
PKCS11Hash(java.lang.String algorithmName,
int hashValueLength,
iaik.pkcs.pkcs11.Mechanism mechanism)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected byte[] |
engineDigest()
Completes the hash computation by performing final operations such as padding.
|
protected int |
engineGetDigestLength()
Returns the digest length in bytes.
|
protected void |
engineReset()
Resets the digest for further use.
|
protected void |
engineUpdate(byte input)
Updates the digest using the specified byte.
|
protected void |
engineUpdate(byte[] data,
int offset,
int length)
Updates the digest using the specified array of bytes, starting at the specified offset.
|
protected void |
finalize()
Tries to close the used session.
|
protected void |
finalizePkcs11Operation()
The internal session finalization method, if the current operation has been finished.
|
TokenManager |
getTokenManager()
Get the manager of the token that processes this digest.
|
iaik.pkcs.pkcs11.Mechanism |
getUsedMechanism() |
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.
|
protected void |
initialize()
The internal initialization method, here 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 hash to delegate operations.
|
boolean |
isSupportedBy(TokenManager tokenManager)
Check, if the current token of the given token manager supports the required features for this
engine class.
|
void |
setTokenManager(TokenManager tokenManager)
Set the manager of the token that processes this digest.
|
protected TokenManager tokenManager_
protected iaik.pkcs.pkcs11.Session session_
protected int hashValueLength_
protected iaik.pkcs.pkcs11.Mechanism mechanism_
protected iaik.pkcs.pkcs11.Mechanism[] usedMechanisms_
protected iaik.pkcs.pkcs11.MechanismInfo[][] usedMechanismInfos_
protected boolean initialized_
protected boolean pkcs11OperationInitialized_
protected boolean useSoftwareDelegate_
protected java.security.MessageDigest softwareDelegate_
protected PKCS11Hash(java.lang.String algorithmName, int hashValueLength, iaik.pkcs.pkcs11.Mechanism mechanism)
algorithmName
- The name of this hash algorithm.hashValueLength
- The length of the producted hash value in bytes; e.g. 20 for SHA-1.mechanism
- The PKCS#11 mechanism of this hash.protected int engineGetDigestLength()
engineGetDigestLength
in class java.security.MessageDigestSpi
protected void engineUpdate(byte input)
engineUpdate
in class java.security.MessageDigestSpi
input
- the byte to use for the update.protected void engineUpdate(byte[] data, int offset, int length)
engineUpdate
in class java.security.MessageDigestSpi
data
- the array of bytes to use for the update.offset
- the offset to start from in the array of bytes.length
- the number of bytes to use, starting at offset
.protected byte[] engineDigest()
engineDigest
has been called, the engine should be reset (see
engineReset
). Resetting is the responsibility of the engine implementor.engineDigest
in class java.security.MessageDigestSpi
protected void engineReset()
engineReset
in class java.security.MessageDigestSpi
protected iaik.pkcs.pkcs11.Mechanism[] getUsedMechanisms()
getRequiredMechanismFeatures()
method.getUsedMechanismFeatures()
. May be empty, but must not be null.public iaik.pkcs.pkcs11.Mechanism getUsedMechanism()
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 TokenManager getTokenManager()
protected void initialize()
protected void initializeSession() throws iaik.pkcs.pkcs11.TokenException
iaik.pkcs.pkcs11.TokenException
- If opening or login of the session fails.protected void initializePkcs11Operation() throws iaik.pkcs.pkcs11.TokenException
iaik.pkcs.pkcs11.TokenException
- If the key is invalid for this operation.protected void finalizePkcs11Operation()
protected void initializeSoftwareDelegate()
public void setTokenManager(TokenManager tokenManager)
tokenManager
- The manager of the token that processes this digest.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