gnu.crypto.hash

Class MD2

Implemented Interfaces:
Cloneable, IMessageDigest

public class MD2
extends BaseHash

An implementation of the MD2 message digest algorithm.

MD2 is not widely used. Unless it is needed for compatibility with existing systems, it is not recommended for use in new applications.

References:

  1. The MD2 Message-Digest Algorithm.
    B. Kaliski.
  2. The RFC ERRATA PAGE under section RFC 1319.

Version:
$Revision: 1.5 $

Field Summary

Fields inherited from class gnu.crypto.hash.BaseHash

blockSize, buffer, count, hashSize, name

Constructor Summary

MD2()
Creates a new MD2 digest ready for use.

Method Summary

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()
Generates an array of padding bytes.
protected void
resetContext()
Resets the instance for future re-use.
boolean
selfTest()
A basic test.
protected void
transform(byte[] in, int off)
Adds BLOCK_LENGTH bytes to the running digest.

Methods inherited from class gnu.crypto.hash.BaseHash

blockSize, clone, digest, getResult, hashSize, name, padBuffer, reset, resetContext, selfTest, transform, update, update

Constructor Details

MD2

public MD2()
Creates a new MD2 digest ready for use.

Method Details

clone

public Object clone()
Returns a clone copy of this instance.
Specified by:
clone in interface IMessageDigest
Overrides:
clone in interface BaseHash

Returns:
a clone copy of this instance.


getResult

protected byte[] getResult()
Constructs the result from the contents of the current context.
Overrides:
getResult in interface BaseHash

Returns:
the output of the completed hash operation.


padBuffer

protected byte[] padBuffer()
Generates an array of padding bytes. The padding is defined as i bytes of value i, where i is the number of bytes to fill the last block of the message to BLOCK_LENGTH bytes (or BLOCK_LENGTH bytes when the last block was completely full).
Overrides:
padBuffer in interface BaseHash

Returns:
the bytes to pad the remaining bytes in the buffer before completing a hash operation.


resetContext

protected void resetContext()
Resets the instance for future re-use.
Overrides:
resetContext in interface BaseHash


selfTest

public boolean selfTest()
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
Overrides:
selfTest in interface BaseHash

Returns:
true if the implementation passes a basic self-test. Returns false otherwise.


transform

protected void transform(byte[] in,
                         int off)
Adds BLOCK_LENGTH bytes to the running digest.
Overrides:
transform in interface BaseHash

Parameters:
in - the byte array to take the BLOCK_LENGTH bytes from.
off - the offset to start from in the given byte array.


Copyright © 2001, 2002, 2003 Free Software Foundation, Inc. All Rights Reserved.