protected AEADBlockCipher createAEADBlockCipher_AES_GCM() { // TODO Consider allowing custom configuration of multiplier return new GCMBlockCipher(createAESEngine()); }
private void outputBlock(byte[] output, int offset) { if (output.length < (offset + BLOCK_SIZE)) { throw new OutputLengthException("Output buffer too short"); } if (totalLength == 0) { initCipher(); } gCTRBlock(bufBlock, output, offset); if (forEncryption) { bufOff = 0; } else { System.arraycopy(bufBlock, BLOCK_SIZE, bufBlock, 0, macSize); bufOff = macSize; } }
public void reset() { cipher.reset(); } }
public void processAADByte(byte in) { checkStatus(); atBlock[atBlockPos] = in; if (++atBlockPos == BLOCK_SIZE) { // Hash each block as it fills gHASHBlock(S_at, atBlock); atBlockPos = 0; atLength += BLOCK_SIZE; } }
public int processByte(byte in, byte[] out, int outOff) throws DataLengthException { checkStatus(); bufBlock[bufOff] = in; if (++bufOff == bufBlock.length) { outputBlock(out, outOff); return BLOCK_SIZE; } return 0; }
public int doFinal(byte[] out, int outOff) throws IllegalStateException, InvalidCipherTextException checkStatus(); initCipher(); gCTRPartial(bufBlock, 0, extra, out, outOff); gHASHPartial(S_at, atBlock, 0, atBlockPos); Pack.longToBigEndian(totalLength * 8, X, 8); gHASHBlock(S, X); reset(false);
gCTRBlock(tmp, extra, out, outOff); packLength((long)A.length * 8, X, 0); packLength(totalLength * 8, X, 8); xor(S, X); multiplier.multiplyH(S); xor(tag, S); reset(false);
multiplier.init(H); this.initS = gHASH(A); this.J0 = gHASH(nonce); byte[] X = new byte[16]; packLength((long)nonce.length * 8, X, 8); xor(this.J0, X); multiplier.multiplyH(this.J0);
gHASH(J0, nonce, nonce.length); byte[] X = new byte[BLOCK_SIZE]; Pack.longToBigEndian((long)nonce.length * 8, X, 8); gHASHBlock(J0, X); processAADBytes(initialAssociatedText, 0, initialAssociatedText.length);
private int process(byte in, byte[] out, int outOff) throws DataLengthException { bufBlock[bufOff++] = in; if (bufOff == bufBlock.length) { gCTRBlock(bufBlock, BLOCK_SIZE, out, outOff); if (!forEncryption) { System.arraycopy(bufBlock, BLOCK_SIZE, bufBlock, 0, macSize); } // bufOff = 0; bufOff = bufBlock.length - BLOCK_SIZE; // return bufBlock.length; return BLOCK_SIZE; } return 0; }
public int doFinal(byte[] out, int outOff) throws DataLengthException, IllegalStateException { try { return cipher.doFinal(out, outOff); } catch (InvalidCipherTextException e) { // Impossible in encrypt mode throw new IllegalStateException(e.toString()); } }
public void processAADBytes(byte[] in, int inOff, int len) { checkStatus(); for (int i = 0; i < len; ++i) { atBlock[atBlockPos] = in[inOff + i]; if (++atBlockPos == BLOCK_SIZE) { // Hash each block as it fills gHASHBlock(S_at, atBlock); atBlockPos = 0; atLength += BLOCK_SIZE; } } }
public int processBytes(byte[] in, int inOff, int len, byte[] out, int outOff) throws DataLengthException { checkStatus(); if (in.length < (inOff + len)) { throw new DataLengthException("Input buffer too short"); } int resultLen = 0; for (int i = 0; i < len; ++i) { bufBlock[bufOff] = in[inOff + i]; if (++bufOff == bufBlock.length) { outputBlock(out, outOff + resultLen); resultLen += BLOCK_SIZE; } } return resultLen; }
public int processBytes(byte[] in, int inOff, int len, byte[] out, int outOff) throws DataLengthException { int resultLen = 0; for (int i = 0; i != len; i++) { // resultLen += process(in[inOff + i], out, outOff + resultLen); bufBlock[bufOff++] = in[inOff + i]; if (bufOff == bufBlock.length) { gCTRBlock(bufBlock, BLOCK_SIZE, out, outOff + resultLen); if (!forEncryption) { System.arraycopy(bufBlock, BLOCK_SIZE, bufBlock, 0, macSize); } // bufOff = 0; bufOff = bufBlock.length - BLOCK_SIZE; // return bufBlock.Length; resultLen += BLOCK_SIZE; } } return resultLen; }
protected AEADBlockCipher createAEADBlockCipher_Camellia_GCM() { // TODO Consider allowing custom configuration of multiplier return new GCMBlockCipher(createCamelliaEngine()); }
public void reset() { reset(true); }
protected AEADBlockCipher createAEADBlockCipher_AES_GCM() { // TODO Consider allowing custom configuration of multiplier return new GCMBlockCipher(createAESEngine()); }
public void reset() { reset(true); }
protected AEADBlockCipher createAEADBlockCipher_ARIA_GCM() { // TODO Consider allowing custom configuration of multiplier return new GCMBlockCipher(createARIAEngine()); }
protected AEADBlockCipher createAEADBlockCipher_Camellia_GCM() { // TODO Consider allowing custom configuration of multiplier return new GCMBlockCipher(createCamelliaEngine()); }