is.logi.crypto.hash
Class HashState

java.lang.Object
  |
  +--is.logi.crypto.Crypto
        |
        +--is.logi.crypto.hash.HashState
Direct Known Subclasses:
MD5State, SHA1State

public abstract class HashState
extends Crypto

An object of this class holds the status of a fingerprint still being calculated.

A fingerprint state object can be repeatedly updated with data. At any time a Fingerprint object can be requested for the data that has then been added to the fingerprint state.

Author:
Logi Ragnarsson (logir@hi.is)
See Also:
SHA1State, Fingerprint, Signature

Fields inherited from class is.logi.crypto.Crypto
BIT, cdsPath, keySource, NIBBLE, primeCertainty, random
 
Constructor Summary
HashState()
           
 
Method Summary
abstract  int blockSize()
          Return the number of bytes needed to make a valid hash.
abstract  Fingerprint calculate()
          Return a fingerprint for the curret state, without destroying the state.
static HashState create(java.lang.String algorithm)
          Create a HashState object for the named fingerprint algorithm.
abstract  java.lang.String getName()
          Return the name of the algorithm used by this HashState object.
abstract  int hashSize()
          Returns the size of a fingerprint in bytes.
abstract  void reset()
          Reset the state.
 void update(byte[] buf)
          Update the fingerprint state with the bytes from buf.
abstract  void update(byte[] buf, int offset, int length)
          Update the fingerprint state with the bytes from buf[offset, offset+length-1].
 void update(java.lang.String s)
          Update the fingerprint state with the characters from s.
 
Methods inherited from class is.logi.crypto.Crypto
binString, binString, equal, equalRelaxed, equalSub, fromHexNibble, fromHexString, fromString, fromString, hexString, hexString, hexString, hexString, makeClass, makeInt, makeLong, makeSessionKey, pastSpace, pickBits, pickBits, readInt, writeBytes, writeBytes, writeInt
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashState

public HashState()
Method Detail

create

public static HashState create(java.lang.String algorithm)
                        throws InvalidCDSException
Create a HashState object for the named fingerprint algorithm.
Throws:
InvalidCDSException - if a HashState object for the named algorithm could not be created.

getName

public abstract java.lang.String getName()
Return the name of the algorithm used by this HashState object.

reset

public abstract void reset()
Reset the state.

update

public abstract void update(byte[] buf,
                            int offset,
                            int length)
Update the fingerprint state with the bytes from buf[offset, offset+length-1].

update

public void update(byte[] buf)
Update the fingerprint state with the bytes from buf.

update

public void update(java.lang.String s)
Update the fingerprint state with the characters from s.

calculate

public abstract Fingerprint calculate()
Return a fingerprint for the curret state, without destroying the state.

blockSize

public abstract int blockSize()
Return the number of bytes needed to make a valid hash. If a multiple of this number of bytes is hashed, no padding is needed. If no such value exists, returns 0.

hashSize

public abstract int hashSize()
Returns the size of a fingerprint in bytes.


Copyright 1997-1999 Logi Ragnarsson