org.bouncycastle.crypto.digests
Class WhirlpoolDigest

java.lang.Object
  extended by org.bouncycastle.crypto.digests.WhirlpoolDigest
All Implemented Interfaces:
Digest, ExtendedDigest

public final class WhirlpoolDigest
extends java.lang.Object
implements ExtendedDigest

Implementation of WhirlpoolDigest, based on Java source published by Barreto and Rijmen.


Field Summary
private  short[] _bitCount
           
private  long[] _block
           
private  byte[] _buffer
           
private  int _bufferPos
           
private  long[] _hash
           
private  long[] _K
           
private  long[] _L
           
private  long[] _rc
           
private  long[] _state
           
private static int BITCOUNT_ARRAY_SIZE
           
private static int BYTE_LENGTH
           
private static long[] C0
           
private static long[] C1
           
private static long[] C2
           
private static long[] C3
           
private static long[] C4
           
private static long[] C5
           
private static long[] C6
           
private static long[] C7
           
private static int DIGEST_LENGTH_BYTES
           
private static short[] EIGHT
           
private static int REDUCTION_POLYNOMIAL
           
private static int ROUNDS
           
private static int[] SBOX
           
 
Constructor Summary
WhirlpoolDigest()
           
WhirlpoolDigest(WhirlpoolDigest originalDigest)
          Copy constructor.
 
Method Summary
private  long bytesToLongFromBuffer(byte[] buffer, int startPos)
           
private  void convertLongToByteArray(long inputLong, byte[] outputArray, int offSet)
           
private  byte[] copyBitLength()
           
 int doFinal(byte[] out, int outOff)
          close the digest, producing the final digest value.
private  void finish()
           
 java.lang.String getAlgorithmName()
          return the algorithm name
 int getByteLength()
          Return the size in bytes of the internal buffer the digest applies it's compression function to.
 int getDigestSize()
          return the size, in bytes, of the digest produced by this message digest.
private  void increment()
           
private  int maskWithReductionPolynomial(int input)
           
private  long packIntoLong(int b7, int b6, int b5, int b4, int b3, int b2, int b1, int b0)
           
protected  void processBlock()
           
private  void processFilledBuffer(byte[] in, int inOff)
           
 void reset()
          reset the chaining variables
 void update(byte in)
          update the message digest with a single byte.
 void update(byte[] in, int inOff, int len)
          update the message digest with a block of bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BYTE_LENGTH

private static final int BYTE_LENGTH
See Also:
Constant Field Values

DIGEST_LENGTH_BYTES

private static final int DIGEST_LENGTH_BYTES
See Also:
Constant Field Values

ROUNDS

private static final int ROUNDS
See Also:
Constant Field Values

REDUCTION_POLYNOMIAL

private static final int REDUCTION_POLYNOMIAL
See Also:
Constant Field Values

SBOX

private static final int[] SBOX

C0

private static final long[] C0

C1

private static final long[] C1

C2

private static final long[] C2

C3

private static final long[] C3

C4

private static final long[] C4

C5

private static final long[] C5

C6

private static final long[] C6

C7

private static final long[] C7

_rc

private final long[] _rc

BITCOUNT_ARRAY_SIZE

private static final int BITCOUNT_ARRAY_SIZE
See Also:
Constant Field Values

_buffer

private byte[] _buffer

_bufferPos

private int _bufferPos

_bitCount

private short[] _bitCount

_hash

private long[] _hash

_K

private long[] _K

_L

private long[] _L

_block

private long[] _block

_state

private long[] _state

EIGHT

private static final short[] EIGHT
Constructor Detail

WhirlpoolDigest

public WhirlpoolDigest()

WhirlpoolDigest

public WhirlpoolDigest(WhirlpoolDigest originalDigest)
Copy constructor. This will copy the state of the provided message digest.

Method Detail

packIntoLong

private long packIntoLong(int b7,
                          int b6,
                          int b5,
                          int b4,
                          int b3,
                          int b2,
                          int b1,
                          int b0)

maskWithReductionPolynomial

private int maskWithReductionPolynomial(int input)

getAlgorithmName

public java.lang.String getAlgorithmName()
Description copied from interface: Digest
return the algorithm name

Specified by:
getAlgorithmName in interface Digest
Returns:
the algorithm name

getDigestSize

public int getDigestSize()
Description copied from interface: Digest
return the size, in bytes, of the digest produced by this message digest.

Specified by:
getDigestSize in interface Digest
Returns:
the size, in bytes, of the digest produced by this message digest.

doFinal

public int doFinal(byte[] out,
                   int outOff)
Description copied from interface: Digest
close the digest, producing the final digest value. The doFinal call leaves the digest reset.

Specified by:
doFinal in interface Digest
Parameters:
out - the array the digest is to be copied into.
outOff - the offset into the out array the digest is to start at.

reset

public void reset()
reset the chaining variables

Specified by:
reset in interface Digest

processFilledBuffer

private void processFilledBuffer(byte[] in,
                                 int inOff)

bytesToLongFromBuffer

private long bytesToLongFromBuffer(byte[] buffer,
                                   int startPos)

convertLongToByteArray

private void convertLongToByteArray(long inputLong,
                                    byte[] outputArray,
                                    int offSet)

processBlock

protected void processBlock()

update

public void update(byte in)
Description copied from interface: Digest
update the message digest with a single byte.

Specified by:
update in interface Digest
Parameters:
in - the input byte to be entered.

increment

private void increment()

update

public void update(byte[] in,
                   int inOff,
                   int len)
Description copied from interface: Digest
update the message digest with a block of bytes.

Specified by:
update in interface Digest
Parameters:
in - the byte array containing the data.
inOff - the offset into the byte array where the data starts.
len - the length of the data.

finish

private void finish()

copyBitLength

private byte[] copyBitLength()

getByteLength

public int getByteLength()
Description copied from interface: ExtendedDigest
Return the size in bytes of the internal buffer the digest applies it's compression function to.

Specified by:
getByteLength in interface ExtendedDigest
Returns:
byte length of the digests internal buffer.