8#include <botan/block_cipher.h>
9#include <botan/scan_name.h>
10#include <botan/exceptn.h>
12#if defined(BOTAN_HAS_AES)
13 #include <botan/aes.h>
16#if defined(BOTAN_HAS_ARIA)
17 #include <botan/aria.h>
20#if defined(BOTAN_HAS_BLOWFISH)
21 #include <botan/blowfish.h>
24#if defined(BOTAN_HAS_CAMELLIA)
25 #include <botan/camellia.h>
28#if defined(BOTAN_HAS_CAST_128)
29 #include <botan/cast128.h>
32#if defined(BOTAN_HAS_CAST_256)
33 #include <botan/cast256.h>
36#if defined(BOTAN_HAS_CASCADE)
37 #include <botan/cascade.h>
40#if defined(BOTAN_HAS_DES)
41 #include <botan/des.h>
42 #include <botan/desx.h>
45#if defined(BOTAN_HAS_GOST_28147_89)
46 #include <botan/gost_28147.h>
49#if defined(BOTAN_HAS_IDEA)
50 #include <botan/idea.h>
53#if defined(BOTAN_HAS_KASUMI)
54 #include <botan/kasumi.h>
57#if defined(BOTAN_HAS_LION)
58 #include <botan/lion.h>
61#if defined(BOTAN_HAS_MISTY1)
62 #include <botan/misty1.h>
65#if defined(BOTAN_HAS_NOEKEON)
66 #include <botan/noekeon.h>
69#if defined(BOTAN_HAS_SEED)
70 #include <botan/seed.h>
73#if defined(BOTAN_HAS_SERPENT)
74 #include <botan/serpent.h>
77#if defined(BOTAN_HAS_SHACAL2)
78 #include <botan/shacal2.h>
81#if defined(BOTAN_HAS_SM4)
82 #include <botan/sm4.h>
85#if defined(BOTAN_HAS_TWOFISH)
86 #include <botan/twofish.h>
89#if defined(BOTAN_HAS_THREEFISH_512)
90 #include <botan/threefish_512.h>
93#if defined(BOTAN_HAS_XTEA)
94 #include <botan/xtea.h>
97#if defined(BOTAN_HAS_COMMONCRYPTO)
98 #include <botan/internal/commoncrypto.h>
103std::unique_ptr<BlockCipher>
105 const std::string& provider)
107#if defined(BOTAN_HAS_COMMONCRYPTO)
125#if defined(BOTAN_HAS_AES)
126 if(algo ==
"AES-128")
128 return std::unique_ptr<BlockCipher>(
new AES_128);
131 if(algo ==
"AES-192")
133 return std::unique_ptr<BlockCipher>(
new AES_192);
136 if(algo ==
"AES-256")
138 return std::unique_ptr<BlockCipher>(
new AES_256);
142#if defined(BOTAN_HAS_ARIA)
143 if(algo ==
"ARIA-128")
145 return std::unique_ptr<BlockCipher>(
new ARIA_128);
148 if(algo ==
"ARIA-192")
150 return std::unique_ptr<BlockCipher>(
new ARIA_192);
153 if(algo ==
"ARIA-256")
155 return std::unique_ptr<BlockCipher>(
new ARIA_256);
159#if defined(BOTAN_HAS_SERPENT)
160 if(algo ==
"Serpent")
162 return std::unique_ptr<BlockCipher>(
new Serpent);
166#if defined(BOTAN_HAS_SHACAL2)
167 if(algo ==
"SHACAL2")
169 return std::unique_ptr<BlockCipher>(
new SHACAL2);
173#if defined(BOTAN_HAS_TWOFISH)
174 if(algo ==
"Twofish")
176 return std::unique_ptr<BlockCipher>(
new Twofish);
180#if defined(BOTAN_HAS_THREEFISH_512)
181 if(algo ==
"Threefish-512")
187#if defined(BOTAN_HAS_BLOWFISH)
188 if(algo ==
"Blowfish")
190 return std::unique_ptr<BlockCipher>(
new Blowfish);
194#if defined(BOTAN_HAS_CAMELLIA)
195 if(algo ==
"Camellia-128")
200 if(algo ==
"Camellia-192")
205 if(algo ==
"Camellia-256")
211#if defined(BOTAN_HAS_DES)
214 return std::unique_ptr<BlockCipher>(
new DES);
219 return std::unique_ptr<BlockCipher>(
new DESX);
222 if(algo ==
"TripleDES" || algo ==
"3DES" || algo ==
"DES-EDE")
224 return std::unique_ptr<BlockCipher>(
new TripleDES);
228#if defined(BOTAN_HAS_NOEKEON)
229 if(algo ==
"Noekeon")
231 return std::unique_ptr<BlockCipher>(
new Noekeon);
235#if defined(BOTAN_HAS_CAST_128)
236 if(algo ==
"CAST-128" || algo ==
"CAST5")
238 return std::unique_ptr<BlockCipher>(
new CAST_128);
242#if defined(BOTAN_HAS_CAST_256)
243 if(algo ==
"CAST-256")
245 return std::unique_ptr<BlockCipher>(
new CAST_256);
249#if defined(BOTAN_HAS_IDEA)
252 return std::unique_ptr<BlockCipher>(
new IDEA);
256#if defined(BOTAN_HAS_KASUMI)
259 return std::unique_ptr<BlockCipher>(
new KASUMI);
263#if defined(BOTAN_HAS_MISTY1)
266 return std::unique_ptr<BlockCipher>(
new MISTY1);
270#if defined(BOTAN_HAS_SEED)
273 return std::unique_ptr<BlockCipher>(
new SEED);
277#if defined(BOTAN_HAS_SM4)
280 return std::unique_ptr<BlockCipher>(
new SM4);
284#if defined(BOTAN_HAS_XTEA)
287 return std::unique_ptr<BlockCipher>(
new XTEA);
293#if defined(BOTAN_HAS_GOST_28147_89)
296 return std::unique_ptr<BlockCipher>(
new GOST_28147_89(req.
arg(0,
"R3411_94_TestParam")));
300#if defined(BOTAN_HAS_CASCADE)
307 return std::unique_ptr<BlockCipher>(
new Cascade_Cipher(c1.release(), c2.release()));
311#if defined(BOTAN_HAS_LION)
320 return std::unique_ptr<BlockCipher>(
new Lion(
hash.release(), stream.release(),
block_size));
332std::unique_ptr<BlockCipher>
334 const std::string& provider)
345 return probe_providers_of<BlockCipher>(algo, {
"base",
"openssl",
"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)