Botan 1.10.17

Public Member Functions | List of all members
Botan::Core_Engine Class Reference

`#include <core_engine.h>`

Inheritance diagram for Botan::Core_Engine:

## Public Member Functions
BlockCipher * | find_block_cipher (const SCAN_Name &, Algorithm_Factory &) const
HashFunction * | find_hash (const SCAN_Name &request, Algorithm_Factory &) const
MessageAuthenticationCode * | find_mac (const SCAN_Name &request, Algorithm_Factory &) const
PBKDF * | find_pbkdf (const SCAN_Name &algo_spec, Algorithm_Factory &af) const
StreamCipher * | find_stream_cipher (const SCAN_Name &, Algorithm_Factory &) const
Keyed_Filter * | get_cipher (const std::string &, Cipher_Dir, Algorithm_Factory &)
PK_Ops::Decryption * | get_decryption_op (const Private_Key &key) const
PK_Ops::Encryption * | get_encryption_op (const Public_Key &key) const
PK_Ops::Key_Agreement * | get_key_agreement_op (const Private_Key &key) const
PK_Ops::Signature * | get_signature_op (const Private_Key &key) const
PK_Ops::Verification * | get_verify_op (const Public_Key &key) const
Modular_Exponentiator * | mod_exp (const BigInt &n, Power_Mod::Usage_Hints) const
std::string | provider_name () const

## Detailed Description

Core Engine

Definition at line 18 of file core_engine.h.

## Member Function Documentation

## ◆ find_block_cipher()

BlockCipher * Botan::Core_Engine::find_block_cipher | ( | const SCAN_Name & | algo_spec,
|  | Algorithm_Factory & | af
| ) |  | const
| virtual

Parameters

  algo_spec | the algorithm name/specification
  af | an algorithm factory object

Returns
  newly allocated object, or NULL

Reimplemented from Botan::Engine.

Definition at line 119 of file lookup_block.cpp.

References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_as_integer(), Botan::SCAN_Name::arg_count(), Botan::SCAN_Name::arg_count_between(), Botan::HashFunction::clone(), Botan::BlockCipher::clone(), Botan::Algorithm_Factory::prototype_block_cipher(), and Botan::Algorithm_Factory::prototype_hash_function().

121 {
122
123 #if defined(BOTAN_HAS_AES)
124 if(request.algo_name() == "AES-128")
125 return new AES_128;
126 if(request.algo_name() == "AES-192")
127 return new AES_192;
128 if(request.algo_name() == "AES-256")
129 return new AES_256;
130 #endif
131
132 #if defined(BOTAN_HAS_BLOWFISH)
133 if(request.algo_name() == "Blowfish")
134 return new Blowfish;
135 #endif
136
137 #if defined(BOTAN_HAS_CAMELLIA)
138 if(request.algo_name() == "Camellia-128")
139 return new Camellia_128;
140 if(request.algo_name() == "Camellia-192")
141 return new Camellia_192;
142 if(request.algo_name() == "Camellia-256")
143 return new Camellia_256;
144 #endif
145
146 #if defined(BOTAN_HAS_CAST)
147 if(request.algo_name() == "CAST-128")
148 return new CAST_128;
149 if(request.algo_name() == "CAST-256")
150 return new CAST_256;
151 #endif
152
153 #if defined(BOTAN_HAS_DES)
154 if(request.algo_name() == "DES")
155 return new DES;
156 if(request.algo_name() == "DESX")
157 return new DESX;
158 if(request.algo_name() == "TripleDES")
159 return new TripleDES;
160 #endif
161
162 #if defined(BOTAN_HAS_GOST_28147_89)
163 if(request.algo_name() == "GOST-28147-89")
164 return new GOST_28147_89(request.arg(0, "R3411_94_TestParam"));
165 #endif
166
167 #if defined(BOTAN_HAS_IDEA)
168 if(request.algo_name() == "IDEA")
169 return new IDEA;
170 #endif
171
172 #if defined(BOTAN_HAS_KASUMI)
173 if(request.algo_name() == "KASUMI")
174 return new KASUMI;
175 #endif
176
177 #if defined(BOTAN_HAS_MARS)
178 if(request.algo_name() == "MARS")
179 return new MARS;
180 #endif
181
182 #if defined(BOTAN_HAS_MISTY1)
183 if(request.algo_name() == "MISTY1")
184 return new MISTY1(request.arg_as_integer(0, 8));
185 #endif
186
187 #if defined(BOTAN_HAS_NOEKEON)
188 if(request.algo_name() == "Noekeon")
189 return new Noekeon;
190 #endif
191
192 #if defined(BOTAN_HAS_RC2)
193 if(request.algo_name() == "RC2")
194 return new RC2;
195 #endif
196
197 #if defined(BOTAN_HAS_RC5)
198 if(request.algo_name() == "RC5")
199 return new RC5(request.arg_as_integer(0, 12));
200 #endif
201
202 #if defined(BOTAN_HAS_RC6)
203 if(request.algo_name() == "RC6")
204 return new RC6;
205 #endif
206
207 #if defined(BOTAN_HAS_SAFER)
208 if(request.algo_name() == "SAFER-SK")
209 return new SAFER_SK(request.arg_as_integer(0, 10));
210 #endif
211
212 #if defined(BOTAN_HAS_SEED)
213 if(request.algo_name() == "SEED")
214 return new SEED;
215 #endif
216
217 #if defined(BOTAN_HAS_SERPENT)
218 if(request.algo_name() == "Serpent")
219 return new Serpent;
220 #endif
221
222 #if defined(BOTAN_HAS_SKIPJACK)
223 if(request.algo_name() == "Skipjack")
224 return new Skipjack;
225 #endif
226
227 #if defined(BOTAN_HAS_SQUARE)
228 if(request.algo_name() == "Square")
229 return new Square;
230 #endif
231
232 #if defined(BOTAN_HAS_TEA)
233 if(request.algo_name() == "TEA")
234 return new TEA;
235 #endif
236
237 #if defined(BOTAN_HAS_TWOFISH)
238 if(request.algo_name() == "Twofish")
239 return new Twofish;
240 #endif
241
242 #if defined(BOTAN_HAS_XTEA)
243 if(request.algo_name() == "XTEA")
244 return new XTEA;
245 #endif
246
247 #if defined(BOTAN_HAS_LUBY_RACKOFF)
248 if(request.algo_name() == "Luby-Rackoff" && request.arg_count() == 1)
249 {
250 const HashFunction* hash = af.prototype_hash_function(request.arg(0));
251
252 if(hash)
253 return new LubyRackoff(hash->clone());
254 }
255 #endif
256
257 #if defined(BOTAN_HAS_CASCADE)
258 if(request.algo_name() == "Cascade" && request.arg_count() == 2)
259 {
260 const BlockCipher* c1 = af.prototype_block_cipher(request.arg(0));
261 const BlockCipher* c2 = af.prototype_block_cipher(request.arg(1));
262
263 if(c1 && c2)
264 return new Cascade_Cipher(c1->clone(), c2->clone());
265 }
266 #endif
267
268 #if defined(BOTAN_HAS_LION)
269 if(request.algo_name() == "Lion" && request.arg_count_between(2, 3))
270 {
271 const size_t block_size = request.arg_as_integer(2, 1024);
272
273 const HashFunction* hash =
274 af.prototype_hash_function(request.arg(0));
275
276 const StreamCipher* stream_cipher =
277 af.prototype_stream_cipher(request.arg(1));
278
279 if(!hash || !stream_cipher)
280 return 0;
281
282 return new Lion(hash->clone(), stream_cipher->clone(), block_size);
283 }
284 #endif
285
286 return 0;
287 }

## ◆ find_hash()

HashFunction * Botan::Core_Engine::find_hash | ( | const SCAN_Name & | algo_spec,
|  | Algorithm_Factory & | af
| ) |  | const
| virtual

Parameters

  algo_spec | the algorithm name/specification
  af | an algorithm factory object

Returns
  newly allocated object, or NULL

Reimplemented from Botan::Engine.

Definition at line 98 of file lookup_hash.cpp.

References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_as_integer(), Botan::SCAN_Name::arg_count(), Botan::HashFunction::clone(), and Botan::Algorithm_Factory::prototype_hash_function().

100 {
101 #if defined(BOTAN_HAS_ADLER32)
102 if(request.algo_name() == "Adler32")
103 return new Adler32;
104 #endif
105
106 #if defined(BOTAN_HAS_CRC24)
107 if(request.algo_name() == "CRC24")
108 return new CRC24;
109 #endif
110
111 #if defined(BOTAN_HAS_CRC32)
112 if(request.algo_name() == "CRC32")
113 return new CRC32;
114 #endif
115
116 #if defined(BOTAN_HAS_BMW_512)
117 if(request.algo_name() == "BMW-512")
118 return new BMW_512;
119 #endif
120
121 #if defined(BOTAN_HAS_GOST_34_11)
122 if(request.algo_name() == "GOST-34.11")
123 return new GOST_34_11;
124 #endif
125
126 #if defined(BOTAN_HAS_HAS_160)
127 if(request.algo_name() == "HAS-160")
128 return new HAS_160;
129 #endif
130
131 #if defined(BOTAN_HAS_KECCAK)
132 if(request.algo_name() == "Keccak-1600")
133 return new Keccak_1600(request.arg_as_integer(0, 512));
134 #endif
135
136 #if defined(BOTAN_HAS_MD2)
137 if(request.algo_name() == "MD2")
138 return new MD2;
139 #endif
140
141 #if defined(BOTAN_HAS_MD4)
142 if(request.algo_name() == "MD4")
143 return new MD4;
144 #endif
145
146 #if defined(BOTAN_HAS_MD5)
147 if(request.algo_name() == "MD5")
148 return new MD5;
149 #endif
150
151 #if defined(BOTAN_HAS_RIPEMD_128)
152 if(request.algo_name() == "RIPEMD-128")
153 return new RIPEMD_128;
154 #endif
155
156 #if defined(BOTAN_HAS_RIPEMD_160)
157 if(request.algo_name() == "RIPEMD-160")
158 return new RIPEMD_160;
159 #endif
160
161 #if defined(BOTAN_HAS_SHA1)
162 if(request.algo_name() == "SHA-160")
163 return new SHA_160;
164 #endif
165
166 #if defined(BOTAN_HAS_SHA2_32)
167 if(request.algo_name() == "SHA-224")
168 return new SHA_224;
169 if(request.algo_name() == "SHA-256")
170 return new SHA_256;
171 #endif
172
173 #if defined(BOTAN_HAS_SHA2_64)
174 if(request.algo_name() == "SHA-384")
175 return new SHA_384;
176 if(request.algo_name() == "SHA-512")
177 return new SHA_512;
178 #endif
179
180 #if defined(BOTAN_HAS_TIGER)
181 if(request.algo_name() == "Tiger")
182 return new Tiger(request.arg_as_integer(0, 24), // hash output
183 request.arg_as_integer(1, 3)); // # passes
184 #endif
185
186 #if defined(BOTAN_HAS_SKEIN_512)
187 if(request.algo_name() == "Skein-512")
188 return new Skein_512(request.arg_as_integer(0, 512),
189 request.arg(1, ""));
190 #endif
191
192 #if defined(BOTAN_HAS_WHIRLPOOL)
193 if(request.algo_name() == "Whirlpool")
194 return new Whirlpool;
195 #endif
196
197 #if defined(BOTAN_HAS_COMB4P)
198 if(request.algo_name() == "Comb4P" && request.arg_count() == 2)
199 {
200 const HashFunction* h1 = af.prototype_hash_function(request.arg(0));
201 const HashFunction* h2 = af.prototype_hash_function(request.arg(1));
202
203 if(h1 && h2)
204 return new Comb4P(h1->clone(), h2->clone());
205 }
206 #endif
207
208 #if defined(BOTAN_HAS_PARALLEL_HASH)
209
210 if(request.algo_name() == "Parallel")
211 {
212 std::vector<const HashFunction*> hash_prototypes;
213
214 /* First pass, just get the prototypes (no memory allocation). Then
215 if all were found, replace each prototype with a newly created clone
216 */
217 for(size_t i = 0; i != request.arg_count(); ++i)
218 {
219 const HashFunction* hash = af.prototype_hash_function(request.arg(i));
220 if(!hash)
221 return 0;
222
223 hash_prototypes.push_back(hash);
224 }
225
226 std::vector<HashFunction*> hashes;
227 for(size_t i = 0; i != hash_prototypes.size(); ++i)
228 hashes.push_back(hash_prototypes[i]->clone());
229
230 return new Parallel(hashes);
231 }
232
233 #endif
234
235 return 0;
236 }

## ◆ find_mac()

MessageAuthenticationCode * Botan::Core_Engine::find_mac | ( | const SCAN_Name & | algo_spec,
|  | Algorithm_Factory & | af
| ) |  | const
| virtual

Parameters

  algo_spec | the algorithm name/specification
  af | an algorithm factory object

Returns
  newly allocated object, or NULL

Reimplemented from Botan::Engine.

Definition at line 38 of file lookup_mac.cpp.

References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_count(), Botan::Algorithm_Factory::make_block_cipher(), and Botan::Algorithm_Factory::make_hash_function().

40 {
41
42 #if defined(BOTAN_HAS_CBC_MAC)
43 if(request.algo_name() == "CBC-MAC" && request.arg_count() == 1)
44 return new CBC_MAC(af.make_block_cipher(request.arg(0)));
45 #endif
46
47 #if defined(BOTAN_HAS_CMAC)
48 if(request.algo_name() == "CMAC" && request.arg_count() == 1)
49 return new CMAC(af.make_block_cipher(request.arg(0)));
50 #endif
51
52 #if defined(BOTAN_HAS_HMAC)
53 if(request.algo_name() == "HMAC" && request.arg_count() == 1)
54 return new HMAC(af.make_hash_function(request.arg(0)));
55 #endif
56
57 #if defined(BOTAN_HAS_SSL3_MAC)
58 if(request.algo_name() == "SSL3-MAC" && request.arg_count() == 1)
59 return new SSL3_MAC(af.make_hash_function(request.arg(0)));
60 #endif
61
62 #if defined(BOTAN_HAS_ANSI_X919_MAC)
63 if(request.algo_name() == "X9.19-MAC" && request.arg_count() == 0)
64 return new ANSI_X919_MAC(af.make_block_cipher("DES"));
65 #endif
66
67 return 0;
68 }

## ◆ find_pbkdf()

PBKDF * Botan::Core_Engine::find_pbkdf | ( | const SCAN_Name & | algo_spec,
|  | Algorithm_Factory & | af
| ) |  | const
| virtual

Parameters

  algo_spec | the algorithm name/specification
  af | an algorithm factory object

Returns
  newly allocated object, or NULL

Reimplemented from Botan::Engine.

Definition at line 26 of file lookup_pbkdf.cpp.

References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_count(), Botan::Algorithm_Factory::make_hash_function(), Botan::Algorithm_Factory::make_mac(), and Botan::Algorithm_Factory::prototype_mac().

28 {
29 #if defined(BOTAN_HAS_PBKDF1)
30 if(algo_spec.algo_name() == "PBKDF1" && algo_spec.arg_count() == 1)
31 return new PKCS5_PBKDF1(af.make_hash_function(algo_spec.arg(0)));
32 #endif
33
34 #if defined(BOTAN_HAS_PBKDF2)
35 if(algo_spec.algo_name() == "PBKDF2" && algo_spec.arg_count() == 1)
36 {
37 if(const MessageAuthenticationCode* mac_proto = af.prototype_mac(algo_spec.arg(0)))
38 return new PKCS5_PBKDF2(mac_proto->clone());
39
40 return new PKCS5_PBKDF2(af.make_mac("HMAC(" + algo_spec.arg(0) + ")"));
41 }
42 #endif
43
44 #if defined(BOTAN_HAS_PGPS2K)
45 if(algo_spec.algo_name() == "OpenPGP-S2K" && algo_spec.arg_count() == 1)
46 return new OpenPGP_S2K(af.make_hash_function(algo_spec.arg(0)));
47 #endif
48
49 return 0;
50 }

## ◆ find_stream_cipher()

StreamCipher * Botan::Core_Engine::find_stream_cipher | ( | const SCAN_Name & | algo_spec,
|  | Algorithm_Factory & | af
| ) |  | const
| virtual

Parameters

  algo_spec | the algorithm name/specification
  af | an algorithm factory object

Returns
  newly allocated object, or NULL

Reimplemented from Botan::Engine.

Definition at line 33 of file lookup_stream.cpp.

References Botan::SCAN_Name::algo_name(), and Botan::SCAN_Name::arg_as_integer().

35 {
36 #if defined(BOTAN_HAS_ARC4)
37 if(request.algo_name() == "ARC4")
38 return new ARC4(request.arg_as_integer(0, 0));
39 if(request.algo_name() == "RC4_drop")
40 return new ARC4(768);
41 #endif
42
43 #if defined(BOTAN_HAS_SALSA20)
44 if(request.algo_name() == "Salsa20")
45 return new Salsa20;
46 #endif
47
48 #if defined(BOTAN_HAS_TURING)
49 if(request.algo_name() == "Turing")
50 return new Turing;
51 #endif
52
53 #if defined(BOTAN_HAS_WID_WAKE)
54 if(request.algo_name() == "WiderWake4+1-BE")
55 return new WiderWake_41_BE;
56 #endif
57
58 return 0;
59 }

## ◆ get_cipher()

Keyed_Filter * Botan::Core_Engine::get_cipher | ( | const std::string & | algo_spec,
|  | Cipher_Dir | dir,
|  | Algorithm_Factory & | af
| ) |  |
| virtual

Return a new cipher object

Parameters

  algo_spec | the algorithm name/specification
  dir | specifies if encryption or decryption is desired
  af | an algorithm factory object

Returns
  newly allocated object, or NULL

Reimplemented from Botan::Engine.

Definition at line 181 of file core_modes.cpp.

References Botan::split_on().

184 {
185 std::vector<std::string> algo_parts = split_on(algo_spec, '/');
186 if(algo_parts.empty())
187 throw Invalid_Algorithm_Name(algo_spec);
188
189 const std::string cipher_name = algo_parts[0];
190
191 // check if it is a stream cipher first (easy case)
192 const StreamCipher* stream_cipher = af.prototype_stream_cipher(cipher_name);
193 if(stream_cipher)
194 return new StreamCipher_Filter(stream_cipher->clone());
195
196 const BlockCipher* block_cipher = af.prototype_block_cipher(cipher_name);
197 if(!block_cipher)
198 return 0;
199
200 if(algo_parts.size() >= 4)
201 return 0; // 4 part mode, not something we know about
202
203 if(algo_parts.size() < 2)
204 throw Lookup_Error("Cipher specification '" + algo_spec +
205 "' is missing mode identifier");
206
207 std::string mode = algo_parts[1];
208
209 std::string padding;
210 if(algo_parts.size() == 3)
211 padding = algo_parts[2];
212 else
213 padding = (mode == "CBC") ? "PKCS7" : "NoPadding";
214
215 if(mode == "ECB" && padding == "CTS")
216 return 0;
217 else if((mode != "CBC" && mode != "ECB") && padding != "NoPadding")
218 throw Invalid_Algorithm_Name(algo_spec);
219
220 Keyed_Filter* filt = get_cipher_mode(block_cipher, direction, mode, padding);
221 if(filt)
222 return filt;
223
224 throw Algorithm_Not_Found(cipher_name + "/" + mode + "/" + padding);
225 }
Botan::split_on
std::vector< std::string > split_on(const std::string &str, char delim)
Definition: parsing.cpp:152
Botan::get_cipher_mode
Keyed_Filter * get_cipher_mode(const BlockCipher *block_cipher, Cipher_Dir direction, const std::string &mode, const std::string &padding)
Definition: core_modes.cpp:77

## ◆ get_decryption_op()

PK_Ops::Decryption * Botan::Core_Engine::get_decryption_op | ( | const Private_Key & | key | ) | const
| virtual

Return a new operator object for this key, if possible

Parameters

  key | the key we want an operator for

Returns
  newly allocated operator object, or NULL

Reimplemented from Botan::Engine.

Definition at line 65 of file def_pk_ops.cpp.

66 {
67 #if defined(BOTAN_HAS_RSA)
68 if(const RSA_PrivateKey* s = dynamic_cast<const RSA_PrivateKey*>(&key))
69 return new RSA_Private_Operation(*s);
70 #endif
71
72 #if defined(BOTAN_HAS_ELGAMAL)
73 if(const ElGamal_PrivateKey* s = dynamic_cast<const ElGamal_PrivateKey*>(&key))
74 return new ElGamal_Decryption_Operation(*s);
75 #endif
76
77 return 0;
78 }

## ◆ get_encryption_op()

PK_Ops::Encryption * Botan::Core_Engine::get_encryption_op | ( | const Public_Key & | key | ) | const
| virtual

Return a new operator object for this key, if possible

Parameters

  key | the key we want an operator for

Returns
  newly allocated operator object, or NULL

Reimplemented from Botan::Engine.

Definition at line 49 of file def_pk_ops.cpp.

50 {
51 #if defined(BOTAN_HAS_RSA)
52 if(const RSA_PublicKey* s = dynamic_cast<const RSA_PublicKey*>(&key))
53 return new RSA_Public_Operation(*s);
54 #endif
55
56 #if defined(BOTAN_HAS_ELGAMAL)
57 if(const ElGamal_PublicKey* s = dynamic_cast<const ElGamal_PublicKey*>(&key))
58 return new ElGamal_Encryption_Operation(*s);
59 #endif
60
61 return 0;
62 }

## ◆ get_key_agreement_op()

PK_Ops::Key_Agreement * Botan::Core_Engine::get_key_agreement_op | ( | const Private_Key & | key | ) | const
| virtual

Return a new operator object for this key, if possible

Parameters

  key | the key we want an operator for

Returns
  newly allocated operator object, or NULL

Reimplemented from Botan::Engine.

Definition at line 81 of file def_pk_ops.cpp.

82 {
83 #if defined(BOTAN_HAS_DIFFIE_HELLMAN)
84 if(const DH_PrivateKey* dh = dynamic_cast<const DH_PrivateKey*>(&key))
85 return new DH_KA_Operation(*dh);
86 #endif
87
88 #if defined(BOTAN_HAS_ECDH)
89 if(const ECDH_PrivateKey* ecdh = dynamic_cast<const ECDH_PrivateKey*>(&key))
90 return new ECDH_KA_Operation(*ecdh);
91 #endif
92
93 return 0;
94 }

## ◆ get_signature_op()

PK_Ops::Signature * Botan::Core_Engine::get_signature_op | ( | const Private_Key & | key | ) | const
| virtual

Return a new operator object for this key, if possible

Parameters

  key | the key we want an operator for

Returns
  newly allocated operator object, or NULL

Reimplemented from Botan::Engine.

Definition at line 97 of file def_pk_ops.cpp.

98 {
99 #if defined(BOTAN_HAS_RSA)
100 if(const RSA_PrivateKey* s = dynamic_cast<const RSA_PrivateKey*>(&key))
101 return new RSA_Private_Operation(*s);
102 #endif
103
104 #if defined(BOTAN_HAS_RW)
105 if(const RW_PrivateKey* s = dynamic_cast<const RW_PrivateKey*>(&key))
106 return new RW_Signature_Operation(*s);
107 #endif
108
109 #if defined(BOTAN_HAS_DSA)
110 if(const DSA_PrivateKey* s = dynamic_cast<const DSA_PrivateKey*>(&key))
111 return new DSA_Signature_Operation(*s);
112 #endif
113
114 #if defined(BOTAN_HAS_ECDSA)
115 if(const ECDSA_PrivateKey* s = dynamic_cast<const ECDSA_PrivateKey*>(&key))
116 return new ECDSA_Signature_Operation(*s);
117 #endif
118
119 #if defined(BOTAN_HAS_GOST_34_10_2001)
120 if(const GOST_3410_PrivateKey* s =
121 dynamic_cast<const GOST_3410_PrivateKey*>(&key))
122 return new GOST_3410_Signature_Operation(*s);
123 #endif
124
125 #if defined(BOTAN_HAS_NYBERG_RUEPPEL)
126 if(const NR_PrivateKey* s = dynamic_cast<const NR_PrivateKey*>(&key))
127 return new NR_Signature_Operation(*s);
128 #endif
129
130 return 0;
131 }

## ◆ get_verify_op()

PK_Ops::Verification * Botan::Core_Engine::get_verify_op | ( | const Public_Key & | key | ) | const
| virtual

Return a new operator object for this key, if possible

Parameters

  key | the key we want an operator for

Returns
  newly allocated operator object, or NULL

Reimplemented from Botan::Engine.

Definition at line 134 of file def_pk_ops.cpp.

135 {
136 #if defined(BOTAN_HAS_RSA)
137 if(const RSA_PublicKey* s = dynamic_cast<const RSA_PublicKey*>(&key))
138 return new RSA_Public_Operation(*s);
139 #endif
140
141 #if defined(BOTAN_HAS_RW)
142 if(const RW_PublicKey* s = dynamic_cast<const RW_PublicKey*>(&key))
143 return new RW_Verification_Operation(*s);
144 #endif
145
146 #if defined(BOTAN_HAS_DSA)
147 if(const DSA_PublicKey* s = dynamic_cast<const DSA_PublicKey*>(&key))
148 return new DSA_Verification_Operation(*s);
149 #endif
150
151 #if defined(BOTAN_HAS_ECDSA)
152 if(const ECDSA_PublicKey* s = dynamic_cast<const ECDSA_PublicKey*>(&key))
153 return new ECDSA_Verification_Operation(*s);
154 #endif
155
156 #if defined(BOTAN_HAS_GOST_34_10_2001)
157 if(const GOST_3410_PublicKey* s =
158 dynamic_cast<const GOST_3410_PublicKey*>(&key))
159 return new GOST_3410_Verification_Operation(*s);
160 #endif
161
162 #if defined(BOTAN_HAS_NYBERG_RUEPPEL)
163 if(const NR_PublicKey* s = dynamic_cast<const NR_PublicKey*>(&key))
164 return new NR_Verification_Operation(*s);
165 #endif
166
167 return 0;
168 }

## ◆ mod_exp()

Modular_Exponentiator * Botan::Core_Engine::mod_exp | ( | const BigInt & | n,
|  | Power_Mod::Usage_Hints | hints
| ) |  | const
| virtual

Parameters

  n | the modulus
  hints | any use hints

Returns
  newly allocated object, or NULL

Reimplemented from Botan::Engine.

Definition at line 17 of file def_powm.cpp.

18 {
19 if(n.is_odd())
20 return new Montgomery_Exponentiator(n, hints);
21 return new Fixed_Window_Exponentiator(n, hints);
22 }

## ◆ provider_name()

std::string Botan::Core_Engine::provider_name | ( |  | ) | const
| inline virtual

Returns
  name of this engine

Implements Botan::Engine.

Definition at line 21 of file core_engine.h.

21 { return "core"; }

The documentation for this class was generated from the following files:

- src/engine/core_engine/core_engine.h
- src/engine/core_engine/core_modes.cpp
- src/engine/core_engine/def_pk_ops.cpp
- src/engine/core_engine/def_powm.cpp
- src/engine/core_engine/lookup_block.cpp
- src/engine/core_engine/lookup_hash.cpp
- src/engine/core_engine/lookup_mac.cpp
- src/engine/core_engine/lookup_pbkdf.cpp
- src/engine/core_engine/lookup_stream.cpp