diff options
-rw-r--r-- | src/engine/def_engine/def_mode.cpp | 2 | ||||
-rw-r--r-- | src/filters/algo_filt.cpp | 11 | ||||
-rw-r--r-- | src/libstate/libstate.cpp | 4 | ||||
-rw-r--r-- | src/libstate/libstate.h | 3 | ||||
-rw-r--r-- | src/libstate/lookup.cpp | 88 | ||||
-rw-r--r-- | src/libstate/lookup.h | 10 | ||||
-rw-r--r-- | src/libstate/pk_engine.cpp | 16 |
7 files changed, 69 insertions, 65 deletions
diff --git a/src/engine/def_engine/def_mode.cpp b/src/engine/def_engine/def_mode.cpp index 7933fbb84..a2015e6d3 100644 --- a/src/engine/def_engine/def_mode.cpp +++ b/src/engine/def_engine/def_mode.cpp @@ -80,7 +80,7 @@ Keyed_Filter* Default_Engine::get_cipher(const std::string& algo_spec, const std::string cipher_name = algo_parts[0]; - Algorithm_Factory& af = global_state().algo_factory(); + Algorithm_Factory& af = global_state().algorithm_factory(); // check if it is a stream cipher first (easy case) const StreamCipher* stream_cipher = af.prototype_stream_cipher(cipher_name); diff --git a/src/filters/algo_filt.cpp b/src/filters/algo_filt.cpp index 17b0b8440..08e65c601 100644 --- a/src/filters/algo_filt.cpp +++ b/src/filters/algo_filt.cpp @@ -15,7 +15,7 @@ namespace Botan { StreamCipher_Filter::StreamCipher_Filter(const std::string& sc_name) : buffer(DEFAULT_BUFFERSIZE) { - Algorithm_Factory& af = global_state().algo_factory(); + Algorithm_Factory& af = global_state().algorithm_factory(); base_ptr = cipher = af.make_stream_cipher(sc_name); } @@ -35,7 +35,7 @@ StreamCipher_Filter::StreamCipher_Filter(const std::string& sc_name, const SymmetricKey& key) : buffer(DEFAULT_BUFFERSIZE) { - Algorithm_Factory& af = global_state().algo_factory(); + Algorithm_Factory& af = global_state().algorithm_factory(); base_ptr = cipher = af.make_stream_cipher(sc_name); cipher->set_key(key); } @@ -70,7 +70,8 @@ Hash_Filter::Hash_Filter(const std::string& algo_spec, u32bit len) : OUTPUT_LENGTH(len) { - hash = global_state().algo_factory().make_hash_function(algo_spec); + Algorithm_Factory& af = global_state().algorithm_factory(); + hash = af.make_hash_function(algo_spec); } /************************************************* @@ -91,7 +92,7 @@ void Hash_Filter::end_msg() MAC_Filter::MAC_Filter(const std::string& mac_name, u32bit len) : OUTPUT_LENGTH(len) { - Algorithm_Factory& af = global_state().algo_factory(); + Algorithm_Factory& af = global_state().algorithm_factory(); base_ptr = mac = af.make_mac(mac_name); } @@ -101,7 +102,7 @@ MAC_Filter::MAC_Filter(const std::string& mac_name, u32bit len) : MAC_Filter::MAC_Filter(const std::string& mac_name, const SymmetricKey& key, u32bit len) : OUTPUT_LENGTH(len) { - Algorithm_Factory& af = global_state().algo_factory(); + Algorithm_Factory& af = global_state().algorithm_factory(); base_ptr = mac = af.make_mac(mac_name); mac->set_key(key); } diff --git a/src/libstate/libstate.cpp b/src/libstate/libstate.cpp index 1e5f7aa8b..160f07678 100644 --- a/src/libstate/libstate.cpp +++ b/src/libstate/libstate.cpp @@ -227,10 +227,10 @@ std::string Library_State::option(const std::string& key) const /** Return a reference to the Algorithm_Factory */ -Algorithm_Factory& Library_State::algo_factory() +Algorithm_Factory& Library_State::algorithm_factory() { if(!m_algorithm_factory) - throw Invalid_State("Uninitialized in Library_State::algo_factory"); + throw Invalid_State("Uninitialized in Library_State::algorithm_factory"); return *m_algorithm_factory; } diff --git a/src/libstate/libstate.h b/src/libstate/libstate.h index ac500b42f..53a70a636 100644 --- a/src/libstate/libstate.h +++ b/src/libstate/libstate.h @@ -27,8 +27,7 @@ class BOTAN_DLL Library_State void initialize(bool thread_safe); - Algorithm_Factory& algo_factory(); - Algorithm_Factory& algorithm_factory() { return algo_factory(); } + Algorithm_Factory& algorithm_factory(); void add_engine(class Engine*); diff --git a/src/libstate/lookup.cpp b/src/libstate/lookup.cpp index d16364cdc..24a8a8ecd 100644 --- a/src/libstate/lookup.cpp +++ b/src/libstate/lookup.cpp @@ -12,10 +12,10 @@ namespace Botan { /** * Acquire a block cipher */ -const BlockCipher* retrieve_block_cipher(Library_State& libstate, - const std::string& algo_spec) +const BlockCipher* retrieve_block_cipher(const std::string& algo_spec) { - return libstate.algo_factory().prototype_block_cipher(algo_spec); + Algorithm_Factory& af = global_state().algorithm_factory(); + return af.prototype_block_cipher(algo_spec); } /** @@ -23,16 +23,17 @@ const BlockCipher* retrieve_block_cipher(Library_State& libstate, */ BlockCipher* get_block_cipher(const std::string& algo_spec) { - return global_state().algo_factory().make_block_cipher(algo_spec); + Algorithm_Factory& af = global_state().algorithm_factory(); + return af.make_block_cipher(algo_spec); } /** * Acquire a stream cipher */ -const StreamCipher* retrieve_stream_cipher(Library_State& libstate, - const std::string& algo_spec) +const StreamCipher* retrieve_stream_cipher(const std::string& algo_spec) { - return libstate.algo_factory().prototype_stream_cipher(algo_spec); + Algorithm_Factory& af = global_state().algorithm_factory(); + return af.prototype_stream_cipher(algo_spec); } /** @@ -40,16 +41,17 @@ const StreamCipher* retrieve_stream_cipher(Library_State& libstate, */ StreamCipher* get_stream_cipher(const std::string& algo_spec) { - return global_state().algo_factory().make_stream_cipher(algo_spec); + Algorithm_Factory& af = global_state().algorithm_factory(); + return af.make_stream_cipher(algo_spec); } /** * Acquire a hash function */ -const HashFunction* retrieve_hash(Library_State& libstate, - const std::string& algo_spec) +const HashFunction* retrieve_hash(const std::string& algo_spec) { - return libstate.algo_factory().prototype_hash_function(algo_spec); + Algorithm_Factory& af = global_state().algorithm_factory(); + return af.prototype_hash_function(algo_spec); } /** @@ -57,7 +59,8 @@ const HashFunction* retrieve_hash(Library_State& libstate, */ HashFunction* get_hash(const std::string& algo_spec) { - return global_state().algo_factory().make_hash_function(algo_spec); + Algorithm_Factory& af = global_state().algorithm_factory(); + return af.make_hash_function(algo_spec); } /** @@ -65,16 +68,17 @@ HashFunction* get_hash(const std::string& algo_spec) */ bool have_hash(const std::string& algo_spec) { - return global_state().algo_factory().prototype_hash_function(algo_spec); + Algorithm_Factory& af = global_state().algorithm_factory(); + return af.prototype_hash_function(algo_spec); } /** * Acquire an authentication code */ -const MessageAuthenticationCode* retrieve_mac(Library_State& libstate, - const std::string& algo_spec) +const MessageAuthenticationCode* retrieve_mac(const std::string& algo_spec) { - return libstate.algo_factory().prototype_mac(algo_spec); + Algorithm_Factory& af = global_state().algorithm_factory(); + return af.prototype_mac(algo_spec); } /** @@ -82,7 +86,8 @@ const MessageAuthenticationCode* retrieve_mac(Library_State& libstate, */ MessageAuthenticationCode* get_mac(const std::string& algo_spec) { - return global_state().algo_factory().make_mac(algo_spec); + Algorithm_Factory& af = global_state().algorithm_factory(); + return af.make_mac(algo_spec); } /** @@ -90,7 +95,8 @@ MessageAuthenticationCode* get_mac(const std::string& algo_spec) */ bool have_mac(const std::string& algo_spec) { - return global_state().algo_factory().prototype_mac(algo_spec); + Algorithm_Factory& af = global_state().algorithm_factory(); + return af.prototype_mac(algo_spec); } /** @@ -98,13 +104,13 @@ bool have_mac(const std::string& algo_spec) */ bool have_algorithm(const std::string& name) { - if(retrieve_block_cipher(global_state(), name)) + if(retrieve_block_cipher(name)) return true; - if(retrieve_stream_cipher(global_state(), name)) + if(retrieve_stream_cipher(name)) return true; - if(retrieve_hash(global_state(), name)) + if(retrieve_hash(name)) return true; - if(retrieve_mac(global_state(), name)) + if(retrieve_mac(name)) return true; return false; } @@ -114,7 +120,7 @@ bool have_algorithm(const std::string& name) */ bool have_block_cipher(const std::string& name) { - return (retrieve_block_cipher(global_state(), name) != 0); + return (retrieve_block_cipher(name) != 0); } /** @@ -122,7 +128,7 @@ bool have_block_cipher(const std::string& name) */ bool have_stream_cipher(const std::string& name) { - return (retrieve_stream_cipher(global_state(), name) != 0); + return (retrieve_stream_cipher(name) != 0); } /** @@ -130,11 +136,11 @@ bool have_stream_cipher(const std::string& name) */ u32bit block_size_of(const std::string& name) { - const BlockCipher* cipher = retrieve_block_cipher(global_state(), name); + const BlockCipher* cipher = retrieve_block_cipher(name); if(cipher) return cipher->BLOCK_SIZE; - const HashFunction* hash = retrieve_hash(global_state(), name); + const HashFunction* hash = retrieve_hash(name); if(hash) return hash->HASH_BLOCK_SIZE; @@ -146,11 +152,11 @@ u32bit block_size_of(const std::string& name) */ u32bit output_length_of(const std::string& name) { - const HashFunction* hash = retrieve_hash(global_state(), name); + const HashFunction* hash = retrieve_hash(name); if(hash) return hash->OUTPUT_LENGTH; - const MessageAuthenticationCode* mac = retrieve_mac(global_state(), name); + const MessageAuthenticationCode* mac = retrieve_mac(name); if(mac) return mac->OUTPUT_LENGTH; @@ -162,15 +168,15 @@ u32bit output_length_of(const std::string& name) */ bool valid_keylength_for(u32bit key_len, const std::string& name) { - const BlockCipher* bc = retrieve_block_cipher(global_state(), name); + const BlockCipher* bc = retrieve_block_cipher(name); if(bc) return bc->valid_keylength(key_len); - const StreamCipher* sc = retrieve_stream_cipher(global_state(), name); + const StreamCipher* sc = retrieve_stream_cipher(name); if(sc) return sc->valid_keylength(key_len); - const MessageAuthenticationCode* mac = retrieve_mac(global_state(), name); + const MessageAuthenticationCode* mac = retrieve_mac(name); if(mac) return mac->valid_keylength(key_len); @@ -182,15 +188,15 @@ bool valid_keylength_for(u32bit key_len, const std::string& name) */ u32bit min_keylength_of(const std::string& name) { - const BlockCipher* bc = retrieve_block_cipher(global_state(), name); + const BlockCipher* bc = retrieve_block_cipher(name); if(bc) return bc->MINIMUM_KEYLENGTH; - const StreamCipher* sc = retrieve_stream_cipher(global_state(), name); + const StreamCipher* sc = retrieve_stream_cipher(name); if(sc) return sc->MINIMUM_KEYLENGTH; - const MessageAuthenticationCode* mac = retrieve_mac(global_state(), name); + const MessageAuthenticationCode* mac = retrieve_mac(name); if(mac) return mac->MINIMUM_KEYLENGTH; @@ -202,15 +208,15 @@ u32bit min_keylength_of(const std::string& name) */ u32bit max_keylength_of(const std::string& name) { - const BlockCipher* bc = retrieve_block_cipher(global_state(), name); + const BlockCipher* bc = retrieve_block_cipher(name); if(bc) return bc->MAXIMUM_KEYLENGTH; - const StreamCipher* sc = retrieve_stream_cipher(global_state(), name); + const StreamCipher* sc = retrieve_stream_cipher(name); if(sc) return sc->MAXIMUM_KEYLENGTH; - const MessageAuthenticationCode* mac = retrieve_mac(global_state(), name); + const MessageAuthenticationCode* mac = retrieve_mac(name); if(mac) return mac->MAXIMUM_KEYLENGTH; @@ -222,15 +228,15 @@ u32bit max_keylength_of(const std::string& name) */ u32bit keylength_multiple_of(const std::string& name) { - const BlockCipher* bc = retrieve_block_cipher(global_state(), name); + const BlockCipher* bc = retrieve_block_cipher(name); if(bc) return bc->KEYLENGTH_MULTIPLE; - const StreamCipher* sc = retrieve_stream_cipher(global_state(), name); + const StreamCipher* sc = retrieve_stream_cipher(name); if(sc) return sc->KEYLENGTH_MULTIPLE; - const MessageAuthenticationCode* mac = retrieve_mac(global_state(), name); + const MessageAuthenticationCode* mac = retrieve_mac(name); if(mac) return mac->KEYLENGTH_MULTIPLE; @@ -243,7 +249,7 @@ u32bit keylength_multiple_of(const std::string& name) Keyed_Filter* get_cipher(const std::string& algo_spec, Cipher_Dir direction) { - Algorithm_Factory::Engine_Iterator i(global_state().algo_factory()); + Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory()); while(Engine* engine = i.next()) { diff --git a/src/libstate/lookup.h b/src/libstate/lookup.h index ec7932338..60575aa7f 100644 --- a/src/libstate/lookup.h +++ b/src/libstate/lookup.h @@ -20,8 +20,6 @@ namespace Botan { -class Library_State; - /************************************************* * Retrieve an object from the lookup table * *************************************************/ @@ -29,16 +27,16 @@ class Library_State; // retains ownership BOTAN_DLL const BlockCipher* -retrieve_block_cipher(Library_State&, const std::string&); +retrieve_block_cipher(const std::string&); BOTAN_DLL const StreamCipher* -retrieve_stream_cipher(Library_State&, const std::string&); +retrieve_stream_cipher(const std::string&); BOTAN_DLL const HashFunction* -retrieve_hash(Library_State&, const std::string&); +retrieve_hash(const std::string&); BOTAN_DLL const MessageAuthenticationCode* -retrieve_mac(Library_State&, const std::string&); +retrieve_mac(const std::string&); /************************************************* * Get an algorithm object * diff --git a/src/libstate/pk_engine.cpp b/src/libstate/pk_engine.cpp index 7b8e7d8fc..5904ce1f9 100644 --- a/src/libstate/pk_engine.cpp +++ b/src/libstate/pk_engine.cpp @@ -19,7 +19,7 @@ IF_Operation* if_op(const BigInt& e, const BigInt& n, const BigInt& d, const BigInt& p, const BigInt& q, const BigInt& d1, const BigInt& d2, const BigInt& c) { - Algorithm_Factory::Engine_Iterator i(global_state().algo_factory()); + Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory()); while(const Engine* engine = i.next()) { @@ -38,7 +38,7 @@ IF_Operation* if_op(const BigInt& e, const BigInt& n, const BigInt& d, *************************************************/ DSA_Operation* dsa_op(const DL_Group& group, const BigInt& y, const BigInt& x) { - Algorithm_Factory::Engine_Iterator i(global_state().algo_factory()); + Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory()); while(const Engine* engine = i.next()) { @@ -57,7 +57,7 @@ DSA_Operation* dsa_op(const DL_Group& group, const BigInt& y, const BigInt& x) *************************************************/ NR_Operation* nr_op(const DL_Group& group, const BigInt& y, const BigInt& x) { - Algorithm_Factory::Engine_Iterator i(global_state().algo_factory()); + Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory()); while(const Engine* engine = i.next()) { @@ -76,7 +76,7 @@ NR_Operation* nr_op(const DL_Group& group, const BigInt& y, const BigInt& x) *************************************************/ ELG_Operation* elg_op(const DL_Group& group, const BigInt& y, const BigInt& x) { - Algorithm_Factory::Engine_Iterator i(global_state().algo_factory()); + Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory()); while(const Engine* engine = i.next()) { @@ -95,7 +95,7 @@ ELG_Operation* elg_op(const DL_Group& group, const BigInt& y, const BigInt& x) *************************************************/ DH_Operation* dh_op(const DL_Group& group, const BigInt& x) { - Algorithm_Factory::Engine_Iterator i(global_state().algo_factory()); + Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory()); while(const Engine* engine = i.next()) { @@ -116,7 +116,7 @@ ECDSA_Operation* ecdsa_op(const EC_Domain_Params& dom_pars, const BigInt& priv_key, const PointGFp& pub_key) { - Algorithm_Factory::Engine_Iterator i(global_state().algo_factory()); + Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory()); while(const Engine* engine = i.next()) { @@ -137,7 +137,7 @@ ECKAEG_Operation* eckaeg_op(const EC_Domain_Params& dom_pars, const BigInt& priv_key, const PointGFp& pub_key) { - Algorithm_Factory::Engine_Iterator i(global_state().algo_factory()); + Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory()); while(const Engine* engine = i.next()) { @@ -155,7 +155,7 @@ ECKAEG_Operation* eckaeg_op(const EC_Domain_Params& dom_pars, *************************************************/ Modular_Exponentiator* mod_exp(const BigInt& n, Power_Mod::Usage_Hints hints) { - Algorithm_Factory::Engine_Iterator i(global_state().algo_factory()); + Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory()); while(const Engine* engine = i.next()) { |