Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.java.security.hash
Class Sha256  view Sha256 download Sha256.java

java.lang.Object
  extended bygnu.java.security.hash.BaseHash
      extended bygnu.java.security.hash.Sha256
All Implemented Interfaces:
java.lang.Cloneable, IMessageDigest

public class Sha256
extends BaseHash

Implementation of SHA2-1 [SHA-256] per the IETF Draft Specification.

References:

  1. Descriptions of SHA-256, SHA-384, and SHA-512,
  2. http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf


Field Summary
private static int BLOCK_SIZE
           
private static java.lang.String DIGEST0
           
private  int h0
          256-bit interim result.
private  int h1
          256-bit interim result.
private  int h2
          256-bit interim result.
private  int h3
          256-bit interim result.
private  int h4
          256-bit interim result.
private  int h5
          256-bit interim result.
private  int h6
          256-bit interim result.
private  int h7
          256-bit interim result.
private static int[] k
           
private static java.lang.Boolean valid
          caches the result of the correctness test, once executed.
private static int[] w
           
 
Fields inherited from class gnu.java.security.hash.BaseHash
blockSize, buffer, count, hashSize, name
 
Constructor Summary
  Sha256()
          Trivial 0-arguments constructor.
private Sha256(Sha256 md)
          Private constructor for cloning purposes.
 
Method Summary
 java.lang.Object clone()
          Returns a clone copy of this instance.
static int[] G(int hh0, int hh1, int hh2, int hh3, int hh4, int hh5, int hh6, int hh7, byte[] in, int offset)
           
protected  byte[] getResult()
          Constructs the result from the contents of the current context.
protected  byte[] padBuffer()
          Returns the byte array to use as padding before completing a hash operation.
protected  void resetContext()
          Resets the instance for future re-use.
 boolean selfTest()
          A basic test.
private static int[] sha(int hh0, int hh1, int hh2, int hh3, int hh4, int hh5, int hh6, int hh7, byte[] in, int offset)
           
protected  void transform(byte[] in, int offset)
          The block digest transformation per se.
 
Methods inherited from class gnu.java.security.hash.BaseHash
blockSize, digest, hashSize, name, reset, update, update, update
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

k

private static final int[] k

BLOCK_SIZE

private static final int BLOCK_SIZE
See Also:
Constant Field Values

DIGEST0

private static final java.lang.String DIGEST0
See Also:
Constant Field Values

w

private static final int[] w

valid

private static java.lang.Boolean valid
caches the result of the correctness test, once executed.


h0

private int h0
256-bit interim result.


h1

private int h1
256-bit interim result.


h2

private int h2
256-bit interim result.


h3

private int h3
256-bit interim result.


h4

private int h4
256-bit interim result.


h5

private int h5
256-bit interim result.


h6

private int h6
256-bit interim result.


h7

private int h7
256-bit interim result.

Constructor Detail

Sha256

public Sha256()
Trivial 0-arguments constructor.


Sha256

private Sha256(Sha256 md)

Private constructor for cloning purposes.

Method Detail

G

public static final int[] G(int hh0,
                            int hh1,
                            int hh2,
                            int hh3,
                            int hh4,
                            int hh5,
                            int hh6,
                            int hh7,
                            byte[] in,
                            int offset)

clone

public java.lang.Object clone()
Description copied from interface: IMessageDigest

Returns a clone copy of this instance.

Specified by:
clone in interface IMessageDigest
Specified by:
clone in class BaseHash

transform

protected void transform(byte[] in,
                         int offset)
Description copied from class: BaseHash

The block digest transformation per se.

Specified by:
transform in class BaseHash

padBuffer

protected byte[] padBuffer()
Description copied from class: BaseHash

Returns the byte array to use as padding before completing a hash operation.

Specified by:
padBuffer in class BaseHash

getResult

protected byte[] getResult()
Description copied from class: BaseHash

Constructs the result from the contents of the current context.

Specified by:
getResult in class BaseHash

resetContext

protected void resetContext()
Description copied from class: BaseHash
Resets the instance for future re-use.

Specified by:
resetContext in class BaseHash

selfTest

public boolean selfTest()
Description copied from interface: IMessageDigest

A basic test. Ensures that the digest of a pre-determined message is equal to a known pre-computed value.

Specified by:
selfTest in interface IMessageDigest
Specified by:
selfTest in class BaseHash

sha

private static final int[] sha(int hh0,
                               int hh1,
                               int hh2,
                               int hh3,
                               int hh4,
                               int hh5,
                               int hh6,
                               int hh7,
                               byte[] in,
                               int offset)