org.alliance.core.file.hash
Class Tiger

java.lang.Object
  extended by java.security.MessageDigestSpi
      extended by java.security.MessageDigest
          extended by org.alliance.core.file.hash.Tiger
All Implemented Interfaces:
java.lang.Cloneable

public final class Tiger
extends java.security.MessageDigest
implements java.lang.Cloneable

Tiger is a fast new hash function, by Ross Anderson and Eli Biham. This class is a simple Java implementation of the 192-bit Tiger algorithm, based on the sample C code published by Eli Biham on http://www.cs.technion.ac.il/~biham/Reports/Tiger/ in its HTML reference Appendix. It computes a 192-bit digest that is considered stronger, but faster to compute than 160-bit SHA-1. Its input is a set of 64-bytes blocks. The last block of a digested message must include a required padding byte which must be 0x01, the remaining padding bytes must be set to 0x00. May be in the future, this class will be part of the standard JCE (Java Cryptography Environment) included in Java 1.5, code named... Tiger! For now Java 1.4, code named Merlin, does not have this digest algorithm, and only includes Adler32 or CRC32 (in java.util.zip), and MD4, MD5 or SHA1 (in javax.crypto.Mac, included in the SUN JCE). You can include it in your own Secrurty Provider by inserting these properties in your Provider derived class: put("MessageDigest.Tiger", "com.limegroup.gnutella.security.Tiger");


Constructor Summary
Tiger()
          Creates a Tiger object with default initial state.
 
Method Summary
 java.lang.Object clone()
          Clones this object.
 byte[] engineDigest()
          Completes the hash computation by performing final operations such as padding.
 int engineDigest(byte[] hashvalue, int offset, int len)
          Completes the hash computation by performing final operations such as padding.
 int engineGetDigestLength()
          Returns the digest length in bytes.
 void engineReset()
          Reset then initialize the digest context.
 void engineUpdate(byte input)
          Updates the digest using the specified byte.
 void engineUpdate(byte[] input, int offset, int len)
          Updates the digest using the specified array of bytes, starting at the specified offset.
protected  void init()
          Initialize the digest context.
 
Methods inherited from class java.security.MessageDigest
digest, digest, digest, getAlgorithm, getDigestLength, getInstance, getInstance, getInstance, getProvider, isEqual, reset, toString, update, update, update, update
 
Methods inherited from class java.security.MessageDigestSpi
engineUpdate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tiger

public Tiger()
Creates a Tiger object with default initial state.

Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones this object.

Overrides:
clone in class java.security.MessageDigest
Throws:
java.lang.CloneNotSupportedException

engineGetDigestLength

public int engineGetDigestLength()
Returns the digest length in bytes. Can be used to allocate your own output buffer when computing multiple digests. Overrides the protected abstract method of java.security.MessageDigestSpi.

Overrides:
engineGetDigestLength in class java.security.MessageDigestSpi
Returns:
the digest length in bytes.

engineReset

public void engineReset()
Reset then initialize the digest context. Overrides the protected abstract method of java.security.MessageDigestSpi.

Specified by:
engineReset in class java.security.MessageDigestSpi

init

protected void init()
Initialize the digest context.


engineUpdate

public void engineUpdate(byte input)
Updates the digest using the specified byte. Requires internal buffering, and may be slow. Overrides the protected abstract method of java.security.MessageDigestSpi.

Specified by:
engineUpdate in class java.security.MessageDigestSpi
Parameters:
input - the byte to use for the update.

engineUpdate

public void engineUpdate(byte[] input,
                         int offset,
                         int len)
Updates the digest using the specified array of bytes, starting at the specified offset. Input length can be any size. May require internal buffering, if input blocks are not multiple of 64 bytes. Overrides the protected abstract method of java.security.MessageDigestSpi.

Specified by:
engineUpdate in class java.security.MessageDigestSpi
Parameters:
input - the array of bytes to use for the update.
offset - the offset to start from in the array of bytes.

engineDigest

public byte[] engineDigest()
Completes the hash computation by performing final operations such as padding. Computes the final hash and returns the final value as a byte[24] array. Once engineDigest has been called, the engine will be automatically reset as specified in the JavaSecurity MessageDigest specification. For faster operations with multiple digests, allocate your own array and use engineDigest(byte[], int offset, int len). * Overrides the protected abstract method of java.security.MessageDigestSpi.

Specified by:
engineDigest in class java.security.MessageDigestSpi
Returns:
the length of the digest stored in the output buffer.

engineDigest

public int engineDigest(byte[] hashvalue,
                        int offset,
                        int len)
                 throws java.security.DigestException
Completes the hash computation by performing final operations such as padding. Once engineDigest has been called, the engine will be automatically reset (see engineReset). Overrides the protected abstract method of java.security.MessageDigestSpi.

Overrides:
engineDigest in class java.security.MessageDigestSpi
Parameters:
hashvalue - the output buffer in which to store the digest.
offset - offset to start from in the output buffer
len - number of bytes within buf allotted for the digest. Both this default implementation and the SUN provider do not return partial digests. The presence of this parameter is solely for consistency in our API's. If the value of this parameter is less than the actual digest length, the method will throw a DigestException. This parameter is ignored if its value is greater than or equal to the actual digest length.
Returns:
the length of the digest stored in the output buffer.
Throws:
java.security.DigestException