1 /**
2 * Dynamically Loaded Engine
3 * (C) 2010 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7 
8 #ifndef BOTAN_DYN_LOADED_ENGINE_H__
9 #define BOTAN_DYN_LOADED_ENGINE_H__
10 
11 #include <botan/engine.h>
12 
13 namespace Botan {
14 
15 /**
16 * Dynamically_Loaded_Engine just proxies the requests to the underlying
17 * Engine object, and handles load/unload details
18 */
19 class BOTAN_DLL Dynamically_Loaded_Engine : public Engine
20    {
21    public:
22       /**
23       * @param lib_path full pathname to DLL to load
24       */
25       Dynamically_Loaded_Engine(const std::string& lib_path);
26 
27       ~Dynamically_Loaded_Engine();
28 
provider_name()29       std::string provider_name() const { return engine->provider_name(); }
30 
find_block_cipher(const SCAN_Name & algo_spec,Algorithm_Factory & af)31       BlockCipher* find_block_cipher(const SCAN_Name& algo_spec,
32                                      Algorithm_Factory& af) const
33          {
34          return engine->find_block_cipher(algo_spec, af);
35          }
36 
find_stream_cipher(const SCAN_Name & algo_spec,Algorithm_Factory & af)37       StreamCipher* find_stream_cipher(const SCAN_Name& algo_spec,
38                                        Algorithm_Factory& af) const
39          {
40          return engine->find_stream_cipher(algo_spec, af);
41          }
42 
find_hash(const SCAN_Name & algo_spec,Algorithm_Factory & af)43       HashFunction* find_hash(const SCAN_Name& algo_spec,
44                               Algorithm_Factory& af) const
45          {
46          return engine->find_hash(algo_spec, af);
47          }
48 
find_mac(const SCAN_Name & algo_spec,Algorithm_Factory & af)49       MessageAuthenticationCode* find_mac(const SCAN_Name& algo_spec,
50                                           Algorithm_Factory& af) const
51          {
52          return engine->find_mac(algo_spec, af);
53          }
54 
find_pbkdf(const SCAN_Name & algo_spec,Algorithm_Factory & af)55       PBKDF* find_pbkdf(const SCAN_Name& algo_spec,
56                         Algorithm_Factory& af) const
57          {
58          return engine->find_pbkdf(algo_spec, af);
59          }
60 
mod_exp(const BigInt & n,Power_Mod::Usage_Hints hints)61       Modular_Exponentiator* mod_exp(const BigInt& n,
62                                      Power_Mod::Usage_Hints hints) const
63          {
64          return engine->mod_exp(n, hints);
65          }
66 
get_cipher(const std::string & algo_spec,Cipher_Dir dir,Algorithm_Factory & af)67       Keyed_Filter* get_cipher(const std::string& algo_spec,
68                                Cipher_Dir dir,
69                                Algorithm_Factory& af)
70          {
71          return engine->get_cipher(algo_spec, dir, af);
72          }
73 
74       PK_Ops::Key_Agreement*
get_key_agreement_op(const Private_Key & key)75          get_key_agreement_op(const Private_Key& key) const
76          {
77          return engine->get_key_agreement_op(key);
78          }
79 
80       PK_Ops::Signature*
get_signature_op(const Private_Key & key)81          get_signature_op(const Private_Key& key) const
82          {
83          return engine->get_signature_op(key);
84          }
85 
86       PK_Ops::Verification*
get_verify_op(const Public_Key & key)87          get_verify_op(const Public_Key& key) const
88          {
89          return engine->get_verify_op(key);
90          }
91 
92       PK_Ops::Encryption*
get_encryption_op(const Public_Key & key)93          get_encryption_op(const Public_Key& key) const
94          {
95          return engine->get_encryption_op(key);
96          }
97 
98       PK_Ops::Decryption*
get_decryption_op(const Private_Key & key)99          get_decryption_op(const Private_Key& key) const
100          {
101          return engine->get_decryption_op(key);
102          }
103 
104    private:
105       class Dynamically_Loaded_Library* lib;
106       Engine* engine;
107    };
108 
109 }
110 
111 #endif
112