public void init(boolean forEncryption, CipherParameters params) throws IllegalArgumentException { counter = 0; cfbEngine.init(forEncryption, params); this.forEncryption = forEncryption; if (params instanceof ParametersWithIV) { params = ((ParametersWithIV)params).getParameters(); } if (params instanceof ParametersWithRandom) { params = ((ParametersWithRandom)params).getParameters(); } if (params instanceof ParametersWithSBox) { params = ((ParametersWithSBox)params).getParameters(); } key = (KeyParameter)params; }
public void init(boolean forEncryption, CipherParameters params) throws IllegalArgumentException { counter = 0; cfbEngine.init(forEncryption, params); this.forEncryption = forEncryption; if (params instanceof ParametersWithIV) { params = ((ParametersWithIV)params).getParameters(); } if (params instanceof ParametersWithRandom) { params = ((ParametersWithRandom)params).getParameters(); } if (params instanceof ParametersWithSBox) { params = ((ParametersWithSBox)params).getParameters(); } key = (KeyParameter)params; }
CipherInputStream cipherInputStream(InputStream inputStream, byte[] key, byte[] checksum) { CFBBlockCipher cipher = new CFBBlockCipher(new AESFastEngine(), 128); KeyParameter keyParameter = new KeyParameter(key); cipher.init(false, keyParameter); return new CipherInputStream(inputStream, cipher); }
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); }