Botan 1.10.17

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 187 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.

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

References Botan::SCAN_Name::algo_name().

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

## ◆ find_mac()

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

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
| virtual inherited

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().

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
| ) |  |
| virtual inherited

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.

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.

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.

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.

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.

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.

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

## ◆ provider_name()

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

Return the provider name ("openssl")

Implements Botan::Engine.

Definition at line 24 of file openssl_engine.h.

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