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

Quick Search    Search Deep

cryptix.jce.provider.md
Class PaddingMD  view PaddingMD download PaddingMD.java

java.lang.Object
  extended byjava.security.MessageDigestSpi
      extended bycryptix.jce.provider.md.PaddingMD
Direct Known Subclasses:
MD4, MD5, RIPEMD, RIPEMD128, RIPEMD160, SHA, SHA256, SHA512Base, Tiger

abstract class PaddingMD
extends java.security.MessageDigestSpi

This abstract class implements the MD4-like block/padding structure as it is used by most hashes (MD4, MD5, SHA-0, SHA-1, RIPEMD-128, RIPEMD-160, Tiger). This class handles the message buffering, bit counting and padding. Subclasses need implement only the three abstract functions to create a working hash. This class has three padding modes: MD5-like, SHA-like and Tiger-like. This applies to the padding and encoding of the 64-bit length counter.

Version:
$Revision: 1.8 $

Field Summary
private  int blockSize
          Size (in bytes) of the blocks.
private  byte[] buf
          64 byte buffer
private  int bufOff
          Buffer offset
private  long byteCount
          Number of bytes hashed 'till now.
private static int DEFAULT_BLOCKSIZE
           
private  int hashSize
          Size (in bytes) of the digest
private  int mode
          Mode
(package private) static int MODE_MD
           
(package private) static int MODE_SHA
           
(package private) static int MODE_TIGER
           
 
Constructor Summary
protected PaddingMD(int hashSize, int mode)
          Construct a 64-byte PaddingMD in MD-like, SHA-like or Tiger-like padding mode.
protected PaddingMD(int blockSize, int hashSize, int mode)
          Construct a 64 or 128-byte PaddingMD in MD-like, SHA-like or Tiger-like padding mode.
protected PaddingMD(PaddingMD src)
           
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this class.
protected abstract  void coreDigest(byte[] buf, int off)
          Return the hash bytes in buf, starting at offset off.
protected abstract  void coreReset()
          Reset the hash internal structures to initial state.
protected abstract  void coreUpdate(byte[] buf, int off)
          Update the internal state with a single block.
protected  byte[] engineDigest()
          Computes the final digest of the stored bytes and returns them.
protected  int engineDigest(byte[] buf, int offset, int len)
          Computes the final digest of the stored bytes and returns them.
protected  int engineGetDigestLength()
          Returns the length of the digest.
protected  void engineReset()
          Resets the digest engine.
protected  void engineUpdate(byte input)
          Updates the digest with the specified byte.
protected  void engineUpdate(byte[] input, int offset, int length)
          Updates the digest with the specified bytes starting with the offset and proceeding for the specified length.
private  int privateDigest(byte[] buf, int offset, int len)
          Same as protected int engineDigest(byte[] buf, int offset, int len) except that we don't validate arguments.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BLOCKSIZE

private static final int DEFAULT_BLOCKSIZE
See Also:
Constant Field Values

blockSize

private final int blockSize
Size (in bytes) of the blocks.


hashSize

private final int hashSize
Size (in bytes) of the digest


buf

private final byte[] buf
64 byte buffer


bufOff

private int bufOff
Buffer offset


byteCount

private long byteCount
Number of bytes hashed 'till now.


mode

private final int mode
Mode


MODE_MD

static final int MODE_MD
See Also:
Constant Field Values

MODE_SHA

static final int MODE_SHA
See Also:
Constant Field Values

MODE_TIGER

static final int MODE_TIGER
See Also:
Constant Field Values
Constructor Detail

PaddingMD

protected PaddingMD(int hashSize,
                    int mode)
Construct a 64-byte PaddingMD in MD-like, SHA-like or Tiger-like padding mode. The subclass must call this constructor, giving the length of it's hash in bytes.


PaddingMD

protected PaddingMD(int blockSize,
                    int hashSize,
                    int mode)
Construct a 64 or 128-byte PaddingMD in MD-like, SHA-like or Tiger-like padding mode.


PaddingMD

protected PaddingMD(PaddingMD src)
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Description copied from class: java.security.MessageDigestSpi
Returns a clone of this class. If cloning is not supported, then by default the class throws a CloneNotSupportedException. The MessageDigestSpi provider implementation has to overload this class in order to be cloneable.


engineGetDigestLength

protected int engineGetDigestLength()
Description copied from class: java.security.MessageDigestSpi
Returns the length of the digest. It may be overridden by the provider to return the length of the digest. Default is to return 0. It is concrete for backwards compatibility with JDK1.1 message digest classes.


engineUpdate

protected void engineUpdate(byte input)
Description copied from class: java.security.MessageDigestSpi
Updates the digest with the specified byte.


engineUpdate

protected void engineUpdate(byte[] input,
                            int offset,
                            int length)
Description copied from class: java.security.MessageDigestSpi
Updates the digest with the specified bytes starting with the offset and proceeding for the specified length.


engineDigest

protected byte[] engineDigest()
Description copied from class: java.security.MessageDigestSpi
Computes the final digest of the stored bytes and returns them. It performs any necessary padding. The message digest should reset sensitive data after performing the digest.


engineDigest

protected int engineDigest(byte[] buf,
                           int offset,
                           int len)
                    throws java.security.DigestException
Description copied from class: java.security.MessageDigestSpi
Computes the final digest of the stored bytes and returns them. It performs any necessary padding. The message digest should reset sensitive data after performing the digest. This method is left concrete for backwards compatibility with JDK1.1 message digest classes.


privateDigest

private int privateDigest(byte[] buf,
                          int offset,
                          int len)
Same as protected int engineDigest(byte[] buf, int offset, int len) except that we don't validate arguments.


engineReset

protected void engineReset()
Description copied from class: java.security.MessageDigestSpi
Resets the digest engine. Reinitializes internal variables and clears sensitive data.


coreDigest

protected abstract void coreDigest(byte[] buf,
                                   int off)
Return the hash bytes in buf, starting at offset off. The subclass is expected to write exactly hashSize bytes in the given buffer. The buffer is guaranteed to be large enough.


coreReset

protected abstract void coreReset()
Reset the hash internal structures to initial state.


coreUpdate

protected abstract void coreUpdate(byte[] buf,
                                   int off)
Update the internal state with a single block. buf contains a single block (64 bytes, 512 bits) of data, starting at offset off.