de.flexiprovider.core.md
Class MDFamilyDigest

java.lang.Object
  |
  +--java.security.MessageDigestSpi
        |
        +--de.flexiprovider.api.MessageDigest
              |
              +--de.flexiprovider.core.md.MDFamilyDigest
Direct Known Subclasses:
MD4, MD5, RIPEMD128, RIPEMD160, RIPEMD256, RIPEMD320

public abstract class MDFamilyDigest
extends MessageDigest

This class is the base class for all message digests of the MD family (MD4, MD5, RIPEMD128, ...).

Author:
Martin Döring

Field Summary
protected  int[] state
          state of the engine
protected  int[] x
          internal buffer for processing
 
Constructor Summary
protected MDFamilyDigest(int digestLength)
          Constructor.
 
Method Summary
 int getDigestLength()
           
protected  void initMessageDigest(int[] initialState)
          Initialize the function with an initial state.
protected  void padMessageDigest()
          this method performs the padding.
protected abstract  void processBlock()
          Compute the hash value of the current block.
protected static int rotateLeft(int x, int n)
          Left rotate the given word by the specified amount.
 void update(byte b)
          Update the engine with a single byte
 void update(byte[] bytes, int offset, int len)
          add a block of data from the array bytes to the message digest.
 
Methods inherited from class de.flexiprovider.api.MessageDigest
digest, digest, digest, engineDigest, engineGetDigestLength, engineReset, engineUpdate, engineUpdate, reset, update
 
Methods inherited from class java.security.MessageDigestSpi
clone, engineDigest
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

protected int[] x
internal buffer for processing

state

protected int[] state
state of the engine
Constructor Detail

MDFamilyDigest

protected MDFamilyDigest(int digestLength)
Constructor.
Parameters:
digestLength - the digest length
Method Detail

initMessageDigest

protected void initMessageDigest(int[] initialState)
Initialize the function with an initial state.
Parameters:
initialState - the initial state

getDigestLength

public int getDigestLength()
Overrides:
getDigestLength in class MessageDigest
Returns:
the digest length in bytes.

update

public void update(byte b)
Update the engine with a single byte
Overrides:
update in class MessageDigest
Parameters:
b - byte to be added.

update

public void update(byte[] bytes,
                   int offset,
                   int len)
add a block of data from the array bytes to the message digest. The block starts offset bytes into the array, and is of size length.
Overrides:
update in class MessageDigest
Parameters:
bytes - byte array to process
offset - offset into the array to start from
len - number of bytes to process

padMessageDigest

protected void padMessageDigest()
this method performs the padding. A single 1-bit is appended and then 0-bits, until only 64 bits are left free in the final block to enter the total length of the entered message.

processBlock

protected abstract void processBlock()
Compute the hash value of the current block.

rotateLeft

protected static int rotateLeft(int x,
                                int n)
Left rotate the given word by the specified amount.
Parameters:
x - the word
n - the rotation amount
Returns:
the rotated word