Botan: Botan::OpenSSL_Engine Class Reference

Botan 1.10.16

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

## ◆ find_block_cipher()

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)

## ◆ find_hash()

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 }

## ◆ find_mac()

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 }

## ◆ find_pbkdf()

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 }

## ◆ find_stream_cipher()

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 82 of file ossl_arc4.cpp.

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

Referenced by provider_name().

84 {
85 #if !defined(OPENSSL_NO_RC4)
86 if(request.algo_name() == "ARC4")
87 return new ARC4_OpenSSL(request.arg_as_integer(0, 0));
88 if(request.algo_name() == "RC4_drop")
89 return new ARC4_OpenSSL(768);
90 #endif
91
92 return 0;
93 }

## ◆ get_cipher()

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 }

## ◆ get_decryption_op()

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 334 of file ossl_pk.cpp.

Referenced by provider_name().

335 {
336 #if defined(BOTAN_HAS_RSA)
337 if(const RSA_PrivateKey* s = dynamic_cast<const RSA_PrivateKey*>(&key))
338 return new OSSL_RSA_Private_Operation(*s);
339 #endif
340
341 return 0;
342 }

## ◆ get_encryption_op()

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 323 of file ossl_pk.cpp.

Referenced by provider_name().

324 {
325 #if defined(BOTAN_HAS_RSA)
326 if(const RSA_PublicKey* s = dynamic_cast<const RSA_PublicKey*>(&key))
327 return new OSSL_RSA_Public_Operation(*s);
328 #endif
329
330 return 0;
331 }

## ◆ get_key_agreement_op()

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 280 of file ossl_pk.cpp.

Referenced by provider_name().

281 {
282 #if defined(BOTAN_HAS_DIFFIE_HELLMAN)
283 if(const DH_PrivateKey* dh = dynamic_cast<const DH_PrivateKey*>(&key))
284 return new OSSL_DH_KA_Operation(*dh);
285 #endif
286
287 return 0;
288 }

## ◆ get_signature_op()

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 291 of file ossl_pk.cpp.

Referenced by provider_name().

292 {
293 #if defined(BOTAN_HAS_RSA)
294 if(const RSA_PrivateKey* s = dynamic_cast<const RSA_PrivateKey*>(&key))
295 return new OSSL_RSA_Private_Operation(*s);
296 #endif
297
298 #if defined(BOTAN_HAS_DSA)
299 if(const DSA_PrivateKey* s = dynamic_cast<const DSA_PrivateKey*>(&key))
300 return new OSSL_DSA_Signature_Operation(*s);
301 #endif
302
303 return 0;
304 }

## ◆ get_verify_op()

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 307 of file ossl_pk.cpp.

Referenced by provider_name().

308 {
309 #if defined(BOTAN_HAS_RSA)
310 if(const RSA_PublicKey* s = dynamic_cast<const RSA_PublicKey*>(&key))
311 return new OSSL_RSA_Public_Operation(*s);
312 #endif
313
314 #if defined(BOTAN_HAS_DSA)
315 if(const DSA_PublicKey* s = dynamic_cast<const DSA_PublicKey*>(&key))
316 return new OSSL_DSA_Verification_Operation(*s);
317 #endif
318
319 return 0;
320 }

## ◆ mod_exp()

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 }

## ◆ provider_name()

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