MessageDigestImpl



com.licel.jcardsim.crypto
Class MessageDigestImpl

java.lang.Object
  extended by javacard.security.MessageDigest
      extended by com.licel.jcardsim.crypto.MessageDigestImpl

public class MessageDigestImpl
extends MessageDigest

Implementation MessageDigest based on BouncyCastle CryptoAPI

See Also:
MessageDigest, MD5Digest, RIPEMD160Digest, SHA1Digest

Field Summary
 
Fields inherited from class javacard.security.MessageDigest
ALG_MD5, ALG_RIPEMD160, ALG_SHA
 
Constructor Summary
MessageDigestImpl(byte algorithm)
           
 
Method Summary
 short doFinal(byte[] inBuff, short inOffset, short inLength, byte[] outBuff, short outOffset)
          Generates a hash of all/last input data.
 byte getAlgorithm()
          Gets the Message digest algorithm.
 byte getLength()
          Returns the byte length of the hash.
 void reset()
          Resets the MessageDigest object to the initial state for further use.
 void update(byte[] inBuff, short inOffset, short inLength)
          Accumulates a hash of the input data.
 
Methods inherited from class javacard.security.MessageDigest
getInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageDigestImpl

public MessageDigestImpl(byte algorithm)
Method Detail

getAlgorithm

public byte getAlgorithm()
Description copied from class: MessageDigest
Gets the Message digest algorithm.

Specified by:
getAlgorithm in class MessageDigest
Returns:
the algorithm code defined above

getLength

public byte getLength()
Description copied from class: MessageDigest
Returns the byte length of the hash.

Specified by:
getLength in class MessageDigest
Returns:
hash length

doFinal

public short doFinal(byte[] inBuff,
                     short inOffset,
                     short inLength,
                     byte[] outBuff,
                     short outOffset)
Description copied from class: MessageDigest
Generates a hash of all/last input data. Completes and returns the hash computation after performing final operations such as padding. The MessageDigest object is reset to the initial state after this call is made.

The input and output buffer data may overlap.

Specified by:
doFinal in class MessageDigest
Parameters:
inBuff - the input buffer of data to be hashed
inOffset - the offset into the input buffer at which to begin hash generation
inLength - the byte length to hash
outBuff - the output buffer, may be the same as the input buffer
outOffset - the offset into the output buffer where the resulting hash value begins
Returns:
number of bytes of hash output in outBuff

update

public void update(byte[] inBuff,
                   short inOffset,
                   short inLength)
Description copied from class: MessageDigest
Accumulates a hash of the input data. This method requires temporary storage of intermediate results. In addition, if the input data length is not block aligned (multiple of block size) then additional internal storage may be allocated at this time to store a partial input data block. This may result in additional resource consumption and/or slow performance. This method should only be used if all the input data required for the hash is not available in one byte array. If all of the input data required for the hash is located in a single byte array, use of the doFinal() method is recommended. The doFinal() method must be called to complete processing of input data accumulated by one or more calls to the update() method.

Note:

  • If inLength is 0 this method does nothing.

Specified by:
update in class MessageDigest
Parameters:
inBuff - the input buffer of data to be hashed
inOffset - the offset into the input buffer at which to begin hash generation
inLength - the byte length to hash See also: MessageDigest.doFinal(byte[], short, short, byte[], short)

reset

public void reset()
Description copied from class: MessageDigest
Resets the MessageDigest object to the initial state for further use.

Specified by:
reset in class MessageDigest