8 #ifndef BOTAN_CIPHER_MODE_H__
9 #define BOTAN_CIPHER_MODE_H__
11 #include <botan/secmem.h>
12 #include <botan/key_spec.h>
13 #include <botan/exceptn.h>
14 #include <botan/symkey.h>
31 virtual void start_msg(
const uint8_t nonce[],
size_t nonce_len) = 0;
37 template<
typename Alloc>
38 void start(
const std::vector<uint8_t, Alloc>& nonce)
40 start_msg(nonce.data(), nonce.size());
48 void start(
const uint8_t nonce[],
size_t nonce_len)
50 start_msg(nonce, nonce_len);
58 return start_msg(
nullptr, 0);
74 virtual size_t process(uint8_t msg[],
size_t msg_len) = 0;
84 uint8_t* buf = buffer.data() + offset;
85 const size_t buf_size = buffer.size() - offset;
87 const size_t written = process(buf, buf_size);
88 buffer.resize(offset + written);
105 virtual size_t output_length(
size_t input_length)
const = 0;
110 virtual size_t update_granularity()
const = 0;
116 virtual size_t minimum_final_size()
const = 0;
121 virtual size_t default_nonce_length()
const = 0;
126 virtual bool valid_nonce_length(
size_t nonce_len)
const = 0;
128 virtual std::string name()
const = 0;
134 virtual void clear() = 0;
139 virtual void reset() = 0;
164 return key_spec().valid_keylength(length);
171 template<
typename Alloc>
172 void set_key(
const std::vector<uint8_t, Alloc>& key)
174 set_key(key.data(), key.size());
191 void set_key(
const uint8_t key[],
size_t length)
193 if(!valid_keylength(length))
195 key_schedule(key, length);
202 virtual std::string
provider()
const {
return "base"; }
205 virtual void key_schedule(
const uint8_t key[],
size_t length) = 0;
void set_key(const uint8_t key[], size_t length)
void update(secure_vector< uint8_t > &buffer, size_t offset=0)
Cipher_Mode * get_cipher_mode(const std::string &algo, Cipher_Dir direction)
void start(const std::vector< uint8_t, Alloc > &nonce)
virtual bool authenticated() const
#define BOTAN_ASSERT(expr, assertion_made)
virtual size_t tag_size() const
virtual std::string provider() const
void start(const uint8_t nonce[], size_t nonce_len)
std::vector< T, secure_allocator< T >> secure_vector
void set_key(const SymmetricKey &key)
void set_key(const std::vector< uint8_t, Alloc > &key)
bool valid_keylength(size_t length) const
const uint8_t * begin() const