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