private byte[] updateMac(KeccakDigest mac, byte[] seed, int offset, byte[] out, int outOffset, boolean egress) throws IOException { byte[] aesBlock = new byte[mac.getDigestSize()]; doSum(mac, aesBlock); makeMacCipher().processBlock(aesBlock, 0, aesBlock, 0); // Note that although the mac digest size is 32 bytes, we only use 16 bytes in the computation int length = 16; for (int i = 0; i < length; i++) { aesBlock[i] ^= seed[i + offset]; } mac.update(aesBlock, 0, length); byte[] result = new byte[mac.getDigestSize()]; doSum(mac, result); if (egress) { System.arraycopy(result, 0, out, outOffset, length); } else { for (int i = 0; i < length; i++) { if (out[i + outOffset] != result[i]) { throw new IOException("MAC mismatch"); } } } return result; }
byte[] macBuffer = new byte[egressMac.getDigestSize()];
InputStream payload = new ByteArrayInputStream(buffer, pos, totalBodySize - pos); int size = totalBodySize - pos; byte[] macBuffer = new byte[ingressMac.getDigestSize()];
public int doFinal(byte[] out, int outOff) { squeeze(out, outOff, fixedOutputLength); reset(); return getDigestSize(); }
protected int doFinal(byte[] out, int outOff, byte partialByte, int partialBits) { if (partialBits > 0) { absorbBits(partialByte, partialBits); } squeeze(out, outOff, fixedOutputLength); reset(); return getDigestSize(); }