1b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallampackage org.bouncycastle.crypto;
2b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
3b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
4b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam/**
5b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * base interface that a public/private key block cipher needs
6b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam * to conform to.
7b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam */
8b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallampublic interface AsymmetricBlockCipher
9b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam{
10b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    /**
11b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     * initialise the cipher.
12b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     *
13b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     * @param forEncryption if true the cipher is initialised for
14b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     *  encryption, if false for decryption.
15b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     * @param param the key and other data required by the cipher.
16b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     */
17b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public void init(boolean forEncryption, CipherParameters param);
18b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
19b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    /**
20b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     * returns the largest size an input block can be.
21b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     *
22b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     * @return maximum size for an input block.
23b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     */
24b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public int getInputBlockSize();
25b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
26b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    /**
27b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     * returns the maximum size of the block produced by this cipher.
28b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     *
29b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     * @return maximum size of the output block produced by the cipher.
30b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     */
31b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public int getOutputBlockSize();
32b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam
33b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    /**
34b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     * process the block of len bytes stored in in from offset inOff.
35b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     *
36b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     * @param in the input data
37b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     * @param inOff offset into the in array where the data starts
38b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     * @param len the length of the block to be processed.
39b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     * @return the resulting byte array of the encryption/decryption process.
40b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     * @exception InvalidCipherTextException data decrypts improperly.
41b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     * @exception DataLengthException the input data is too large for the cipher.
42b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam     */
43b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam    public byte[] processBlock(byte[] in, int inOff, int len)
44b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam        throws InvalidCipherTextException;
45b61a96e7ef1a78acf013bbf08fe537e5b5f129caPeter Hallam}
46