private void processPartial(byte[] buf, int off, int len, byte[] out, int outOff) { byte[] ctrBlock = new byte[BLOCK_SIZE]; getNextCTRBlock(ctrBlock); if (forEncryption) { GCMUtil.xor(buf, off, ctrBlock, 0, len); gHASHPartial(S, buf, off, len); } else { gHASHPartial(S, buf, off, len); GCMUtil.xor(buf, off, ctrBlock, 0, len); } System.arraycopy(buf, off, out, outOff, len); totalLength += len; }
private void processBlock(byte[] buf, int bufOff, byte[] out, int outOff) { if ((out.length - outOff) < BLOCK_SIZE) { throw new OutputLengthException("Output buffer too short"); } if (totalLength == 0) { initCipher(); } byte[] ctrBlock = new byte[BLOCK_SIZE]; getNextCTRBlock(ctrBlock); if (forEncryption) { GCMUtil.xor(ctrBlock, buf, bufOff); gHASHBlock(S, ctrBlock); System.arraycopy(ctrBlock, 0, out, outOff, BLOCK_SIZE); } else { gHASHBlock(S, buf, bufOff); GCMUtil.xor(ctrBlock, 0, buf, bufOff, out, outOff); } totalLength += BLOCK_SIZE; }