Class InitializedMessageDigest

  • Direct Known Subclasses:
    InitializedMessageDigest.OneShot

    public abstract class InitializedMessageDigest
    extends MessageDigest
    The InitializedMessageDigest class is a subclass of the base class MessageDigest. 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 of InitializedMessageDigest algorithms must extend this class and implement all the abstract methods.

    A tear or card reset event resets a InitializedMessageDigest object 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
    • Constructor Detail

      • InitializedMessageDigest

        protected InitializedMessageDigest()
        protected constructor
    • Method Detail

      • setInitialDigest

        public abstract void setInitialDigest​(byte[] state,
                                              short stateOffset,
                                              short stateLength,
                                              byte[] digestedMsgLenBuf,
                                              short digestedMsgLenOffset,
                                              short digestedMsgLenLength)
                                       throws CryptoException
        This method sets the state of the hash engine in place of the default value used by the MessageDigest superclass. 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 this InitializedMessageDigest object via the update and doFinal methods 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 into state array where the state data begins
        stateLength - the length of data in state array.
        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 within digestedMsgLenBuf where 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 in digestedMsgLenBuf
        Throws:
        CryptoException - with the following reason codes:
        • CryptoException.ILLEGAL_VALUE if the parameter initialDigestLength is 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 (see ALG_* algorithm descriptions ALG_SHA).