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