9#include <botan/block_cipher.h>
10#include <botan/internal/ffi_util.h>
21 if(bc ==
nullptr || bc_name ==
nullptr || *bc_name == 0) {
28 if(cipher ==
nullptr) {
63 const size_t bs = b.block_size();
68 if(std::in_range<int>(bs)) {
69 return static_cast<int>(bs);
80 return BOTAN_FFI_VISIT(bc, [=](
const auto& b) { b.encrypt_n(in, out, blocks); });
87 return BOTAN_FFI_VISIT(bc, [=](
const auto& b) { b.decrypt_n(in, out, blocks); });
91 if(name_len ==
nullptr) {
99 size_t* out_minimum_keylength,
100 size_t* out_maximum_keylength,
101 size_t* out_keylength_modulo) {
103 if(out_minimum_keylength) {
104 *out_minimum_keylength = bc.minimum_keylength();
106 if(out_maximum_keylength) {
107 *out_maximum_keylength = bc.maximum_keylength();
109 if(out_keylength_modulo) {
110 *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
@ BOTAN_FFI_ERROR_INVALID_OBJECT_STATE
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)
BOTAN_FFI_ERROR ffi_new_object(T *obj, Args &&... args)
int ffi_guard_thunk(const char *func_name, T thunk)
bool any_null_pointers(Ptrs... ptr)
int write_str_output(char out[], size_t *out_len, const std::string &str)