aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstate/engine/def_engine/lookup_mac.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-11-09 22:50:05 +0000
committerlloyd <[email protected]>2008-11-09 22:50:05 +0000
commit986f88320c05cc8ab064451858af3c1f949e89fa (patch)
treec0be62e9afc0bde099f0868631b900e2f9c74c77 /src/libstate/engine/def_engine/lookup_mac.cpp
parent3622375eabb11c10b9beeb8448643a62276ca65f (diff)
Modify Default_Engine to use SCAN_Name internally
Diffstat (limited to 'src/libstate/engine/def_engine/lookup_mac.cpp')
-rw-r--r--src/libstate/engine/def_engine/lookup_mac.cpp48
1 files changed, 12 insertions, 36 deletions
diff --git a/src/libstate/engine/def_engine/lookup_mac.cpp b/src/libstate/engine/def_engine/lookup_mac.cpp
index db80d525f..5cdc20cf2 100644
--- a/src/libstate/engine/def_engine/lookup_mac.cpp
+++ b/src/libstate/engine/def_engine/lookup_mac.cpp
@@ -5,8 +5,7 @@
#include <botan/def_eng.h>
#include <botan/lookup.h>
-#include <botan/libstate.h>
-#include <botan/parsing.h>
+#include <botan/scan_name.h>
#if defined(BOTAN_HAS_CBC_MAC)
#include <botan/cbc_mac.h>
@@ -36,54 +35,31 @@ namespace Botan {
MessageAuthenticationCode*
Default_Engine::find_mac(const std::string& algo_spec) const
{
- std::vector<std::string> name = parse_algorithm_name(algo_spec);
- if(name.empty())
- return 0;
- const std::string algo_name = global_state().deref_alias(name[0]);
+ SCAN_Name request(algo_spec);
#if defined(BOTAN_HAS_CBC_MAC)
- if(algo_name == "CBC-MAC")
- {
- if(name.size() == 2)
- return new CBC_MAC(get_block_cipher(name[1]));
- throw Invalid_Algorithm_Name(algo_spec);
- }
+ if(request.algo_name() == "CBC-MAC" && request.arg_count() == 1)
+ return new CBC_MAC(get_block_cipher(request.argument(0)));
#endif
#if defined(BOTAN_HAS_CMAC)
- if(algo_name == "CMAC")
- {
- if(name.size() == 2)
- return new CMAC(get_block_cipher(name[1]));
- throw Invalid_Algorithm_Name(algo_spec);
- }
+ if(request.algo_name() == "CMAC" && request.arg_count() == 1)
+ return new CMAC(get_block_cipher(request.argument(0)));
#endif
#if defined(BOTAN_HAS_HMAC)
- if(algo_name == "HMAC")
- {
- if(name.size() == 2)
- return new HMAC(get_hash(name[1]));
- throw Invalid_Algorithm_Name(algo_spec);
- }
+ if(request.algo_name() == "HMAC" && request.arg_count() == 1)
+ return new HMAC(get_hash(request.argument(0)));
#endif
#if defined(BOTAN_HAS_SSL3_MAC)
- if(algo_name == "SSL3-MAC")
- {
- if(name.size() == 2)
- return new SSL3_MAC(get_hash(name[1]));
- throw Invalid_Algorithm_Name(algo_spec);
- }
+ if(request.algo_name() == "SSL3-MAC" && request.arg_count() == 1)
+ return new SSL3_MAC(get_hash(request.argument(0)));
#endif
#if defined(BOTAN_HAS_ANSI_X919_MAC)
- if(algo_name == "X9.19-MAC")
- {
- if(name.size() == 1)
- return new ANSI_X919_MAC(get_block_cipher("DES"));
- throw Invalid_Algorithm_Name(algo_spec);
- }
+ if(request.algo_name() == "X9.19-MAC" && request.arg_count() == 0)
+ return new ANSI_X919_MAC(get_block_cipher("DES"));
#endif
return 0;