Botan 1.10.17
stream_cipher.h
Go to the documentation of this file.
1/*
2* Stream Cipher
3* (C) 1999-2007 Jack Lloyd
4*
5* Distributed under the terms of the Botan license
6*/
7
8#ifndef BOTAN_STREAM_CIPHER_H__
9#define BOTAN_STREAM_CIPHER_H__
10
11#include <botan/sym_algo.h>
12
13namespace Botan {
14
15/**
16* Base class for all stream ciphers
17*/
18class BOTAN_DLL StreamCipher : public SymmetricAlgorithm
19 {
20 public:
21 /**
22 * Encrypt or decrypt a message
23 * @param in the plaintext
24 * @param out the byte array to hold the output, i.e. the ciphertext
25 * @param len the length of both in and out in bytes
26 */
27 virtual void cipher(const byte in[], byte out[], size_t len) = 0;
28
29 /**
30 * Encrypt or decrypt a message
31 * @param buf the plaintext / ciphertext
32 * @param len the length of buf in bytes
33 */
34 void cipher1(byte buf[], size_t len)
35 { cipher(buf, buf, len); }
36
37 /**
38 * Resync the cipher using the IV
39 * @param iv the initialization vector
40 * @param iv_len the length of the IV in bytes
41 */
42 virtual void set_iv(const byte iv[], size_t iv_len);
43
44 /**
45 * @param iv_len the length of the IV in bytes
46 * @return if the length is valid for this algorithm
47 */
48 virtual bool valid_iv_length(size_t iv_len) const;
49
50 /**
51 * Get a new object representing the same algorithm as *this
52 */
53 virtual StreamCipher* clone() const = 0;
54 };
55
56}
57
58#endif
virtual void cipher(const byte in[], byte out[], size_t len)=0
void cipher1(byte buf[], size_t len)
virtual StreamCipher * clone() const =0