public CCM256() { super(new KCCMBlockCipher(new DSTU7624Engine(256))); } }
public int doFinal(byte[] out, int outOff) throws IllegalStateException, InvalidCipherTextException { int len = processPacket(data.getBuffer(), 0, data.size(), out, outOff); reset(); return len; }
processAAD(associatedText.getBuffer(), 0, associatedText.size(), data.size()); processAAD(associatedText.getBuffer(), 0, associatedText.size(), data.size() - macSize); CalculateMac(in, inOff, len); engine.processBlock(nonce, 0, s, 0); while (totalLength > 0) ProcessBlock(in, inOff, len, out, outOff); totalLength -= engine.getBlockSize(); inOff += engine.getBlockSize(); reset(); ProcessBlock(in, inOff, len, out, outOff); CalculateMac(out, 0, outOff - macSize); reset();
intToBytes(dataLen, buffer, 0); // for G1 G1[G1.length - 1] = getFlag(true, macSize); intToBytes(assocLen, buffer, 0); // for G2
public void reset() { Arrays.fill(G1, (byte)0); Arrays.fill(buffer, (byte)0); Arrays.fill(counter, (byte)0); Arrays.fill(macBlock, (byte)0); counter[0] = 0x01; data.reset(); associatedText.reset(); if (initialAssociatedText != null) { processAADBytes(initialAssociatedText, 0, initialAssociatedText.length); } }
/** * Constructor allowing Nb configuration. * <p> * Nb is a parameter specified in CCM mode of DSTU7624 standard. * This parameter specifies maximum possible length of input. It should * be calculated as follows: Nb = 1/8 * (-3 + log[2]Nmax) + 1, * where Nmax - length of input message in bits. For practical reasons * Nmax usually less than 4Gb, e.g. for Nmax = 2^32 - 1, Nb = 4. * </p> * @param engine base cipher to use under CCM. * @param nB Nb value to use. */ public KCCMBlockCipher(BlockCipher engine, int nB) { this.engine = engine; this.macSize = engine.getBlockSize(); this.nonce = new byte[engine.getBlockSize()]; this.initialAssociatedText = new byte[engine.getBlockSize()]; this.mac = new byte[engine.getBlockSize()]; this.macBlock = new byte[engine.getBlockSize()]; this.G1 = new byte[engine.getBlockSize()]; this.buffer = new byte[engine.getBlockSize()]; this.s = new byte[engine.getBlockSize()]; this.counter = new byte[engine.getBlockSize()]; setNb(nB); }
processAADBytes(initialAssociatedText, 0, initialAssociatedText.length);
public CCM128() { // TODO: key size is also meant to be fixed super(new KCCMBlockCipher(new DSTU7624Engine(128))); } }
public CCM512() { super(new KCCMBlockCipher(new DSTU7624Engine(512))); } }
if (baseEngine instanceof DSTU7624Engine) cipher = new AEADGenericBlockCipher(new KCCMBlockCipher(baseEngine));