blob: 668ce6c5d63b76f6b0f04076b017db9f9b438b92 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
|
/*************************************************
* Cipher Lookup *
* (C) 1999-2007 Jack Lloyd *
*************************************************/
#include <botan/def_eng.h>
#include <botan/lookup.h>
#include <botan/scan_name.h>
#include <memory>
#if defined(BOTAN_HAS_AES)
#include <botan/aes.h>
#endif
#if defined(BOTAN_HAS_BLOWFISH)
#include <botan/blowfish.h>
#endif
#if defined(BOTAN_HAS_CAST)
#include <botan/cast128.h>
#include <botan/cast256.h>
#endif
#if defined(BOTAN_HAS_DES)
#include <botan/des.h>
#include <botan/desx.h>
#endif
#if defined(BOTAN_HAS_GOST)
#include <botan/gost.h>
#endif
#if defined(BOTAN_HAS_IDEA)
#include <botan/idea.h>
#endif
#if defined(BOTAN_HAS_KASUMI)
#include <botan/kasumi.h>
#endif
#if defined(BOTAN_HAS_LION)
#include <botan/lion.h>
#endif
#if defined(BOTAN_HAS_LUBY_RACKOFF)
#include <botan/lubyrack.h>
#endif
#if defined(BOTAN_HAS_MARS)
#include <botan/mars.h>
#endif
#if defined(BOTAN_HAS_MISTY1)
#include <botan/misty1.h>
#endif
#if defined(BOTAN_HAS_NOEKEON)
#include <botan/noekeon.h>
#endif
#if defined(BOTAN_HAS_RC2)
#include <botan/rc2.h>
#endif
#if defined(BOTAN_HAS_RC5)
#include <botan/rc5.h>
#endif
#if defined(BOTAN_HAS_RC6)
#include <botan/rc6.h>
#endif
#if defined(BOTAN_HAS_SAFER)
#include <botan/safer_sk.h>
#endif
#if defined(BOTAN_HAS_SEED)
#include <botan/seed.h>
#endif
#if defined(BOTAN_HAS_SERPENT)
#include <botan/serpent.h>
#endif
#if defined(BOTAN_HAS_SERPENT_IA32)
#include <botan/serp_ia32.h>
#endif
#if defined(BOTAN_HAS_SKIPJACK)
#include <botan/skipjack.h>
#endif
#if defined(BOTAN_HAS_SQUARE)
#include <botan/square.h>
#endif
#if defined(BOTAN_HAS_TEA)
#include <botan/tea.h>
#endif
#if defined(BOTAN_HAS_TWOFISH)
#include <botan/twofish.h>
#endif
#if defined(BOTAN_HAS_XTEA)
#include <botan/xtea.h>
#endif
#if defined(BOTAN_HAS_ARC4)
#include <botan/arc4.h>
#endif
#if defined(BOTAN_HAS_SALSA20)
#include <botan/salsa20.h>
#endif
#if defined(BOTAN_HAS_TURING)
#include <botan/turing.h>
#endif
#if defined(BOTAN_HAS_WID_WAKE)
#include <botan/wid_wake.h>
#endif
#if defined(BOTAN_HAS_CIPHER_MODE_PADDING)
#include <botan/mode_pad.h>
#endif
namespace Botan {
/*************************************************
* Look for an algorithm with this name *
*************************************************/
BlockCipher*
Default_Engine::find_block_cipher(const std::string& algo_spec) const
{
SCAN_Name request(algo_spec);
#if defined(BOTAN_HAS_AES)
if(request.algo_name() == "AES")
return new AES;
if(request.algo_name() == "AES-128")
return new AES_128;
if(request.algo_name() == "AES-192")
return new AES_192;
if(request.algo_name() == "AES-256")
return new AES_256;
#endif
#if defined(BOTAN_HAS_BLOWFISH)
if(request.algo_name() == "Blowfish")
return new Blowfish;
#endif
#if defined(BOTAN_HAS_CAST)
if(request.algo_name() == "CAST-128")
return new CAST_128;
if(request.algo_name() == "CAST-256")
return new CAST_256;
#endif
#if defined(BOTAN_HAS_DES)
if(request.algo_name() == "DES")
return new DES;
if(request.algo_name() == "DESX")
return new DESX;
if(request.algo_name() == "TripleDES")
return new TripleDES;
#endif
#if defined(BOTAN_HAS_GOST)
if(request.algo_name() == "GOST")
return new GOST;
#endif
#if defined(BOTAN_HAS_IDEA)
if(request.algo_name() == "IDEA")
return new IDEA;
#endif
#if defined(BOTAN_HAS_KASUMI)
if(request.algo_name() == "KASUMI")
return new KASUMI;
#endif
#if defined(BOTAN_HAS_MARS)
if(request.algo_name() == "MARS")
return new MARS;
#endif
#if defined(BOTAN_HAS_MISTY1)
if(request.algo_name() == "MISTY1")
return new MISTY1(request.argument_as_u32bit(0, 8));
#endif
#if defined(BOTAN_HAS_NOEKEON)
if(request.algo_name() == "Noekeon")
return new Noekeon;
#endif
#if defined(BOTAN_HAS_RC2)
if(request.algo_name() == "RC2")
return new RC2;
#endif
#if defined(BOTAN_HAS_RC5)
if(request.algo_name() == "RC5")
return new RC5(request.argument_as_u32bit(0, 12));
#endif
#if defined(BOTAN_HAS_RC6)
if(request.algo_name() == "RC6")
return new RC6;
#endif
#if defined(BOTAN_HAS_SAFER)
if(request.algo_name() == "SAFER-SK")
return new SAFER_SK(request.argument_as_u32bit(0, 10));
#endif
#if defined(BOTAN_HAS_SEED)
if(request.algo_name() == "SEED")
return new SEED;
#endif
#if defined(BOTAN_HAS_SERPENT_IA32)
if(request.algo_name() == "Serpent")
return new Serpent_IA32;
#elif defined(BOTAN_HAS_SERPENT)
if(request.algo_name() == "Serpent")
return new Serpent;
#endif
#if defined(BOTAN_HAS_SKIPJACK)
if(request.algo_name() == "Skipjack")
return new Skipjack;
#endif
#if defined(BOTAN_HAS_SQUARE)
if(request.algo_name() == "Square")
return new Square;
#endif
#if defined(BOTAN_HAS_TEA)
if(request.algo_name() == "TEA")
return new TEA;
#endif
#if defined(BOTAN_HAS_TWOFISH)
if(request.algo_name() == "Twofish")
return new Twofish;
#endif
#if defined(BOTAN_HAS_XTEA)
if(request.algo_name() == "XTEA")
return new XTEA;
#endif
#if defined(BOTAN_HAS_LUBY_RACKOFF)
if(request.algo_name() == "Luby-Rackoff" && request.arg_count() == 1)
{
HashFunction* hash = get_hash(request.argument(0));
if(hash)
return new LubyRackoff(hash);
}
#endif
#if defined(BOTAN_HAS_LION)
if(request.algo_name() == "Lion" &&
(request.arg_count() == 2 || request.arg_count() == 3))
{
const u32bit block_size = request.argument_as_u32bit(2, 1024);
std::auto_ptr<HashFunction> hash(get_hash(request.argument(0)));
if(!hash.get())
return 0;
std::auto_ptr<StreamCipher> sc(get_stream_cipher(request.argument(1)));
if(!sc.get())
return 0;
return new Lion(hash.release(), sc.release(), block_size);
}
#endif
return 0;
}
/*************************************************
* Look for an algorithm with this name *
*************************************************/
StreamCipher*
Default_Engine::find_stream_cipher(const std::string& algo_spec) const
{
SCAN_Name request(algo_spec);
#if defined(BOTAN_HAS_ARC4)
if(request.algo_name() == "ARC4")
return new ARC4(request.argument_as_u32bit(0, 0));
if(request.algo_name() == "RC4_drop")
return new ARC4(768);
#endif
#if defined(BOTAN_HAS_SALSA20)
if(request.algo_name() == "Salsa20")
return new Salsa20;
#endif
#if defined(BOTAN_HAS_TURING)
if(request.algo_name() == "Turing")
return new Turing;
#endif
#if defined(BOTAN_HAS_WID_WAKE)
if(request.algo_name() == "WiderWake4+1-BE")
return new WiderWake_41_BE;
#endif
return 0;
}
/*************************************************
* Look for an algorithm with this name *
*************************************************/
BlockCipherModePaddingMethod*
Default_Engine::find_bc_pad(const std::string& algo_spec) const
{
SCAN_Name request(algo_spec);
#if defined(BOTAN_HAS_CIPHER_MODE_PADDING)
if(request.algo_name() == "PKCS7")
return new PKCS7_Padding;
if(request.algo_name() == "OneAndZeros")
return new OneAndZeros_Padding;
if(request.algo_name() == "X9.23")
return new ANSI_X923_Padding;
if(request.algo_name() == "NoPadding")
return new Null_Padding;
#endif
return 0;
}
}
|