public void update(byte in) { if (bufOff == buf.length) { processBlock(buf, 0); bufOff = 0; } buf[bufOff++] = in; }
private void processBlock(byte[] in, int inOff) { xor(c, 0, in, inOff, cTemp); engine.processBlock(cTemp, 0, c, 0); }
public int doFinal(byte[] out, int outOff) throws DataLengthException, IllegalStateException { if (bufOff % buf.length != 0) { throw new DataLengthException("input must be a multiple of blocksize"); } //Last block xor(c, 0, buf, 0, cTemp); xor(cTemp, 0, kDelta, 0, c); engine.processBlock(c, 0, c, 0); if (macSize + outOff > out.length) { throw new OutputLengthException("output buffer too short"); } System.arraycopy(c, 0, out, outOff, macSize); return macSize; }
public void update(byte[] in, int inOff, int len) { if (len < 0) { throw new IllegalArgumentException( "can't have a negative input length!"); } int blockSize = engine.getBlockSize(); int gapLen = blockSize - bufOff; if (len > gapLen) { System.arraycopy(in, inOff, buf, bufOff, gapLen); processBlock(buf, 0); bufOff = 0; len -= gapLen; inOff += gapLen; while (len > blockSize) { processBlock(in, inOff); len -= blockSize; inOff += blockSize; } } System.arraycopy(in, inOff, buf, bufOff, len); bufOff += len; }