01: package org.bouncycastle.crypto;
02:
03: /**
04: * Block cipher engines are expected to conform to this interface.
05: */
06: public interface BlockCipher {
07: /**
08: * Initialise the cipher.
09: *
10: * @param forEncryption if true the cipher is initialised for
11: * encryption, if false for decryption.
12: * @param params the key and other data required by the cipher.
13: * @exception IllegalArgumentException if the params argument is
14: * inappropriate.
15: */
16: public void init(boolean forEncryption, CipherParameters params)
17: throws IllegalArgumentException;
18:
19: /**
20: * Return the name of the algorithm the cipher implements.
21: *
22: * @return the name of the algorithm the cipher implements.
23: */
24: public String getAlgorithmName();
25:
26: /**
27: * Return the block size for this cipher (in bytes).
28: *
29: * @return the block size for this cipher in bytes.
30: */
31: public int getBlockSize();
32:
33: /**
34: * Process one block of input from the array in and write it to
35: * the out array.
36: *
37: * @param in the array containing the input data.
38: * @param inOff offset into the in array the data starts at.
39: * @param out the array the output data will be copied into.
40: * @param outOff the offset into the out array the output will start at.
41: * @exception DataLengthException if there isn't enough data in in, or
42: * space in out.
43: * @exception IllegalStateException if the cipher isn't initialised.
44: * @return the number of bytes processed and produced.
45: */
46: public int processBlock(byte[] in, int inOff, byte[] out, int outOff)
47: throws DataLengthException, IllegalStateException;
48:
49: /**
50: * Reset the cipher. After resetting the cipher is in the same state
51: * as it was after the last init (if there was one).
52: */
53: public void reset();
54: }
|