1
package org.bouncycastle.crypto.modes;
3
import org.bouncycastle.crypto.BlockCipher;
4
import org.bouncycastle.crypto.CipherParameters;
5
import org.bouncycastle.crypto.DataLengthException;
6
import org.bouncycastle.crypto.InvalidCipherTextException;
9
* A block cipher mode that includes authenticated encryption with a streaming mode and optional associated data.
10
* @see org.bouncycastle.crypto.params.AEADParameters
12
public interface AEADBlockCipher
15
* initialise the underlying cipher. Parameter can either be an AEADParameters or a ParametersWithIV object.
17
* @param forEncryption true if we are setting up for encryption, false otherwise.
18
* @param params the necessary parameters for the underlying cipher to be initialised.
19
* @exception IllegalArgumentException if the params argument is inappropriate.
21
public void init(boolean forEncryption, CipherParameters params)
22
throws IllegalArgumentException;
25
* Return the name of the algorithm.
27
* @return the algorithm name.
29
public String getAlgorithmName();
32
* return the cipher this object wraps.
34
* @return the cipher this object wraps.
36
public BlockCipher getUnderlyingCipher();
39
* encrypt/decrypt a single byte.
41
* @param in the byte to be processed.
42
* @param out the output buffer the processed byte goes into.
43
* @param outOff the offset into the output byte array the processed data starts at.
44
* @return the number of bytes written to out.
45
* @exception DataLengthException if the output buffer is too small.
47
public int processByte(byte in, byte[] out, int outOff)
48
throws DataLengthException;
51
* process a block of bytes from in putting the result into out.
53
* @param in the input byte array.
54
* @param inOff the offset into the in array where the data to be processed starts.
55
* @param len the number of bytes to be processed.
56
* @param out the output buffer the processed bytes go into.
57
* @param outOff the offset into the output byte array the processed data starts at.
58
* @return the number of bytes written to out.
59
* @exception DataLengthException if the output buffer is too small.
61
public int processBytes(byte[] in, int inOff, int len, byte[] out, int outOff)
62
throws DataLengthException;
65
* Finish the operation either appending or verifying the MAC at the end of the data.
67
* @param out space for any resulting output data.
68
* @param outOff offset into out to start copying the data at.
69
* @return number of bytes written into out.
70
* @throws IllegalStateException if the cipher is in an inappropriate state.
71
* @throws org.bouncycastle.crypto.InvalidCipherTextException if the MAC fails to match.
73
public int doFinal(byte[] out, int outOff)
74
throws IllegalStateException, InvalidCipherTextException;
77
* Return the value of the MAC associated with the last stream processed.
79
* @return MAC for plaintext data.
81
public byte[] getMac();
84
* return the size of the output buffer required for a processBytes
85
* an input of len bytes.
87
* @param len the length of the input.
88
* @return the space required to accommodate a call to processBytes
89
* with len bytes of input.
91
public int getUpdateOutputSize(int len);
94
* return the size of the output buffer required for a processBytes plus a
95
* doFinal with an input of len bytes.
97
* @param len the length of the input.
98
* @return the space required to accommodate a call to processBytes and doFinal
99
* with len bytes of input.
101
public int getOutputSize(int len);
104
* Reset the cipher. After resetting the cipher is in the same state
105
* as it was after the last init (if there was one).