org.bouncycastle.crypto.digests
abstract public class: GeneralDigest [javadoc |
source]
java.lang.Object
org.bouncycastle.crypto.digests.GeneralDigest
All Implemented Interfaces:
Digest
Direct Known Subclasses:
SHA224Digest, RIPEMD256Digest, MD5Digest, MD4Digest, RIPEMD160Digest, SHA1Digest, SHA256Digest, RIPEMD320Digest, RIPEMD128Digest
base implementation of MD4 family style digest as outlined in
"Handbook of Applied Cryptography", pages 344 - 347.
Method from org.bouncycastle.crypto.digests.GeneralDigest Detail: |
public void finish() {
long bitLength = (byteCount < < 3);
//
// add the pad bytes.
//
update((byte)128);
while (xBufOff != 0)
{
update((byte)0);
}
processLength(bitLength);
processBlock();
}
|
abstract protected void processBlock()
|
abstract protected void processLength(long bitLength)
|
abstract protected void processWord(byte[] in,
int inOff)
|
public void reset() {
byteCount = 0;
xBufOff = 0;
for ( int i = 0; i < xBuf.length; i++ ) {
xBuf[i] = 0;
}
}
|
public void update(byte in) {
xBuf[xBufOff++] = in;
if (xBufOff == xBuf.length)
{
processWord(xBuf, 0);
xBufOff = 0;
}
byteCount++;
}
|
public void update(byte[] in,
int inOff,
int len) {
//
// fill the current word
//
while ((xBufOff != 0) && (len > 0))
{
update(in[inOff]);
inOff++;
len--;
}
//
// process whole words.
//
while (len > xBuf.length)
{
processWord(in, inOff);
inOff += xBuf.length;
len -= xBuf.length;
byteCount += xBuf.length;
}
//
// load in the remainder.
//
while (len > 0)
{
update(in[inOff]);
inOff++;
len--;
}
}
|