9#include <botan/block_cipher.h>
10#include <botan/internal/ffi_util.h>
20 if(bc ==
nullptr || bc_name ==
nullptr || *bc_name == 0) {
27 if(cipher ==
nullptr) {
31 *bc =
new botan_block_cipher_struct(std::move(cipher));
62 return BOTAN_FFI_VISIT(bc, [](
const auto& b) {
return static_cast<int>(b.block_size()); });
66 if(in ==
nullptr || out ==
nullptr) {
69 return BOTAN_FFI_VISIT(bc, [=](
const auto& b) { b.encrypt_n(in, out, blocks); });
73 if(in ==
nullptr || out ==
nullptr) {
76 return BOTAN_FFI_VISIT(bc, [=](
const auto& b) { b.decrypt_n(in, out, blocks); });
80 if(name_len ==
nullptr) {
88 size_t* out_minimum_keylength,
89 size_t* out_maximum_keylength,
90 size_t* out_keylength_modulo) {
92 if(out_minimum_keylength)
93 *out_minimum_keylength = bc.minimum_keylength();
94 if(out_maximum_keylength)
95 *out_maximum_keylength = bc.maximum_keylength();
96 if(out_keylength_modulo)
97 *out_keylength_modulo = bc.key_spec().keylength_multiple();
static std::unique_ptr< BlockCipher > create(std::string_view algo_spec, std::string_view provider="")
struct botan_block_cipher_struct * botan_block_cipher_t
@ BOTAN_FFI_ERROR_NOT_IMPLEMENTED
@ BOTAN_FFI_ERROR_NULL_POINTER
int botan_block_cipher_get_keyspec(botan_block_cipher_t cipher, size_t *out_minimum_keylength, size_t *out_maximum_keylength, size_t *out_keylength_modulo)
int botan_block_cipher_clear(botan_block_cipher_t bc)
int botan_block_cipher_init(botan_block_cipher_t *bc, const char *bc_name)
int botan_block_cipher_block_size(botan_block_cipher_t bc)
int botan_block_cipher_decrypt_blocks(botan_block_cipher_t bc, const uint8_t in[], uint8_t out[], size_t blocks)
int botan_block_cipher_name(botan_block_cipher_t cipher, char *name, size_t *name_len)
int botan_block_cipher_destroy(botan_block_cipher_t bc)
int botan_block_cipher_encrypt_blocks(botan_block_cipher_t bc, const uint8_t in[], uint8_t out[], size_t blocks)
int botan_block_cipher_set_key(botan_block_cipher_t bc, const uint8_t key[], size_t len)
#define BOTAN_FFI_VISIT(obj, lambda)
#define BOTAN_FFI_CHECKED_DELETE(o)
#define BOTAN_FFI_DECLARE_STRUCT(NAME, TYPE, MAGIC)
int write_str_output(uint8_t out[], size_t *out_len, std::string_view str)
int ffi_guard_thunk(const char *func_name, const std::function< int()> &thunk)