8#include <botan/internal/ofb.h>
10#include <botan/exceptn.h>
11#include <botan/internal/fmt.h>
16 m_cipher(std::move(cipher)), m_buffer(m_cipher->block_size()), m_buf_pos(0) {}
25 return m_cipher->has_keying_material();
29 return m_buffer.size();
32void OFB::key_schedule(std::span<const uint8_t> key) {
33 m_cipher->set_key(key);
40 return fmt(
"OFB({})", m_cipher->name());
44 return m_cipher->block_size();
48 return (iv_len <= m_cipher->block_size());
52 return m_cipher->key_spec();
56 return std::make_unique<OFB>(m_cipher->new_object());
59void OFB::cipher_bytes(
const uint8_t in[], uint8_t out[],
size_t length) {
60 while(length >= m_buffer.size() - m_buf_pos) {
61 xor_buf(out, in, &m_buffer[m_buf_pos], m_buffer.size() - m_buf_pos);
62 length -= (m_buffer.size() - m_buf_pos);
63 in += (m_buffer.size() - m_buf_pos);
64 out += (m_buffer.size() - m_buf_pos);
65 m_cipher->encrypt(m_buffer);
68 xor_buf(out, in, &m_buffer[m_buf_pos], length);
72void OFB::set_iv_bytes(
const uint8_t iv[],
size_t iv_len) {
74 throw Invalid_IV_Length(
name(), iv_len);
81 m_cipher->encrypt(m_buffer);
#define BOTAN_ASSERT_NOMSG(expr)
size_t default_iv_length() const override
std::string name() const override
bool valid_iv_length(size_t iv_len) const override
size_t buffer_size() const override
bool has_keying_material() const override
OFB(std::unique_ptr< BlockCipher > cipher)
void seek(uint64_t offset) override
Key_Length_Specification key_spec() const override
std::unique_ptr< StreamCipher > new_object() const override
void set_iv(const uint8_t iv[], size_t iv_len)
void zeroise(std::vector< T, Alloc > &vec)
std::string fmt(std::string_view format, const T &... args)
constexpr void xor_buf(ranges::contiguous_output_range< uint8_t > auto &&out, ranges::contiguous_range< uint8_t > auto &&in)
constexpr void copy_mem(T *out, const T *in, size_t n)