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

#include <openssl_engine.h>

Inheritance diagram for Botan::OpenSSL_Engine:
Botan::Engine

Public Member Functions

BlockCipherfind_block_cipher (const SCAN_Name &, Algorithm_Factory &) const
 
HashFunctionfind_hash (const SCAN_Name &, Algorithm_Factory &) const
 
virtual MessageAuthenticationCodefind_mac (const SCAN_Name &algo_spec, Algorithm_Factory &af) const
 
virtual PBKDFfind_pbkdf (const SCAN_Name &algo_spec, Algorithm_Factory &af) const
 
StreamCipherfind_stream_cipher (const SCAN_Name &, Algorithm_Factory &) const
 
virtual Keyed_Filterget_cipher (const std::string &algo_spec, Cipher_Dir dir, Algorithm_Factory &af)
 
PK_Ops::Decryptionget_decryption_op (const Private_Key &key) const
 
PK_Ops::Encryptionget_encryption_op (const Public_Key &key) const
 
PK_Ops::Key_Agreementget_key_agreement_op (const Private_Key &key) const
 
PK_Ops::Signatureget_signature_op (const Private_Key &key) const
 
PK_Ops::Verificationget_verify_op (const Public_Key &key) const
 
Modular_Exponentiatormod_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_specthe algorithm name/specification
afan 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.

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  }
#define HANDLE_EVP_CIPHER_KEYLEN(NAME, EVP, MIN, MAX, MOD)
#define HANDLE_EVP_CIPHER(NAME, EVP)
HashFunction * Botan::OpenSSL_Engine::find_hash ( const SCAN_Name algo_spec,
Algorithm_Factory af 
) const
virtual
Parameters
algo_specthe algorithm name/specification
afan 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().

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_specthe algorithm name/specification
afan 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_specthe algorithm name/specification
afan 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().

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_specthe algorithm name/specification
dirspecifies if encryption or decryption is desired
afan 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
keythe 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.

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  }
size_t s
Definition: numthry.cpp:27
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
keythe 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.

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  }
size_t s
Definition: numthry.cpp:27
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
keythe 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.

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

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  }
size_t s
Definition: numthry.cpp:27
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
keythe 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.

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  }
size_t s
Definition: numthry.cpp:27
Modular_Exponentiator * Botan::OpenSSL_Engine::mod_exp ( const BigInt n,
Power_Mod::Usage_Hints  hints 
) const
virtual
Parameters
nthe modulus
hintsany 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  }
BigInt n
Definition: numthry.cpp:26
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.

24 { return "openssl"; }

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