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,
63 static std::unique_ptr<Cipher_Mode>
create_or_throw(std::string_view algo,
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); }
148 template <concepts::resizable_
byte_buffer T>
149 void update(T& buffer,
size_t offset = 0) {
150 const size_t written =
process(std::span(buffer).subspan(offset));
151 buffer.resize(offset + written);
191 template <concepts::resizable_
byte_buffer T>
192 void finish(T& final_block,
size_t offset = 0) {
195 final_block.resize(tmp.size());
196 std::copy(tmp.begin(), tmp.end(), final_block.begin());
274 virtual std::string
provider()
const {
return "base"; }
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_DEPRECATED(msg)
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)
static std::unique_ptr< Cipher_Mode > create_or_throw(std::string_view algo, Cipher_Dir direction, std::string_view provider="")
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)
static std::vector< std::string > providers(std::string_view algo_spec)
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
SymmetricAlgorithm()=default
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