1 package org.bouncycastle.crypto.digests;
3 import org.bouncycastle.crypto.Digest;
6 * base implementation of MD4 family style digest as outlined in
7 * "Handbook of Applied Cryptography", pages 344 - 347.
9 public abstract class GeneralDigest
15 private long byteCount;
18 * Standard constructor
20 protected GeneralDigest()
27 * Copy constructor. We are using copy constructors in place
28 * of the Object.clone() interface as this interface is not
31 protected GeneralDigest(GeneralDigest t)
33 xBuf = new byte[t.xBuf.length];
34 System.arraycopy(t.xBuf, 0, xBuf, 0, t.xBuf.length);
37 byteCount = t.byteCount;
45 if (xBufOff == xBuf.length)
60 // fill the current word
62 while ((xBufOff != 0) && (len > 0))
71 // process whole words.
73 while (len > xBuf.length)
75 processWord(in, inOff);
79 byteCount += xBuf.length;
83 // load in the remainder.
96 long bitLength = (byteCount << 3);
108 processLength(bitLength);
118 for ( int i = 0; i < xBuf.length; i++ ) {
123 protected abstract void processWord(byte[] in, int inOff);
125 protected abstract void processLength(long bitLength);
127 protected abstract void processBlock();