8 #include <botan/cipher_mode.h>
9 #include <botan/stream_mode.h>
10 #include <botan/scan_name.h>
13 #if defined(BOTAN_HAS_BLOCK_CIPHER)
14 #include <botan/block_cipher.h>
17 #if defined(BOTAN_HAS_AEAD_MODES)
18 #include <botan/aead.h>
21 #if defined(BOTAN_HAS_MODE_CBC)
22 #include <botan/cbc.h>
25 #if defined(BOTAN_HAS_MODE_CFB)
26 #include <botan/cfb.h>
29 #if defined(BOTAN_HAS_MODE_XTS)
30 #include <botan/xts.h>
33 #if defined(BOTAN_HAS_MODE_XTS)
34 #include <botan/xts.h>
46 #if defined(BOTAN_HAS_AEAD_MODES)
47 if(
auto aead =
get_aead(algo, direction))
53 if(algo.find(
'/') != std::string::npos)
55 const std::vector<std::string> algo_parts =
split_on(algo,
'/');
56 const std::string cipher_name = algo_parts[0];
62 std::ostringstream alg_args;
64 alg_args <<
'(' << cipher_name;
65 for(
size_t i = 1; i < mode_info.size(); ++i)
66 alg_args <<
',' << mode_info[i];
67 for(
size_t i = 2; i < algo_parts.size(); ++i)
68 alg_args <<
',' << algo_parts[i];
71 const std::string mode_name = mode_info[0] + alg_args.str();
75 #if defined(BOTAN_HAS_BLOCK_CIPHER)
91 #if defined(BOTAN_HAS_MODE_CBC)
94 const std::string padding = spec.
arg(1,
"PKCS7");
105 std::unique_ptr<BlockCipherModePaddingMethod> pad(
get_bc_pad(padding));
118 #if defined(BOTAN_HAS_MODE_XTS)
128 #if defined(BOTAN_HAS_MODE_CFB)
131 const size_t feedback_bits = spec.
arg_as_integer(1, 8*bc->block_size());
std::vector< std::string > parse_algorithm_name(const std::string &namex)
std::string arg(size_t i) const
BlockCipherModePaddingMethod * get_bc_pad(const std::string &algo_spec)
Cipher_Mode * get_cipher_mode(const std::string &algo, Cipher_Dir direction)
std::vector< std::string > split_on(const std::string &str, char delim)
size_t arg_as_integer(size_t i, size_t def_value) const
AEAD_Mode * get_aead(const std::string &algo, Cipher_Dir dir)
static std::unique_ptr< BlockCipher > create(const std::string &algo_spec, const std::string &provider="")
const std::string & algo_name() const
static std::unique_ptr< StreamCipher > create(const std::string &algo_spec, const std::string &provider="")