8#include <botan/block_cipher.h>
9#include <botan/internal/scan_name.h>
10#include <botan/exceptn.h>
12#if defined(BOTAN_HAS_AES)
13 #include <botan/internal/aes.h>
16#if defined(BOTAN_HAS_ARIA)
17 #include <botan/internal/aria.h>
20#if defined(BOTAN_HAS_BLOWFISH)
21 #include <botan/internal/blowfish.h>
24#if defined(BOTAN_HAS_CAMELLIA)
25 #include <botan/internal/camellia.h>
28#if defined(BOTAN_HAS_CAST_128)
29 #include <botan/internal/cast128.h>
32#if defined(BOTAN_HAS_CASCADE)
33 #include <botan/internal/cascade.h>
36#if defined(BOTAN_HAS_DES)
37 #include <botan/internal/des.h>
40#if defined(BOTAN_HAS_GOST_28147_89)
41 #include <botan/internal/gost_28147.h>
44#if defined(BOTAN_HAS_IDEA)
45 #include <botan/internal/idea.h>
48#if defined(BOTAN_HAS_LION)
49 #include <botan/internal/lion.h>
52#if defined(BOTAN_HAS_NOEKEON)
53 #include <botan/internal/noekeon.h>
56#if defined(BOTAN_HAS_SEED)
57 #include <botan/internal/seed.h>
60#if defined(BOTAN_HAS_SERPENT)
61 #include <botan/internal/serpent.h>
64#if defined(BOTAN_HAS_SHACAL2)
65 #include <botan/internal/shacal2.h>
68#if defined(BOTAN_HAS_SM4)
69 #include <botan/internal/sm4.h>
72#if defined(BOTAN_HAS_TWOFISH)
73 #include <botan/internal/twofish.h>
76#if defined(BOTAN_HAS_THREEFISH_512)
77 #include <botan/internal/threefish_512.h>
80#if defined(BOTAN_HAS_COMMONCRYPTO)
81 #include <botan/internal/commoncrypto.h>
86std::unique_ptr<BlockCipher>
88 const std::string& provider)
90#if defined(BOTAN_HAS_COMMONCRYPTO)
108#if defined(BOTAN_HAS_AES)
109 if(algo ==
"AES-128")
111 return std::make_unique<AES_128>();
114 if(algo ==
"AES-192")
116 return std::make_unique<AES_192>();
119 if(algo ==
"AES-256")
121 return std::make_unique<AES_256>();
125#if defined(BOTAN_HAS_ARIA)
126 if(algo ==
"ARIA-128")
128 return std::make_unique<ARIA_128>();
131 if(algo ==
"ARIA-192")
133 return std::make_unique<ARIA_192>();
136 if(algo ==
"ARIA-256")
138 return std::make_unique<ARIA_256>();
142#if defined(BOTAN_HAS_SERPENT)
143 if(algo ==
"Serpent")
145 return std::make_unique<Serpent>();
149#if defined(BOTAN_HAS_SHACAL2)
150 if(algo ==
"SHACAL2")
152 return std::make_unique<SHACAL2>();
156#if defined(BOTAN_HAS_TWOFISH)
157 if(algo ==
"Twofish")
159 return std::make_unique<Twofish>();
163#if defined(BOTAN_HAS_THREEFISH_512)
164 if(algo ==
"Threefish-512")
166 return std::make_unique<Threefish_512>();
170#if defined(BOTAN_HAS_BLOWFISH)
171 if(algo ==
"Blowfish")
173 return std::make_unique<Blowfish>();
177#if defined(BOTAN_HAS_CAMELLIA)
178 if(algo ==
"Camellia-128")
180 return std::make_unique<Camellia_128>();
183 if(algo ==
"Camellia-192")
185 return std::make_unique<Camellia_192>();
188 if(algo ==
"Camellia-256")
190 return std::make_unique<Camellia_256>();
194#if defined(BOTAN_HAS_DES)
197 return std::make_unique<DES>();
200 if(algo ==
"TripleDES" || algo ==
"3DES" || algo ==
"DES-EDE")
202 return std::make_unique<TripleDES>();
206#if defined(BOTAN_HAS_NOEKEON)
207 if(algo ==
"Noekeon")
209 return std::make_unique<Noekeon>();
213#if defined(BOTAN_HAS_CAST_128)
214 if(algo ==
"CAST-128" || algo ==
"CAST5")
216 return std::make_unique<CAST_128>();
220#if defined(BOTAN_HAS_IDEA)
223 return std::make_unique<IDEA>();
227#if defined(BOTAN_HAS_SEED)
230 return std::make_unique<SEED>();
234#if defined(BOTAN_HAS_SM4)
237 return std::make_unique<SM4>();
243#if defined(BOTAN_HAS_GOST_28147_89)
246 return std::make_unique<GOST_28147_89>(req.
arg(0,
"R3411_94_TestParam"));
250#if defined(BOTAN_HAS_CASCADE)
257 return std::make_unique<Cascade_Cipher>(std::move(c1), std::move(c2));
261#if defined(BOTAN_HAS_LION)
270 return std::make_unique<Lion>(std::move(
hash), std::move(stream),
block_size);
282std::unique_ptr<BlockCipher>
284 const std::string& provider)
295 return probe_providers_of<BlockCipher>(algo, {
"base",
"commoncrypto" });
#define BOTAN_UNUSED(...)
static std::vector< std::string > providers(const std::string &algo_spec)
static std::unique_ptr< BlockCipher > create(const std::string &algo_spec, const std::string &provider="")
static std::unique_ptr< BlockCipher > create_or_throw(const std::string &algo_spec, const std::string &provider="")
virtual size_t block_size() const =0
virtual std::string provider() const
static std::unique_ptr< HashFunction > create(const std::string &algo_spec, const std::string &provider="")
std::string arg(size_t i) const
const std::string & algo_name() const
size_t arg_as_integer(size_t i, size_t def_value) const
bool arg_count_between(size_t lower, size_t upper) const
static std::unique_ptr< StreamCipher > create(const std::string &algo_spec, const std::string &provider="")
std::unique_ptr< BlockCipher > make_commoncrypto_block_cipher(const std::string &name)