9#include <botan/internal/cfb.h>
11#include <botan/mem_ops.h>
12#include <botan/internal/fmt.h>
17 m_cipher(std::move(
cipher)),
19 m_feedback_bytes(feedback_bits != 0 ? feedback_bits / 8 : m_block_size) {
20 if(feedback_bits % 8 != 0 ||
feedback() > m_block_size) {
74 return m_cipher->has_keying_material();
77void CFB_Mode::key_schedule(std::span<const uint8_t> key) {
78 m_cipher->set_key(key);
82void CFB_Mode::start_msg(
const uint8_t nonce[],
size_t nonce_len) {
84 throw Invalid_IV_Length(
name(), nonce_len);
91 throw Invalid_State(
"CFB requires a non-empty initial nonce");
95 m_state.assign(nonce, nonce + nonce_len);
103 const size_t carryover =
block_size() - shift;
113size_t CFB_Encryption::process_msg(uint8_t buf[],
size_t sz) {
136 while(left >= shift) {
160inline void xor_copy(uint8_t buf[], uint8_t key_buf[],
size_t len) {
161 for(
size_t i = 0; i != len; ++i) {
162 uint8_t k = key_buf[i];
170size_t CFB_Decryption::process_msg(uint8_t buf[],
size_t sz) {
192 while(left >= shift) {
#define BOTAN_STATE_CHECK(expr)
void encrypt(const uint8_t in[], uint8_t out[]) const
size_t ideal_granularity() const final
size_t block_size() const
secure_vector< uint8_t > m_keystream
std::string name() const final
CFB_Mode(std::unique_ptr< BlockCipher > cipher, size_t feedback_bits)
Key_Length_Specification key_spec() const final
size_t default_nonce_length() const final
bool has_keying_material() const final
size_t output_length(size_t input_length) const final
secure_vector< uint8_t > m_state
const BlockCipher & cipher() const
size_t update_granularity() const final
bool valid_nonce_length(size_t n) const final
size_t minimum_final_size() const final
void update(T &buffer, size_t offset=0)
void assert_key_material_set() const
virtual Key_Length_Specification key_spec() const =0
void zeroise(std::vector< T, Alloc > &vec)
constexpr void copy_mem(T *out, const T *in, size_t n)
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)
std::vector< T, secure_allocator< T > > secure_vector