org.clazzes.optional.sec
Class SHA256Digest

java.lang.Object
  extended by org.clazzes.optional.sec.GeneralDigest
      extended by org.clazzes.optional.sec.SHA256Digest
All Implemented Interfaces:
Digest

public class SHA256Digest
extends GeneralDigest

FIPS 180-2 implementation of SHA-256. This class has been copied from bouncycastle.


Field Summary
static int DIGEST_LENGTH
           
 
Constructor Summary
SHA256Digest()
          Standard constructor
SHA256Digest(SHA256Digest t)
          Copy constructor.
 
Method Summary
 Digest cloneState()
           
 int doFinal(byte[] out, int outOff)
          Retrieve the hash of all data added so far with Digest.update(byte[], int, int).
 java.lang.String getAlgorithmName()
           
 int getDigestSize()
           
protected  void processBlock()
           
protected  void processLength(long bitLength)
           
protected  void processWord(byte[] in, int inOff)
           
 void reset()
          reset the chaining variables
 
Methods inherited from class org.clazzes.optional.sec.GeneralDigest
finish, getByteLength, update, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIGEST_LENGTH

public static final int DIGEST_LENGTH
See Also:
Constant Field Values
Constructor Detail

SHA256Digest

public SHA256Digest()
Standard constructor


SHA256Digest

public SHA256Digest(SHA256Digest t)
Copy constructor. This will copy the state of the provided message digest.

Method Detail

cloneState

public Digest cloneState()
Returns:
A new digest in identical state. This is used, when you want to calculate an intermediate digest value and continue afterward with adding more content.

getAlgorithmName

public java.lang.String getAlgorithmName()
Returns:
The name of the digest algorithm.

getDigestSize

public int getDigestSize()
Returns:
The size of computed hashes.

processWord

protected void processWord(byte[] in,
                           int inOff)
Specified by:
processWord in class GeneralDigest

processLength

protected void processLength(long bitLength)
Specified by:
processLength in class GeneralDigest

doFinal

public int doFinal(byte[] out,
                   int outOff)
Description copied from interface: Digest
Retrieve the hash of all data added so far with Digest.update(byte[], int, int).

Parameters:
out - The buffer, where the computed hash will be stored. Digest.getDigestSize() bytes starting at off will be written to hash.
outOff - The offset at which the hash is stored.
Returns:
The number of bytes written, which is equal to Digest.getDigestSize().

reset

public void reset()
reset the chaining variables

Specified by:
reset in interface Digest
Overrides:
reset in class GeneralDigest

processBlock

protected void processBlock()
Specified by:
processBlock in class GeneralDigest


Copyright © 2010. All Rights Reserved.