protected byte calculateByte(byte b) { if (counter > 0 && counter % 1024 == 0) { BlockCipher base = cfbEngine.getUnderlyingCipher(); base.init(false, key); byte[] nextKey = new byte[32]; base.processBlock(C, 0, nextKey, 0); base.processBlock(C, 8, nextKey, 8); base.processBlock(C, 16, nextKey, 16); base.processBlock(C, 24, nextKey, 24); key = new KeyParameter(nextKey); base.init(true, key); byte[] iv = cfbEngine.getCurrentIV(); base.processBlock(iv, 0, iv, 0); cfbEngine.init(forEncryption, new ParametersWithIV(key, iv)); } counter++; return cfbEngine.calculateByte(b); }
protected byte calculateByte(byte b) { if (counter > 0 && counter % 1024 == 0) { BlockCipher base = cfbEngine.getUnderlyingCipher(); base.init(false, key); byte[] nextKey = new byte[32]; base.processBlock(C, 0, nextKey, 0); base.processBlock(C, 8, nextKey, 8); base.processBlock(C, 16, nextKey, 16); base.processBlock(C, 24, nextKey, 24); key = new KeyParameter(nextKey); base.init(true, key); byte[] iv = cfbEngine.getCurrentIV(); base.processBlock(iv, 0, iv, 0); cfbEngine.init(forEncryption, new ParametersWithIV(key, iv)); } counter++; return cfbEngine.calculateByte(b); }