1 package org.bouncycastle.crypto;
3 import java.lang.IllegalStateException;
6 * Block cipher engines are expected to conform to this interface.
8 public interface BlockCipher
11 * Initialise the cipher.
13 * @param forEncryption if true the cipher is initialised for
14 * encryption, if false for decryption.
15 * @param param the key and other data required by the cipher.
16 * @exception IllegalArgumentException if the params argument is
19 public void init(boolean forEncryption, CipherParameters params)
20 throws IllegalArgumentException;
23 * Return the name of the algorithm the cipher implements.
25 * @return the name of the algorithm the cipher implements.
27 public String getAlgorithmName();
30 * Return the block size for this cipher (in bytes).
32 * @return the block size for this cipher in bytes.
34 public int getBlockSize();
37 * Process one block of input from the array in and write it to
40 * @param in the array containing the input data.
41 * @param inOff offset into the in array the data starts at.
42 * @param out the array the output data will be copied into.
43 * @param outOff the offset into the out array the output will start at.
44 * @exception DataLengthException if there isn't enough data in in, or
46 * @exception IllegalStateException if the cipher isn't initialised.
47 * @return the number of bytes processed and produced.
49 public int processBlock(byte[] in, int inOff, byte[] out, int outOff)
50 throws DataLengthException, IllegalStateException;
53 * Reset the cipher. After resetting the cipher is in the same state
54 * as it was after the last init (if there was one).