cryptix.provider.md
Class SHA1

java.lang.Object
  extended byjava.security.MessageDigestSpi
      extended byjava.security.MessageDigest
          extended bycryptix.provider.md.BlockMessageDigest
              extended bycryptix.provider.md.SHA1
All Implemented Interfaces:
java.lang.Cloneable

public final class SHA1
extends BlockMessageDigest
implements java.lang.Cloneable

This class implements the SHA-1 message digest algorithm.

BUG: The update method is missing.

References:

  1. Bruce Schneier, "Section 18.7 Secure Hash Algorithm (SHA)," Applied Cryptography, 2nd edition, John Wiley & Sons, 1996

  2. NIST FIPS PUB 180-1, "Secure Hash Standard", U.S. Department of Commerce, May 1993.
    http://www.itl.nist.gov/div897/pubs/fip180-1.htm

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

$Revision: 1.7 $

Since:
Cryptix 2.2.2
Author:
Systemics Ltd, David Hopwood

Nested Class Summary
 
Nested classes inherited from class java.security.MessageDigest
 
Constructor Summary
SHA1()
          Constructs a SHA-1 message digest.
 
Method Summary
protected  long bitcount()
           
 java.lang.Object clone()
          Returns a copy of this MD object.
protected  byte[] engineDigest()
          SPI: Calculates the final digest.
protected  byte[] engineDigest(byte[] in, int length)
          Returns the digest of the data added and resets the digest.
protected  int engineGetDataLength()
          Returns the length of the data (in bytes) hashed in every transform.
protected  int engineGetDigestLength()
          Returns the length of the hash (in bytes).
protected  void engineReset()
          Initializes (resets) the message digest.
protected  void engineTransform(byte[] in)
          Adds data to the message digest.
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.
static void main(java.lang.String[] argv)
          Entry point for self_test.
static void self_test()
          Do some basic tests.
 
Methods inherited from class java.security.MessageDigest
digest, digest, digest, getAlgorithm, getDigestLength, getInstance, getInstance, getInstance, getProvider, isEqual, reset, toString, update, update, update
 
Methods inherited from class java.security.MessageDigestSpi
engineDigest
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SHA1

public SHA1()
Constructs a SHA-1 message digest.

Method Detail

engineGetDigestLength

protected int engineGetDigestLength()
Returns the length of the hash (in bytes).


engineGetDataLength

protected int engineGetDataLength()
Returns the length of the data (in bytes) hashed in every transform.

Specified by:
engineGetDataLength in class BlockMessageDigest

clone

public java.lang.Object clone()
Returns a copy of this MD object.


engineReset

protected void engineReset()
Initializes (resets) the message digest.

Overrides:
engineReset in class BlockMessageDigest

engineTransform

protected void engineTransform(byte[] in)
Adds data to the message digest.

Specified by:
engineTransform in class BlockMessageDigest

engineDigest

protected byte[] engineDigest(byte[] in,
                              int length)
Returns the digest of the data added and resets the digest.

Specified by:
engineDigest in class BlockMessageDigest
Parameters:
in - the last incomplete block.
length - the length in bytes of the last block.
Returns:
the digest of all the data added to the message digest as a byte array.

main

public static final void main(java.lang.String[] argv)
Entry point for self_test.


self_test

public static final void self_test()
                            throws java.lang.Exception
Do some basic tests. Three of the known/validation data are included only, no output, success or exception. If you want more, write a test program!

Throws:
java.lang.Exception
See Also:
TestSHA1

bitcount

protected long bitcount()
Returns:
number of bits hashed so far?

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.

engineDigest

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

Returns:
the digest as a byte array.