8#ifndef BOTAN_CIPHER_MODE_H_
9#define BOTAN_CIPHER_MODE_H_
11#include <botan/concepts.h>
12#include <botan/exceptn.h>
13#include <botan/secmem.h>
14#include <botan/sym_algo.h>
43 static std::vector<std::string> providers(std::string_view algo_spec);
52 static std::unique_ptr<Cipher_Mode> create(std::string_view algo,
54 std::string_view provider =
"");
63 static std::unique_ptr<Cipher_Mode> create_or_throw(std::string_view algo,
65 std::string_view provider =
"");
71 virtual void start_msg(
const uint8_t nonce[],
size_t nonce_len) = 0;
77 virtual size_t process_msg(uint8_t msg[],
size_t msg_len) = 0;
98 void start(std::span<const uint8_t> nonce) { start_msg(nonce.data(), nonce.size()); }
105 void start(
const uint8_t nonce[],
size_t nonce_len) { start_msg(nonce, nonce_len); }
117 void start() {
return start_msg(
nullptr, 0); }
132 size_t process(std::span<uint8_t> msg) {
return this->process_msg(msg.data(), msg.size()); }
134 size_t process(uint8_t msg[],
size_t msg_len) {
return this->process_msg(msg, msg_len); }
148 template <concepts::resizable_
byte_buffer T>
151 const size_t written = process(std::span(buffer).subspan(offset));
152 buffer.resize(offset + written);
192 template <concepts::resizable_
byte_buffer T>
193 void finish(
T& final_block,
size_t offset = 0) {
195 finish_msg(tmp, offset);
196 final_block.resize(tmp.size());
197 std::copy(tmp.begin(), tmp.end(), final_block.begin());
275 virtual std::string
provider()
const {
return "base"; }
#define BOTAN_ASSERT(expr, assertion_made)
virtual void start_msg(const uint8_t nonce[], size_t nonce_len)=0
static std::unique_ptr< Cipher_Mode > create(std::string_view algo, Cipher_Dir direction, std::string_view provider="")
virtual std::string provider() const
void start(std::span< const uint8_t > nonce)
bool authenticated() const
virtual void finish_msg(secure_vector< uint8_t > &final_block, size_t offset=0)=0
void start(const uint8_t nonce[], size_t nonce_len)
void finish(secure_vector< uint8_t > &final_block, size_t offset=0)
virtual size_t default_nonce_length() const =0
size_t process(uint8_t msg[], size_t msg_len)
virtual bool requires_entire_message() const
virtual size_t ideal_granularity() const =0
void update(T &buffer, size_t offset=0)
size_t process(std::span< uint8_t > msg)
virtual size_t output_length(size_t input_length) const =0
void finish(T &final_block, size_t offset=0)
virtual size_t tag_size() const
virtual size_t process_msg(uint8_t msg[], size_t msg_len)=0
virtual size_t minimum_final_size() const =0
virtual size_t update_granularity() const =0
virtual bool valid_nonce_length(size_t nonce_len) const =0
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_DEPRECATED(msg)
Cipher_Mode * get_cipher_mode(std::string_view algo_spec, Cipher_Dir direction, std::string_view provider="")
std::vector< T, secure_allocator< T > > secure_vector