Package javacard.security
Class InitializedMessageDigest
- java.lang.Object
-
- javacard.security.MessageDigest
-
- javacard.security.InitializedMessageDigest
-
- Direct Known Subclasses:
InitializedMessageDigest.OneShot
public abstract class InitializedMessageDigest extends MessageDigest
TheInitializedMessageDigestclass is a subclass of the base classMessageDigest. This class is used to generate a hash representing a specified message but with the additional capability to set the state of the hash engine. This state is the intermediate state of the hash engine when a block-aligned portion of the message has been previously processed. Implementations ofInitializedMessageDigestalgorithms must extend this class and implement all the abstract methods.A tear or card reset event resets a
InitializedMessageDigestobject to the initial state (state upon construction).Even if a transaction is in progress, update of intermediate result state in the implementation instance shall not participate in the transaction.
- Since:
- 2.2.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classInitializedMessageDigest.OneShotTheOneShotclass is a specialization of theInitializedMessageDigestclass intended to support efficient one-shot hash operations that may avoid persistent memory writes entirely.
-
Field Summary
-
Fields inherited from class javacard.security.MessageDigest
ALG_MD5, ALG_NULL, ALG_RIPEMD160, ALG_SHA, ALG_SHA_224, ALG_SHA_256, ALG_SHA_384, ALG_SHA_512, ALG_SHA3_224, ALG_SHA3_256, ALG_SHA3_384, ALG_SHA3_512, ALG_SM3, LENGTH_MD5, LENGTH_RIPEMD160, LENGTH_SHA, LENGTH_SHA_224, LENGTH_SHA_256, LENGTH_SHA_384, LENGTH_SHA_512, LENGTH_SHA3_224, LENGTH_SHA3_256, LENGTH_SHA3_384, LENGTH_SHA3_512, LENGTH_SM3
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedInitializedMessageDigest()protected constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract voidsetInitialDigest(byte[] state, short stateOffset, short stateLength, byte[] digestedMsgLenBuf, short digestedMsgLenOffset, short digestedMsgLenLength)This method sets the state of the hash engine in place of the default value used by theMessageDigestsuperclass.-
Methods inherited from class javacard.security.MessageDigest
doFinal, doIntermediateMessageDigest, getAlgorithm, getInitializedMessageDigestInstance, getInstance, getLength, isIntermediateMessageDigestSupported, reset, update
-
-
-
-
Method Detail
-
setInitialDigest
public abstract void setInitialDigest(byte[] state, short stateOffset, short stateLength, byte[] digestedMsgLenBuf, short digestedMsgLenOffset, short digestedMsgLenLength) throws CryptoExceptionThis method sets the state of the hash engine in place of the default value used by theMessageDigestsuperclass. This state is the intermediate state of the hash engine when a block-aligned portion of the message has been previously processed. The remaining bytes of the message must be presented to thisInitializedMessageDigestobject via theupdateanddoFinalmethods to generate the final message digest.Note:
- The maximum allowed value of the byte length of the first part of the message is algorithm specific
- Parameters:
state- input buffer containing the intermediate state of the hash engine when a block-aligned portion of the message has been previously processed (using the same algorithm).stateOffset- offset intostatearray where the state data beginsstateLength- the length of data instatearray.digestedMsgLenBuf- the byte array containing the number of bytes in the first part of the message that has previously been processed to obtain the specified intermediate state. The value must be a multiple of the block size defined by the hash algorithm.digestedMsgLenOffset- the offset withindigestedMsgLenBufwhere the digested length begins (the bytes starting at this offset for digestedMsgLenLength bytes are concatenated to form the actual length of the message portion already processed)digestedMsgLenLength- byte length of the value stored indigestedMsgLenBuf- Throws:
CryptoException- with the following reason codes:CryptoException.ILLEGAL_VALUEif the parameterstateLengthis not equal to the intermediate hash value size of the algorithm or if the number of bytes in the first part of the message that has previously been hashed is 0 or not a multiple of the algorithm's block size or greater than the maximum length supported by the algorithm (seeALG_*algorithm descriptionsALG_SHA).
-
-