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

Quick Search    Search Deep

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

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

public final class Whirlpool
extends BaseHash

Whirlpool, a new 512-bit hashing function operating on messages less than 2 ** 256 bits in length. The function structure is designed according to the Wide Trail strategy and permits a wide variety of implementation trade-offs.

This implementation is of Whirlpool Version 3, described in [1] last revised on May 24th, 2003.

IMPORTANT: This implementation is not thread-safe.

References:

  1. The WHIRLPOOL Hashing Function.
    Paulo S.L.M. Barreto and Vincent Rijmen.


Field Summary
private static int BLOCK_SIZE
           
private static boolean DEBUG
           
private static int debuglevel
           
private static java.lang.String DIGEST0
          The digest of the 0-bit long message.
private  long H0
          The 512-bit context as 8 longs.
private  long H1
          The 512-bit context as 8 longs.
private  long H2
          The 512-bit context as 8 longs.
private  long H3
          The 512-bit context as 8 longs.
private  long H4
          The 512-bit context as 8 longs.
private  long H5
          The 512-bit context as 8 longs.
private  long H6
          The 512-bit context as 8 longs.
private  long H7
          The 512-bit context as 8 longs.
private  long k00
          Work area for computing the round key schedule.
private  long k01
          Work area for computing the round key schedule.
private  long k02
          Work area for computing the round key schedule.
private  long k03
          Work area for computing the round key schedule.
private  long k04
          Work area for computing the round key schedule.
private  long k05
          Work area for computing the round key schedule.
private  long k06
          Work area for computing the round key schedule.
private  long k07
          Work area for computing the round key schedule.
private  long Kr0
           
private  long Kr1
           
private  long Kr2
           
private  long Kr3
           
private  long Kr4
           
private  long Kr5
           
private  long Kr6
           
private  long Kr7
           
private  long n0
          work area for transforming the 512-bit buffer.
private  long n1
          work area for transforming the 512-bit buffer.
private  long n2
          work area for transforming the 512-bit buffer.
private  long n3
          work area for transforming the 512-bit buffer.
private  long n4
          work area for transforming the 512-bit buffer.
private  long n5
          work area for transforming the 512-bit buffer.
private  long n6
          work area for transforming the 512-bit buffer.
private  long n7
          work area for transforming the 512-bit buffer.
private  long nn0
           
private  long nn1
           
private  long nn2
           
private  long nn3
           
private  long nn4
           
private  long nn5
           
private  long nn6
           
private  long nn7
           
private static int R
          Default number of rounds.
private static long[] rc
          The round constants.
private static java.lang.String S_box
          Whirlpool S-box; p.
private static long[] T0
          The 64-bit lookup tables; section 7.1 p.
private static long[] T1
           
private static long[] T2
           
private static long[] T3
           
private static long[] T4
           
private static long[] T5
           
private static long[] T6
           
private static long[] T7
           
private static java.lang.Boolean valid
          caches the result of the correctness test, once executed.
private  long w0
          work area for holding block cipher's intermediate values.
private  long w1
          work area for holding block cipher's intermediate values.
private  long w2
          work area for holding block cipher's intermediate values.
private  long w3
          work area for holding block cipher's intermediate values.
private  long w4
          work area for holding block cipher's intermediate values.
private  long w5
          work area for holding block cipher's intermediate values.
private  long w6
          work area for holding block cipher's intermediate values.
private  long w7
          work area for holding block cipher's intermediate values.
 
Fields inherited from class gnu.java.security.hash.BaseHash
blockSize, buffer, count, hashSize, name
 
Constructor Summary
  Whirlpool()
          Trivial 0-arguments constructor.
private Whirlpool(Whirlpool md)
          Private constructor for cloning purposes.
 
Method Summary
 java.lang.Object clone()
          Returns a clone copy of this instance.
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.
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

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

debuglevel

private static final int debuglevel
See Also:
Constant Field Values

BLOCK_SIZE

private static final int BLOCK_SIZE
See Also:
Constant Field Values

DIGEST0

private static final java.lang.String DIGEST0
The digest of the 0-bit long message.

See Also:
Constant Field Values

R

private static final int R
Default number of rounds.

See Also:
Constant Field Values

S_box

private static final java.lang.String S_box
Whirlpool S-box; p. 19.

See Also:
Constant Field Values

T0

private static final long[] T0
The 64-bit lookup tables; section 7.1 p. 13.


T1

private static final long[] T1

T2

private static final long[] T2

T3

private static final long[] T3

T4

private static final long[] T4

T5

private static final long[] T5

T6

private static final long[] T6

T7

private static final long[] T7

rc

private static final long[] rc
The round constants.


valid

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


H0

private long H0
The 512-bit context as 8 longs.


H1

private long H1
The 512-bit context as 8 longs.


H2

private long H2
The 512-bit context as 8 longs.


H3

private long H3
The 512-bit context as 8 longs.


H4

private long H4
The 512-bit context as 8 longs.


H5

private long H5
The 512-bit context as 8 longs.


H6

private long H6
The 512-bit context as 8 longs.


H7

private long H7
The 512-bit context as 8 longs.


k00

private long k00
Work area for computing the round key schedule.


k01

private long k01
Work area for computing the round key schedule.


k02

private long k02
Work area for computing the round key schedule.


k03

private long k03
Work area for computing the round key schedule.


k04

private long k04
Work area for computing the round key schedule.


k05

private long k05
Work area for computing the round key schedule.


k06

private long k06
Work area for computing the round key schedule.


k07

private long k07
Work area for computing the round key schedule.


Kr0

private long Kr0

Kr1

private long Kr1

Kr2

private long Kr2

Kr3

private long Kr3

Kr4

private long Kr4

Kr5

private long Kr5

Kr6

private long Kr6

Kr7

private long Kr7

n0

private long n0
work area for transforming the 512-bit buffer.


n1

private long n1
work area for transforming the 512-bit buffer.


n2

private long n2
work area for transforming the 512-bit buffer.


n3

private long n3
work area for transforming the 512-bit buffer.


n4

private long n4
work area for transforming the 512-bit buffer.


n5

private long n5
work area for transforming the 512-bit buffer.


n6

private long n6
work area for transforming the 512-bit buffer.


n7

private long n7
work area for transforming the 512-bit buffer.


nn0

private long nn0

nn1

private long nn1

nn2

private long nn2

nn3

private long nn3

nn4

private long nn4

nn5

private long nn5

nn6

private long nn6

nn7

private long nn7

w0

private long w0
work area for holding block cipher's intermediate values.


w1

private long w1
work area for holding block cipher's intermediate values.


w2

private long w2
work area for holding block cipher's intermediate values.


w3

private long w3
work area for holding block cipher's intermediate values.


w4

private long w4
work area for holding block cipher's intermediate values.


w5

private long w5
work area for holding block cipher's intermediate values.


w6

private long w6
work area for holding block cipher's intermediate values.


w7

private long w7
work area for holding block cipher's intermediate values.

Constructor Detail

Whirlpool

public Whirlpool()
Trivial 0-arguments constructor.


Whirlpool

private Whirlpool(Whirlpool md)

Private constructor for cloning purposes.

Method Detail

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