8 #include <botan/cipher_filter.h>
9 #include <botan/internal/rounding.h>
15 size_t choose_update_size(
size_t update_granularity)
17 const size_t target_size = 1024;
19 if(update_granularity >= target_size)
20 return update_granularity;
22 return round_up(target_size, update_granularity);
29 mode->minimum_final_size()),
30 m_nonce(mode->default_nonce_length() == 0),
32 m_buffer(m_mode->update_granularity())
38 return m_mode->name();
47 std::vector<uint8_t> Cipher_Mode_Filter::Nonce_State::get()
49 BOTAN_ASSERT(m_fresh_nonce,
"The nonce is fresh for this message");
52 m_fresh_nonce =
false;
68 return m_mode->key_spec();
73 return m_mode->valid_nonce_length(length);
76 void Cipher_Mode_Filter::write(
const uint8_t input[],
size_t input_length)
81 void Cipher_Mode_Filter::end_msg()
86 void Cipher_Mode_Filter::start_msg()
88 m_mode->start(m_nonce.get());
91 void Cipher_Mode_Filter::buffered_block(
const uint8_t input[],
size_t input_length)
95 const size_t take =
std::min(m_mode->update_granularity(), input_length);
97 m_buffer.assign(input, input + take);
98 m_mode->update(m_buffer);
103 input_length -= take;
107 void Cipher_Mode_Filter::buffered_final(
const uint8_t input[],
size_t input_length)
109 secure_vector<uint8_t> buf(input, input + input_length);
secure_vector< uint8_t > bits_of() const
void set_iv(const InitializationVector &iv) override
bool valid_iv_length(size_t length) const override
virtual void send(const uint8_t in[], size_t length)
#define BOTAN_ASSERT(expr, assertion_made)
Cipher_Mode_Filter(Cipher_Mode *t)
void write(const uint8_t in[], size_t length)
void set_key(const SymmetricKey &key) override
std::string name() const override
Key_Length_Specification key_spec() const override
std::vector< T > unlock(const secure_vector< T > &in)
size_t round_up(size_t n, size_t align_to)