/** * initialise a CAST cipher. * * @param encrypting whether or not we are for encryption. * @param params the parameters required to set up the cipher. * @exception IllegalArgumentException if the params argument is * inappropriate. */ public void init( boolean encrypting, CipherParameters params) { if (params instanceof KeyParameter) { _encrypting = encrypting; _workingKey = ((KeyParameter)params).getKey(); setKey(_workingKey); return; } throw new IllegalArgumentException("Invalid parameter passed to "+getAlgorithmName()+" init - " + params.getClass().getName()); }
/** * initialise a CAST cipher. * * @param encrypting whether or not we are for encryption. * @param params the parameters required to set up the cipher. * @exception IllegalArgumentException if the params argument is * inappropriate. */ public void init( boolean encrypting, CipherParameters params) { if (params instanceof KeyParameter) { _encrypting = encrypting; _workingKey = ((KeyParameter)params).getKey(); setKey(_workingKey); return; } throw new IllegalArgumentException("Invalid parameter passed to "+getAlgorithmName()+" init - " + params.getClass().getName()); }
public int processBlock( byte[] in, int inOff, byte[] out, int outOff) { if (_workingKey == null) { throw new IllegalStateException(getAlgorithmName()+" not initialised"); } int blockSize = getBlockSize(); if ((inOff + blockSize) > in.length) { throw new DataLengthException("input buffer too short"); } if ((outOff + blockSize) > out.length) { throw new OutputLengthException("output buffer too short"); } if (_encrypting) { return encryptBlock(in, inOff, out, outOff); } else { return decryptBlock(in, inOff, out, outOff); } }
public int processBlock( byte[] in, int inOff, byte[] out, int outOff) { if (_workingKey == null) { throw new IllegalStateException(getAlgorithmName()+" not initialised"); } int blockSize = getBlockSize(); if ((inOff + blockSize) > in.length) { throw new DataLengthException("Input buffer too short"); } if ((outOff + blockSize) > out.length) { throw new DataLengthException("Output buffer too short"); } if (_encrypting) { return encryptBlock(in, inOff, out, outOff); } else { return decryptBlock(in, inOff, out, outOff); } }