8 #include <botan/block_cipher.h>
9 #include <botan/scan_name.h>
11 #if defined(BOTAN_HAS_AES)
12 #include <botan/aes.h>
15 #if defined(BOTAN_HAS_BLOWFISH)
16 #include <botan/blowfish.h>
19 #if defined(BOTAN_HAS_CAMELLIA)
20 #include <botan/camellia.h>
23 #if defined(BOTAN_HAS_CAST)
24 #include <botan/cast128.h>
25 #include <botan/cast256.h>
28 #if defined(BOTAN_HAS_CASCADE)
29 #include <botan/cascade.h>
32 #if defined(BOTAN_HAS_DES)
33 #include <botan/des.h>
34 #include <botan/desx.h>
37 #if defined(BOTAN_HAS_GOST_28147_89)
38 #include <botan/gost_28147.h>
41 #if defined(BOTAN_HAS_IDEA)
42 #include <botan/idea.h>
45 #if defined(BOTAN_HAS_KASUMI)
46 #include <botan/kasumi.h>
49 #if defined(BOTAN_HAS_LION)
50 #include <botan/lion.h>
53 #if defined(BOTAN_HAS_MISTY1)
54 #include <botan/misty1.h>
57 #if defined(BOTAN_HAS_NOEKEON)
58 #include <botan/noekeon.h>
61 #if defined(BOTAN_HAS_SEED)
62 #include <botan/seed.h>
65 #if defined(BOTAN_HAS_SERPENT)
66 #include <botan/serpent.h>
69 #if defined(BOTAN_HAS_TWOFISH)
70 #include <botan/twofish.h>
73 #if defined(BOTAN_HAS_THREEFISH_512)
74 #include <botan/threefish.h>
77 #if defined(BOTAN_HAS_XTEA)
78 #include <botan/xtea.h>
81 #if defined(BOTAN_HAS_OPENSSL)
82 #include <botan/internal/openssl.h>
87 std::unique_ptr<BlockCipher>
89 const std::string& provider)
91 #if defined(BOTAN_HAS_OPENSSL)
92 if(provider.empty() || provider ==
"openssl")
107 if(provider.empty() ==
false && provider !=
"base")
110 #if defined(BOTAN_HAS_AES)
111 if(algo ==
"AES-128")
113 return std::unique_ptr<BlockCipher>(
new AES_128);
116 if(algo ==
"AES-192")
118 return std::unique_ptr<BlockCipher>(
new AES_192);
121 if(algo ==
"AES-256")
123 return std::unique_ptr<BlockCipher>(
new AES_256);
127 #if defined(BOTAN_HAS_SERPENT)
128 if(algo ==
"Serpent")
130 return std::unique_ptr<BlockCipher>(
new Serpent);
134 #if defined(BOTAN_HAS_TWOFISH)
135 if(algo ==
"Twofish")
137 return std::unique_ptr<BlockCipher>(
new Twofish);
141 #if defined(BOTAN_HAS_THREEFISH_512)
142 if(algo ==
"Threefish-512")
148 #if defined(BOTAN_HAS_BLOWFISH)
149 if(algo ==
"Blowfish")
151 return std::unique_ptr<BlockCipher>(
new Blowfish);
155 #if defined(BOTAN_HAS_CAMELLIA)
156 if(algo ==
"Camellia-128")
161 if(algo ==
"Camellia-192")
166 if(algo ==
"Camellia-256")
172 #if defined(BOTAN_HAS_DES)
175 return std::unique_ptr<BlockCipher>(
new DES);
180 return std::unique_ptr<BlockCipher>(
new DESX);
183 if(algo ==
"TripleDES" || algo ==
"3DES" || algo ==
"DES-EDE")
185 return std::unique_ptr<BlockCipher>(
new TripleDES);
189 #if defined(BOTAN_HAS_NOEKEON)
190 if(algo ==
"Noekeon")
192 return std::unique_ptr<BlockCipher>(
new Noekeon);
196 #if defined(BOTAN_HAS_CAST)
197 if(algo ==
"CAST-128" || algo ==
"CAST5")
199 return std::unique_ptr<BlockCipher>(
new CAST_128);
202 if(algo ==
"CAST-256")
204 return std::unique_ptr<BlockCipher>(
new CAST_256);
208 #if defined(BOTAN_HAS_IDEA)
211 return std::unique_ptr<BlockCipher>(
new IDEA);
215 #if defined(BOTAN_HAS_KASUMI)
218 return std::unique_ptr<BlockCipher>(
new KASUMI);
222 #if defined(BOTAN_HAS_MISTY1)
225 return std::unique_ptr<BlockCipher>(
new MISTY1);
229 #if defined(BOTAN_HAS_SEED)
232 return std::unique_ptr<BlockCipher>(
new SEED);
236 #if defined(BOTAN_HAS_XTEA)
239 return std::unique_ptr<BlockCipher>(
new XTEA);
245 #if defined(BOTAN_HAS_GOST_28147_89)
248 return std::unique_ptr<BlockCipher>(
new GOST_28147_89(req.
arg(0,
"R3411_94_TestParam")));
252 #if defined(BOTAN_HAS_CASCADE)
259 return std::unique_ptr<BlockCipher>(
new Cascade_Cipher(c1.release(), c2.release()));
263 #if defined(BOTAN_HAS_LION)
272 return std::unique_ptr<BlockCipher>(
new Lion(hash.release(), stream.release(),
block_size));
284 std::unique_ptr<BlockCipher>
286 const std::string& provider)
297 return probe_providers_of<BlockCipher>(algo, {
"base",
"openssl" });
std::string arg(size_t i) const
static std::vector< std::string > providers(const std::string &algo_spec)
bool arg_count_between(size_t lower, size_t upper) const
static std::unique_ptr< HashFunction > create(const std::string &algo_spec, const std::string &provider="")
size_t arg_as_integer(size_t i, size_t def_value) const
static std::unique_ptr< BlockCipher > create_or_throw(const std::string &algo_spec, const std::string &provider="")
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="")
std::unique_ptr< BlockCipher > make_openssl_block_cipher(const std::string &name)
virtual size_t block_size() const =0