cryptix.provider.md

Class BlockMessageDigest

Known Direct Subclasses:
MD5, SHA0, SHA1

(package private) abstract class BlockMessageDigest
extends MessageDigest

This is a superclass for message digests that operate internally on blocks of data. It is not intended directly for use by application programmers.

Copyright © 1995-1997 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.4 $

Author:
David Hopwood

Since:
Cryptix 2.2.2

Constructor Summary

BlockMessageDigest(String algorithm)
Constructs a message digest with the specified algorithm name.

Method Summary

protected long
bitcount()
protected byte[]
engineDigest()
SPI: Calculates the final digest.
protected byte[]
engineDigest(byte[] data, int length)
SPI (for BlockMessageDigests only): Calculates the final digest.
protected int
engineGetDataLength()
SPI: Returns the length of the block that this hash function operates on.
protected void
engineReset()
SPI: Resets the digest.
protected void
engineTransform(byte[] data)
SPI (for BlockMessageDigests only): Performs a transformation on the given data, which is always one block long.
protected void
engineUpdate(byte b)
SPI: Updates the message digest with a byte of new data.
protected void
engineUpdate(byte[] data, int offset, int length)
SPI: Updates the message digest with new data.

Constructor Details

BlockMessageDigest

protected BlockMessageDigest(String algorithm)
Constructs a message digest with the specified algorithm name.

Parameters:
algorithm - the standard name of the digest algorithm.

Method Details

bitcount

protected long bitcount()

Returns:
number of bits hashed so far?


engineDigest

protected byte[] engineDigest()
SPI: Calculates the final digest. BlockMessageDigest subclasses should not usually override this method.

Returns:
the digest as a byte array.


engineDigest

protected byte[] engineDigest(byte[] data,
                              int length)
SPI (for BlockMessageDigests only): Calculates the final digest. data[0..length-1] contains the last incomplete input block. length will be less than engineDataLength().

Parameters:
data - the last incomplete block.
length - the length in bytes of the last block.

Returns:
the digest as a byte array.


engineGetDataLength

protected int engineGetDataLength()
SPI: Returns the length of the block that this hash function operates on.


engineReset

protected void engineReset()
SPI: Resets the digest. Subclasses that override engineReset should always call this implementation using super.engineReset().


engineTransform

protected void engineTransform(byte[] data)
SPI (for BlockMessageDigests only): Performs a transformation on the given data, which is always one block long.


engineUpdate

protected void engineUpdate(byte b)
SPI: Updates the message digest with a byte of new data.

Parameters:
b - the byte to be added.


engineUpdate

protected void engineUpdate(byte[] data,
                            int offset,
                            int length)
SPI: Updates the message digest with new data.

Parameters:
data - the data to be added.
offset - the start of the data in the array.
length - the number of bytes of data to add.