edu.rit.crypto
Class MuH1MessageDigest

java.lang.Object
  extended by edu.rit.crypto.MuH1MessageDigest

public class MuH1MessageDigest
extends Object

Class MuH1MessageDigest provides a message digest algorithm using the MicroHash-One (μH-1) 32-bit one-way hash function. The algorithm is:

μH-1 Message Digest Algorithm

  1. [Padding] Append zero or more 0x00 bytes to make the length of the byte sequence equal to a multiple of four bytes.
     
  2. [Initialize chaining variable] C <- 0x045b9e58.
     
  3. For each four-byte chunk of the byte sequence (including padding bytes if any):
     
    1. M <- The next four bytes of the byte sequence converted to an integer in big-endian order.
       
    2. C <- MuH1.compress (C, M).
       
  4. Return message digest value = C.

The μH-1 compression function used in Step (3b) is defined in class MuH1.

As with the μH-1 compression function, the μH-1 message digest algorithm is intended to be used in applications where it only has to withstand attack for a short time, a few milliseconds at most. See class MuH1 for further information.

Note: Class MuH1MessageDigest is not multiple thread safe.


Constructor Summary
MuH1MessageDigest()
          Construct a new message digest object for calculating the μH-1 message digest of a sequence of bytes.
 
Method Summary
 void accumulate(byte b)
          Accumulate a byte into this message digest object.
 void accumulate(byte[] buf)
          Accumulate a byte array into this message digest object.
 void accumulate(byte[] buf, int off, int len)
          Accumulate a portion of a byte array into this message digest object.
 void accumulate(int i)
          Accumulate a four-byte integer into this message digest object.
 int hash()
          Obtain this message digest object's one-way hash value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MuH1MessageDigest

public MuH1MessageDigest()
Construct a new message digest object for calculating the μH-1 message digest of a sequence of bytes.

Method Detail

accumulate

public void accumulate(int i)
Accumulate a four-byte integer into this message digest object.

Parameters:
i - Integer.

accumulate

public void accumulate(byte b)
Accumulate a byte into this message digest object.

Parameters:
b - Byte.

accumulate

public void accumulate(byte[] buf)
Accumulate a byte array into this message digest object.

Parameters:
buf - Byte array.
Throws:
NullPointerException - (unchecked exception) Thrown if buf is null.

accumulate

public void accumulate(byte[] buf,
                       int off,
                       int len)
Accumulate a portion of a byte array into this message digest object.

Parameters:
buf - Byte array.
off - Index of first byte to accumulate.
len - Number of bytes to accumulate.
Throws:
NullPointerException - (unchecked exception) Thrown if buf is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if off < 0, len < 0, or off+len > buf.length.

hash

public int hash()
Obtain this message digest object's one-way hash value. Padding bytes are accumulated if necessary, then the one-way hash value is computed and returned.

Note: After calling hash(), do not accumulate anything further into this message digest object. The results will be incorrect.

Returns:
One-way hash value.


Copyright © 2001-2006 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.