1
package org.bouncycastle.crypto.digests;
3
import org.bouncycastle.crypto.ExtendedDigest;
6
* base implementation of MD4 family style digest as outlined in
7
* "Handbook of Applied Cryptography", pages 344 - 347.
9
public abstract class GeneralDigest
10
implements ExtendedDigest
12
private static final int BYTE_LENGTH = 64;
16
private long byteCount;
19
* Standard constructor
21
protected GeneralDigest()
28
* Copy constructor. We are using copy constructors in place
29
* of the Object.clone() interface as this interface is not
32
protected GeneralDigest(GeneralDigest t)
34
xBuf = new byte[t.xBuf.length];
35
System.arraycopy(t.xBuf, 0, xBuf, 0, t.xBuf.length);
38
byteCount = t.byteCount;
46
if (xBufOff == xBuf.length)
61
// fill the current word
63
while ((xBufOff != 0) && (len > 0))
72
// process whole words.
74
while (len > xBuf.length)
76
processWord(in, inOff);
80
byteCount += xBuf.length;
84
// load in the remainder.
97
long bitLength = (byteCount << 3);
100
// add the pad bytes.
109
processLength(bitLength);
119
for (int i = 0; i < xBuf.length; i++)
125
public int getByteLength()
130
protected abstract void processWord(byte[] in, int inOff);
132
protected abstract void processLength(long bitLength);
134
protected abstract void processBlock();