9#include <botan/internal/cfb.h>
11#include <botan/internal/fmt.h>
16 m_cipher(std::move(cipher)),
17 m_block_size(m_cipher->block_size()),
18 m_feedback_bytes(feedback_bits ? feedback_bits / 8 : m_block_size) {
19 if(feedback_bits % 8 ||
feedback() > m_block_size) {
73 return m_cipher->has_keying_material();
76void CFB_Mode::key_schedule(std::span<const uint8_t> key) {
77 m_cipher->set_key(key);
81void CFB_Mode::start_msg(
const uint8_t nonce[],
size_t nonce_len) {
83 throw Invalid_IV_Length(
name(), nonce_len);
90 throw Invalid_State(
"CFB requires a non-empty initial nonce");
94 m_state.assign(nonce, nonce + nonce_len);
102 const size_t carryover =
block_size() - shift;
112size_t CFB_Encryption::process_msg(uint8_t buf[],
size_t sz) {
135 while(left >= shift) {
159inline void xor_copy(uint8_t buf[], uint8_t key_buf[],
size_t len) {
160 for(
size_t i = 0; i != len; ++i) {
161 uint8_t k = key_buf[i];
169size_t CFB_Decryption::process_msg(uint8_t buf[],
size_t sz) {
191 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 assert_key_material_set() const
virtual Key_Length_Specification key_spec() const =0
int(* update)(CTX *, const void *, CC_LONG 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)
std::vector< T, secure_allocator< T > > secure_vector
constexpr void copy_mem(T *out, const T *in, size_t n)