/** * Process one block of input from the array in and write it to * the out array. * * @param in the array containing the input data. * @param inOff offset into the in array the data starts at. * @param out the array the output data will be copied into. * @param outOff the offset into the out array the output will start at. * @exception DataLengthException if there isn't enough data in in, or * space in out. * @exception IllegalStateException if the cipher isn't initialised. * @return the number of bytes processed and produced. */ public int processBlock( byte[] in, int inOff, byte[] out, int outOff) throws DataLengthException, IllegalStateException { return (forEncryption) ? encryptBlock(in, inOff, out, outOff) : decryptBlock(in, inOff, out, outOff); }
/** * Initialise the cipher and, possibly, the initialisation vector (IV). * If an IV isn't passed as part of the parameter, the IV will be all zeros. * An IV which is too short is handled in FIPS compliant fashion. * * @param forEncryption if true the cipher is initialised for * encryption, if false for decryption. * @param params the key and other data required by the cipher. * @exception IllegalArgumentException if the params argument is * inappropriate. */ public void init( boolean forEncryption, CipherParameters params) throws IllegalArgumentException { this.forEncryption = forEncryption; reset(); cipher.init(true, params); }
static BufferedBlockCipher createStreamCipher(boolean forEncryption, BlockCipher engine, boolean withIntegrityPacket, byte[] key) { BufferedBlockCipher c; if (withIntegrityPacket) { c = new BufferedBlockCipher(new CFBBlockCipher(engine, engine.getBlockSize() * 8)); } else { c = new BufferedBlockCipher(new OpenPGPCFBBlockCipher(engine)); } KeyParameter keyParameter = new KeyParameter(key); if (withIntegrityPacket) { c.init(forEncryption, new ParametersWithIV(keyParameter, new byte[engine.getBlockSize()])); } else { c.init(forEncryption, keyParameter); } return c; }
FR[blockSize - 2] = out[outOff] = encryptByte(in[inOff], blockSize - 2); FR[blockSize - 1] = out[outOff + 1] = encryptByte(in[inOff + 1], blockSize - 1); FR[n - 2] = out[outOff + n] = encryptByte(in[inOff + n], n - 2); FR[n] = out[outOff + n] = encryptByte(in[inOff + n], n); out[outOff] = encryptByte(in[inOff], 0); out[outOff + 1] = encryptByte(in[inOff + 1], 1); FR[n - 2] = out[outOff + n] = encryptByte(in[inOff + n], n - 2);
new OpenPGPCFBBlockCipher(baseEngine));
out[outOff] = encryptByte(inVal, blockSize - 2); out[outOff + 1] = encryptByte(inVal, blockSize - 1); out[outOff + n] = encryptByte(inVal, n - 2); out[n] = encryptByte(in[inOff + n], n); out[outOff ] = encryptByte(inVal1, 0); out[outOff + 1] = encryptByte(inVal2, 1); out[outOff + n] = encryptByte(inVal, n - 2);
new OpenPGPCFBBlockCipher(baseEngine));
/** * Process one block of input from the array in and write it to * the out array. * * @param in the array containing the input data. * @param inOff offset into the in array the data starts at. * @param out the array the output data will be copied into. * @param outOff the offset into the out array the output will start at. * @exception DataLengthException if there isn't enough data in in, or * space in out. * @exception IllegalStateException if the cipher isn't initialised. * @return the number of bytes processed and produced. */ public int processBlock( byte[] in, int inOff, byte[] out, int outOff) throws DataLengthException, IllegalStateException { return (forEncryption) ? encryptBlock(in, inOff, out, outOff) : decryptBlock(in, inOff, out, outOff); }
FR[blockSize - 2] = out[outOff] = encryptByte(in[inOff], blockSize - 2); FR[blockSize - 1] = out[outOff + 1] = encryptByte(in[inOff + 1], blockSize - 1); FR[n - 2] = out[outOff + n] = encryptByte(in[inOff + n], n - 2); FR[n] = out[outOff + n] = encryptByte(in[inOff + n], n); out[outOff] = encryptByte(in[inOff], 0); out[outOff + 1] = encryptByte(in[inOff + 1], 1); FR[n - 2] = out[outOff + n] = encryptByte(in[inOff + n], n - 2);
/** * Initialise the cipher and, possibly, the initialisation vector (IV). * If an IV isn't passed as part of the parameter, the IV will be all zeros. * An IV which is too short is handled in FIPS compliant fashion. * * @param forEncryption if true the cipher is initialised for * encryption, if false for decryption. * @param params the key and other data required by the cipher. * @exception IllegalArgumentException if the params argument is * inappropriate. */ public void init( boolean forEncryption, CipherParameters params) throws IllegalArgumentException { this.forEncryption = forEncryption; reset(); cipher.init(true, params); }
new OpenPGPCFBBlockCipher(baseEngine));
out[outOff] = encryptByte(inVal, blockSize - 2); out[outOff + 1] = encryptByte(inVal, blockSize - 1); out[outOff + n] = encryptByte(inVal, n - 2); out[n] = encryptByte(in[inOff + n], n); out[outOff ] = encryptByte(inVal1, 0); out[outOff + 1] = encryptByte(inVal2, 1); out[outOff + n] = encryptByte(inVal, n - 2);