aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstate/lookup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstate/lookup.cpp')
-rw-r--r--src/libstate/lookup.cpp70
1 files changed, 31 insertions, 39 deletions
diff --git a/src/libstate/lookup.cpp b/src/libstate/lookup.cpp
index dd18420b5..d8fab625b 100644
--- a/src/libstate/lookup.cpp
+++ b/src/libstate/lookup.cpp
@@ -10,6 +10,37 @@
namespace Botan {
/*************************************************
+* Acquire a hash function *
+*************************************************/
+const HashFunction* retrieve_hash(Library_State& libstate,
+ const std::string& name)
+ {
+ return libstate.algo_factory().prototype_hash_function(name);
+ }
+
+/*************************************************
+* Get a hash function by name *
+*************************************************/
+HashFunction* get_hash(const std::string& algo_spec)
+ {
+ const HashFunction* hash =
+ global_state().algo_factory().prototype_hash_function(algo_spec);
+
+ if(hash)
+ return hash->clone();
+
+ throw Algorithm_Not_Found(algo_spec);
+ }
+
+/*************************************************
+* Query if Botan has the named hash function *
+*************************************************/
+bool have_hash(const std::string& algo_spec)
+ {
+ return global_state().algo_factory().prototype_hash_function(algo_spec);
+ }
+
+/*************************************************
* Get a block cipher by name *
*************************************************/
BlockCipher* get_block_cipher(const std::string& name)
@@ -32,17 +63,6 @@ StreamCipher* get_stream_cipher(const std::string& name)
}
/*************************************************
-* Get a hash function by name *
-*************************************************/
-HashFunction* get_hash(const std::string& name)
- {
- const HashFunction* hash = retrieve_hash(global_state(), name);
- if(hash)
- return hash->clone();
- throw Algorithm_Not_Found(name);
- }
-
-/*************************************************
* Get a MAC by name *
*************************************************/
MessageAuthenticationCode* get_mac(const std::string& name)
@@ -86,14 +106,6 @@ bool have_stream_cipher(const std::string& name)
}
/*************************************************
-* Query if Botan has the named hash function *
-*************************************************/
-bool have_hash(const std::string& name)
- {
- return (retrieve_hash(global_state(), name) != 0);
- }
-
-/*************************************************
* Query if Botan has the named MAC *
*************************************************/
bool have_mac(const std::string& name)
@@ -213,7 +225,6 @@ u32bit keylength_multiple_of(const std::string& name)
throw Algorithm_Not_Found(name);
}
-
/*************************************************
* Acquire a block cipher *
*************************************************/
@@ -251,25 +262,6 @@ const StreamCipher* retrieve_stream_cipher(Library_State& libstate,
}
/*************************************************
-* Acquire a hash function *
-*************************************************/
-const HashFunction* retrieve_hash(Library_State& libstate,
- const std::string& name)
- {
- //return libstate.algo_factory().prototype_hash_function(name);
- Algorithm_Factory::Engine_Iterator i(libstate.algo_factory());
-
- while(const Engine* engine = i.next())
- {
- const HashFunction* algo = engine->hash(name);
- if(algo)
- return algo;
- }
-
- return 0;
- }
-
-/*************************************************
* Acquire an authentication code *
*************************************************/
const MessageAuthenticationCode* retrieve_mac(Library_State& libstate,