Botan: Botan::OpenSSL_Engine Class Reference

Botan 1.10.12

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

`#include <openssl_engine.h>`

Inheritance diagram for Botan::OpenSSL_Engine:

## Public Member Functions
BlockCipher * | find_block_cipher (const SCAN_Name &, Algorithm_Factory &) const
HashFunction * | find_hash (const SCAN_Name &, Algorithm_Factory &) const
virtual MessageAuthenticationCode * | find_mac (const SCAN_Name &algo_spec, Algorithm_Factory &af) const
virtual PBKDF * | find_pbkdf (const SCAN_Name &algo_spec, Algorithm_Factory &af) const
StreamCipher * | find_stream_cipher (const SCAN_Name &, Algorithm_Factory &) const
virtual Keyed_Filter * | get_cipher (const std::string &algo_spec, Cipher_Dir dir, Algorithm_Factory &af)
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 &, Power_Mod::Usage_Hints) const
std::string | provider_name () const

## Detailed Description

OpenSSL Engine

Definition at line 18 of file openssl_engine.h.

## Member Function Documentation

BlockCipher * Botan::OpenSSL_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 183 of file ossl_bc.cpp.

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

Referenced by provider_name().

185 {
186 #define HANDLE_EVP_CIPHER(NAME, EVP) \
187 if(request.algo_name() == NAME && request.arg_count() == 0) \
188 return new EVP_BlockCipher(EVP, NAME);
189
190 #define HANDLE_EVP_CIPHER_KEYLEN(NAME, EVP, MIN, MAX, MOD) \
191 if(request.algo_name() == NAME && request.arg_count() == 0) \
192 return new EVP_BlockCipher(EVP, NAME, MIN, MAX, MOD);
193
194 #if !defined(OPENSSL_NO_AES)
195 /*
196 Using OpenSSL's AES causes crashes inside EVP on x86-64 with OpenSSL 0.9.8g
197 cause is unknown
198 */
199 HANDLE_EVP_CIPHER("AES-128", EVP_aes_128_ecb());
200 HANDLE_EVP_CIPHER("AES-192", EVP_aes_192_ecb());
201 HANDLE_EVP_CIPHER("AES-256", EVP_aes_256_ecb());
202 #endif
203
204 #if !defined(OPENSSL_NO_DES)
205 HANDLE_EVP_CIPHER("DES", EVP_des_ecb());
206 HANDLE_EVP_CIPHER_KEYLEN("TripleDES", EVP_des_ede3_ecb(), 16, 24, 8);
207 #endif
208
209 #if !defined(OPENSSL_NO_BF)
210 HANDLE_EVP_CIPHER_KEYLEN("Blowfish", EVP_bf_ecb(), 1, 56, 1);
211 #endif
212
213 #if !defined(OPENSSL_NO_CAST)
214 HANDLE_EVP_CIPHER_KEYLEN("CAST-128", EVP_cast5_ecb(), 1, 16, 1);
215 #endif
216
217 #if !defined(OPENSSL_NO_CAMELLIA)
218 HANDLE_EVP_CIPHER("Camellia-128", EVP_camellia_128_ecb());
219 HANDLE_EVP_CIPHER("Camellia-192", EVP_camellia_192_ecb());
220 HANDLE_EVP_CIPHER("Camellia-256", EVP_camellia_256_ecb());
221 #endif
222
223 #if !defined(OPENSSL_NO_RC2)
224 HANDLE_EVP_CIPHER_KEYLEN("RC2", EVP_rc2_ecb(), 1, 32, 1);
225 #endif
226
227 #if !defined(OPENSSL_NO_RC5) && 0
228 if(request.algo_name() == "RC5")
229 if(request.arg_as_integer(0, 12) == 12)
230 return new EVP_BlockCipher(EVP_rc5_32_12_16_ecb(),
231 "RC5(12)", 1, 32, 1);
232 #endif
233
234 #if !defined(OPENSSL_NO_IDEA) && 0
235 HANDLE_EVP_CIPHER("IDEA", EVP_idea_ecb());
236 #endif
237
238 #if !defined(OPENSSL_NO_SEED)
239 HANDLE_EVP_CIPHER("SEED", EVP_seed_ecb());
240 #endif
241
242 #undef HANDLE_EVP_CIPHER
243 #undef HANDLE_EVP_CIPHER_KEYLEN
244
245 return 0;
246 }
HANDLE_EVP_CIPHER_KEYLEN
#define HANDLE_EVP_CIPHER_KEYLEN(NAME, EVP, MIN, MAX, MOD)
HANDLE_EVP_CIPHER
#define HANDLE_EVP_CIPHER(NAME, EVP)

HashFunction * Botan::OpenSSL_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 106 of file ossl_md.cpp.

References Botan::SCAN_Name::algo_name().

Referenced by provider_name().

108 {
109 #if !defined(OPENSSL_NO_SHA)
110 if(request.algo_name() == "SHA-160")
111 return new EVP_HashFunction(EVP_sha1(), "SHA-160");
112 #endif
113
114 #if !defined(OPENSSL_NO_SHA256)
115 if(request.algo_name() == "SHA-224")
116 return new EVP_HashFunction(EVP_sha224(), "SHA-224");
117 if(request.algo_name() == "SHA-256")
118 return new EVP_HashFunction(EVP_sha256(), "SHA-256");
119 #endif
120
121 #if !defined(OPENSSL_NO_SHA512)
122 if(request.algo_name() == "SHA-384")
123 return new EVP_HashFunction(EVP_sha384(), "SHA-384");
124 if(request.algo_name() == "SHA-512")
125 return new EVP_HashFunction(EVP_sha512(), "SHA-512");
126 #endif
127
128 #if !defined(OPENSSL_NO_MD2)
129 if(request.algo_name() == "MD2")
130 return new EVP_HashFunction(EVP_md2(), "MD2");
131 #endif
132
133 #if !defined(OPENSSL_NO_MD4)
134 if(request.algo_name() == "MD4")
135 return new EVP_HashFunction(EVP_md4(), "MD4");
136 #endif
137
138 #if !defined(OPENSSL_NO_MD5)
139 if(request.algo_name() == "MD5")
140 return new EVP_HashFunction(EVP_md5(), "MD5");
141 #endif
142
143 #if !defined(OPENSSL_NO_RIPEMD)
144 if(request.algo_name() == "RIPEMD-160")
145 return new EVP_HashFunction(EVP_ripemd160(), "RIPEMD-160");
146 #endif
147
148 return 0;
149 }

MessageAuthenticationCode * Botan::Engine::find_mac | ( | const SCAN_Name & | algo_spec,
|  | Algorithm_Factory & | af
| ) |  | const
| virtualinherited

Parameters

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

Returns
  newly allocated object, or NULL

Reimplemented in Botan::Core_Engine, and Botan::Dynamically_Loaded_Engine.

Definition at line 34 of file engine.cpp.

36 {
37 return 0;
38 }

PBKDF * Botan::Engine::find_pbkdf | ( | const SCAN_Name & | algo_spec,
|  | Algorithm_Factory & | af
| ) |  | const
| virtualinherited

Parameters

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

Returns
  newly allocated object, or NULL

Reimplemented in Botan::Dynamically_Loaded_Engine, and Botan::Core_Engine.

Definition at line 41 of file engine.cpp.

43 {
44 return 0;
45 }

StreamCipher * Botan::OpenSSL_Engine::find_stream_cipher | ( | const SCAN_Name & | request,
|  | Algorithm_Factory & |
| ) |  | const
| virtual

Look for an OpenSSL-supported stream cipher (ARC4)

Reimplemented from Botan::Engine.

Definition at line 77 of file ossl_arc4.cpp.

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

Referenced by provider_name().

79 {
80 if(request.algo_name() == "ARC4")
81 return new ARC4_OpenSSL(request.arg_as_integer(0, 0));
82 if(request.algo_name() == "RC4_drop")
83 return new ARC4_OpenSSL(768);
84
85 return 0;
86 }

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

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 in Botan::Dynamically_Loaded_Engine, and Botan::Core_Engine.

Definition at line 54 of file engine.cpp.

57 {
58 return 0;
59 }

PK_Ops::Decryption * Botan::OpenSSL_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 328 of file ossl_pk.cpp.

Referenced by provider_name().

329 {
330 #if defined(BOTAN_HAS_RSA)
331 if(const RSA_PrivateKey* s = dynamic_cast<const RSA_PrivateKey*>(&key))
332 return new OSSL_RSA_Private_Operation(*s);
333 #endif
334
335 return 0;
336 }

PK_Ops::Encryption * Botan::OpenSSL_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 317 of file ossl_pk.cpp.

Referenced by provider_name().

318 {
319 #if defined(BOTAN_HAS_RSA)
320 if(const RSA_PublicKey* s = dynamic_cast<const RSA_PublicKey*>(&key))
321 return new OSSL_RSA_Public_Operation(*s);
322 #endif
323
324 return 0;
325 }

PK_Ops::Key_Agreement * Botan::OpenSSL_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 274 of file ossl_pk.cpp.

Referenced by provider_name().

275 {
276 #if defined(BOTAN_HAS_DIFFIE_HELLMAN)
277 if(const DH_PrivateKey* dh = dynamic_cast<const DH_PrivateKey*>(&key))
278 return new OSSL_DH_KA_Operation(*dh);
279 #endif
280
281 return 0;
282 }

PK_Ops::Signature * Botan::OpenSSL_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 285 of file ossl_pk.cpp.

Referenced by provider_name().

286 {
287 #if defined(BOTAN_HAS_RSA)
288 if(const RSA_PrivateKey* s = dynamic_cast<const RSA_PrivateKey*>(&key))
289 return new OSSL_RSA_Private_Operation(*s);
290 #endif
291
292 #if defined(BOTAN_HAS_DSA)
293 if(const DSA_PrivateKey* s = dynamic_cast<const DSA_PrivateKey*>(&key))
294 return new OSSL_DSA_Signature_Operation(*s);
295 #endif
296
297 return 0;
298 }

PK_Ops::Verification * Botan::OpenSSL_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 301 of file ossl_pk.cpp.

Referenced by provider_name().

302 {
303 #if defined(BOTAN_HAS_RSA)
304 if(const RSA_PublicKey* s = dynamic_cast<const RSA_PublicKey*>(&key))
305 return new OSSL_RSA_Public_Operation(*s);
306 #endif
307
308 #if defined(BOTAN_HAS_DSA)
309 if(const DSA_PublicKey* s = dynamic_cast<const DSA_PublicKey*>(&key))
310 return new OSSL_DSA_Verification_Operation(*s);
311 #endif
312
313 return 0;
314 }

Modular_Exponentiator * Botan::OpenSSL_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 48 of file bn_powm.cpp.

Referenced by provider_name().

50 {
51 return new OpenSSL_Modular_Exponentiator(n);
52 }

std::string Botan::OpenSSL_Engine::provider_name | ( |  | ) | const
| inlinevirtual

Return the provider name ("openssl")

Implements Botan::Engine.

Definition at line 24 of file openssl_engine.h.

References find_block_cipher(), find_hash(), find_stream_cipher(), get_decryption_op(), get_encryption_op(), get_key_agreement_op(), get_signature_op(), get_verify_op(), and mod_exp().

24 { return "openssl"; }

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

- src/engine/openssl/openssl_engine.h
- src/engine/openssl/bn_powm.cpp
- src/engine/openssl/ossl_arc4.cpp
- src/engine/openssl/ossl_bc.cpp
- src/engine/openssl/ossl_md.cpp
- src/engine/openssl/ossl_pk.cpp