/** * initialise the cipher. * * @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(); if (params instanceof ParametersWithRandom) { ParametersWithRandom p = (ParametersWithRandom) params; padding.init(p.getRandom()); cipher.init(forEncryption, p.getParameters()); } else { padding.init(null); cipher.init(forEncryption, params); } }