protected byte[] getLSub(int n) { while (n >= L.size()) { L.addElement(OCB_double((byte[])L.lastElement())); } return (byte[])L.elementAt(n); }
protected void processHashBlock() { /* * HASH: Process any whole blocks */ updateHASH(getLSub(OCB_ntz(++hashBlockCount))); hashBlockPos = 0; }
protected void reset(boolean clearMac) { hashCipher.reset(); mainCipher.reset(); clear(hashBlock); clear(mainBlock); hashBlockPos = 0; mainBlockPos = 0; hashBlockCount = 0; mainBlockCount = 0; clear(OffsetHASH); clear(Sum); System.arraycopy(OffsetMAIN_0, 0, OffsetMAIN, 0, 16); clear(Checksum); if (clearMac) { macBlock = null; } if (initialAssociatedText != null) { processAADBytes(initialAssociatedText, 0, initialAssociatedText.length); } }
protected AEADBlockCipher createAEADBlockCipher_AES_OCB() { return new OCBBlockCipher(createAESEngine(), createAESEngine()); }
OCB_extend(hashBlock, hashBlockPos); updateHASH(L_Asterisk); OCB_extend(mainBlock, mainBlockPos); xor(Checksum, mainBlock); xor(OffsetMAIN, L_Asterisk); xor(mainBlock, Pad); OCB_extend(mainBlock, mainBlockPos); xor(Checksum, mainBlock); xor(Checksum, OffsetMAIN); xor(Checksum, L_Dollar); hashCipher.processBlock(Checksum, 0, Checksum, 0); xor(Checksum, Sum); reset(false);
protected void processMainBlock(byte[] output, int outOff) { if (output.length < (outOff + BLOCK_SIZE)) { throw new OutputLengthException("Output buffer too short"); } /* * OCB-ENCRYPT/OCB-DECRYPT: Process any whole blocks */ if (forEncryption) { xor(Checksum, mainBlock); mainBlockPos = 0; } xor(OffsetMAIN, getLSub(OCB_ntz(++mainBlockCount))); xor(mainBlock, OffsetMAIN); mainCipher.processBlock(mainBlock, 0, mainBlock, 0); xor(mainBlock, OffsetMAIN); System.arraycopy(mainBlock, 0, output, outOff, 16); if (!forEncryption) { xor(Checksum, mainBlock); System.arraycopy(mainBlock, BLOCK_SIZE, mainBlock, 0, macSize); mainBlockPos = macSize; } }
hashCipher.processBlock(L_Asterisk, 0, L_Asterisk, 0); this.L_Dollar = OCB_double(L_Asterisk); this.L.addElement(OCB_double(L_Dollar)); int bottom = processNonce(N); processAADBytes(initialAssociatedText, 0, initialAssociatedText.length);
public void processAADByte(byte input) { hashBlock[hashBlockPos] = input; if (++hashBlockPos == hashBlock.length) { processHashBlock(); } }
public int processByte(byte input, byte[] output, int outOff) throws DataLengthException { mainBlock[mainBlockPos] = input; if (++mainBlockPos == mainBlock.length) { processMainBlock(output, outOff); return BLOCK_SIZE; } return 0; }
protected AEADBlockCipher createAEADBlockCipher_AES_OCB() { return new OCBBlockCipher(createAESEngine(), createAESEngine()); }
public void processAADBytes(byte[] input, int off, int len) { for (int i = 0; i < len; ++i) { hashBlock[hashBlockPos] = input[off + i]; if (++hashBlockPos == hashBlock.length) { processHashBlock(); } } }
public int processBytes(byte[] input, int inOff, int len, byte[] output, int outOff) throws DataLengthException { if (input.length < (inOff + len)) { throw new DataLengthException("Input buffer too short"); } int resultLen = 0; for (int i = 0; i < len; ++i) { mainBlock[mainBlockPos] = input[inOff + i]; if (++mainBlockPos == mainBlock.length) { processMainBlock(output, outOff + resultLen); resultLen += BLOCK_SIZE; } } return resultLen; }
cipher = new AEADGenericBlockCipher(new OCBBlockCipher(baseEngine, engineProvider.get()));