1f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrompackage org.bouncycastle.crypto;
2f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom
3f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom/**
4f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom * the interface stream ciphers conform to.
5f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom */
6f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrompublic interface StreamCipher
7f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom{
8f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom    /**
9f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * Initialise the cipher.
10f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     *
11f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * @param forEncryption if true the cipher is initialised for
12f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     *  encryption, if false for decryption.
13f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * @param params the key and other data required by the cipher.
14f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * @exception IllegalArgumentException if the params argument is
15f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * inappropriate.
16f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     */
17f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom    public void init(boolean forEncryption, CipherParameters params)
18f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom        throws IllegalArgumentException;
19f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom
20f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom    /**
21f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * Return the name of the algorithm the cipher implements.
22f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     *
23f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * @return the name of the algorithm the cipher implements.
24f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     */
25f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom    public String getAlgorithmName();
26f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom
27f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom    /**
28f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * encrypt/decrypt a single byte returning the result.
29f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     *
30f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * @param in the byte to be processed.
31f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * @return the result of processing the input byte.
32f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     */
33f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom    public byte returnByte(byte in);
34f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom
35f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom    /**
36f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * process a block of bytes from in putting the result into out.
37f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     *
38f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * @param in the input byte array.
39f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * @param inOff the offset into the in array where the data to be processed starts.
40f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * @param len the number of bytes to be processed.
41f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * @param out the output buffer the processed bytes go into.
42f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * @param outOff the offset into the output byte array the processed data starts at.
43f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * @exception DataLengthException if the output buffer is too small.
44f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     */
45f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom    public void processBytes(byte[] in, int inOff, int len, byte[] out, int outOff)
46f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom        throws DataLengthException;
47f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom
48f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom    /**
49f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * reset the cipher. This leaves it in the same state
50f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     * it was at after the last init (if there was one).
51f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom     */
52f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom    public void reset();
53f7433bf801526ab2a93e1cadb7a25ded87f43ed4Brian Carlstrom}
54