00001
00002
00003
00004
00005
00006
00007
00008 #ifndef BOTAN_ALGORITHM_FACTORY_H__
00009 #define BOTAN_ALGORITHM_FACTORY_H__
00010
00011 #include <botan/types.h>
00012 #include <string>
00013 #include <vector>
00014
00015 namespace Botan {
00016
00017
00018
00019
00020 class BlockCipher;
00021 class StreamCipher;
00022 class HashFunction;
00023 class MessageAuthenticationCode;
00024
00025 template<typename T> class Algorithm_Cache;
00026
00027 class Engine;
00028 class Mutex_Factory;
00029
00030
00031
00032
00033 class BOTAN_DLL Algorithm_Factory
00034 {
00035 public:
00036
00037
00038
00039
00040 Algorithm_Factory(Mutex_Factory& mf);
00041
00042
00043
00044
00045 ~Algorithm_Factory();
00046
00047
00048
00049
00050 void add_engine(Engine* engine);
00051
00052
00053
00054
00055 void clear_caches();
00056
00057
00058
00059
00060
00061 std::vector<std::string> providers_of(const std::string& algo_spec);
00062
00063
00064
00065
00066
00067 void set_preferred_provider(const std::string& algo_spec,
00068 const std::string& provider);
00069
00070
00071
00072
00073
00074
00075 const BlockCipher*
00076 prototype_block_cipher(const std::string& algo_spec,
00077 const std::string& provider = "");
00078
00079
00080
00081
00082
00083
00084 BlockCipher* make_block_cipher(const std::string& algo_spec,
00085 const std::string& provider = "");
00086
00087
00088
00089
00090
00091 void add_block_cipher(BlockCipher* algo, const std::string& provider);
00092
00093
00094
00095
00096
00097
00098 const StreamCipher*
00099 prototype_stream_cipher(const std::string& algo_spec,
00100 const std::string& provider = "");
00101
00102
00103
00104
00105
00106
00107 StreamCipher* make_stream_cipher(const std::string& algo_spec,
00108 const std::string& provider = "");
00109
00110
00111
00112
00113
00114 void add_stream_cipher(StreamCipher* algo, const std::string& provider);
00115
00116
00117
00118
00119
00120
00121 const HashFunction*
00122 prototype_hash_function(const std::string& algo_spec,
00123 const std::string& provider = "");
00124
00125
00126
00127
00128
00129
00130 HashFunction* make_hash_function(const std::string& algo_spec,
00131 const std::string& provider = "");
00132
00133
00134
00135
00136
00137 void add_hash_function(HashFunction* algo, const std::string& provider);
00138
00139
00140
00141
00142
00143
00144 const MessageAuthenticationCode*
00145 prototype_mac(const std::string& algo_spec,
00146 const std::string& provider = "");
00147
00148
00149
00150
00151
00152
00153 MessageAuthenticationCode* make_mac(const std::string& algo_spec,
00154 const std::string& provider = "");
00155
00156
00157
00158
00159
00160 void add_mac(MessageAuthenticationCode* algo,
00161 const std::string& provider);
00162
00163
00164
00165
00166
00167 class BOTAN_DLL Engine_Iterator
00168 {
00169 public:
00170
00171
00172
00173 Engine* next() { return af.get_engine_n(n++); }
00174
00175
00176
00177
00178 Engine_Iterator(const Algorithm_Factory& a) : af(a) { n = 0; }
00179 private:
00180 const Algorithm_Factory& af;
00181 u32bit n;
00182 };
00183 friend class Engine_Iterator;
00184
00185 private:
00186 Algorithm_Factory(const Algorithm_Factory&) {}
00187 Algorithm_Factory& operator=(const Algorithm_Factory&)
00188 { return (*this); }
00189
00190 Engine* get_engine_n(u32bit) const;
00191
00192 std::vector<Engine*> engines;
00193
00194 Algorithm_Cache<BlockCipher>* block_cipher_cache;
00195 Algorithm_Cache<StreamCipher>* stream_cipher_cache;
00196 Algorithm_Cache<HashFunction>* hash_cache;
00197 Algorithm_Cache<MessageAuthenticationCode>* mac_cache;
00198 };
00199
00200 }
00201
00202 #endif