aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/def_engine/lookup_mac.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-11-11 19:20:32 +0000
committerlloyd <[email protected]>2008-11-11 19:20:32 +0000
commit2af6c4499013911d7b01ce3ce1acc5aa8fef15ab (patch)
tree894612d39bbcd50187334c1bedf197c4475c7393 /src/engine/def_engine/lookup_mac.cpp
parent25d7b7aa9e9896df45f12fa59db4c44411bc21f0 (diff)
Move most of the remaining libstate code to pk_engine.cpp, move engines
back to the toplevel since most othe dependencies have been removed now (except get_cipher which still needs changes)
Diffstat (limited to 'src/engine/def_engine/lookup_mac.cpp')
-rw-r--r--src/engine/def_engine/lookup_mac.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/engine/def_engine/lookup_mac.cpp b/src/engine/def_engine/lookup_mac.cpp
new file mode 100644
index 000000000..ae44bbe3d
--- /dev/null
+++ b/src/engine/def_engine/lookup_mac.cpp
@@ -0,0 +1,68 @@
+/*************************************************
+* MAC Lookup *
+* (C) 1999-2007 Jack Lloyd *
+*************************************************/
+
+#include <botan/def_eng.h>
+#include <botan/scan_name.h>
+#include <botan/algo_factory.h>
+
+#if defined(BOTAN_HAS_CBC_MAC)
+ #include <botan/cbc_mac.h>
+#endif
+
+#if defined(BOTAN_HAS_CMAC)
+ #include <botan/cmac.h>
+#endif
+
+#if defined(BOTAN_HAS_HMAC)
+ #include <botan/hmac.h>
+#endif
+
+#if defined(BOTAN_HAS_SSL3_MAC)
+ #include <botan/ssl3_mac.h>
+#endif
+
+#if defined(BOTAN_HAS_ANSI_X919_MAC)
+ #include <botan/x919_mac.h>
+#endif
+
+namespace Botan {
+
+/*************************************************
+* Look for an algorithm with this name *
+*************************************************/
+MessageAuthenticationCode*
+Default_Engine::find_mac(const SCAN_Name& request,
+ Algorithm_Factory& af) const
+ {
+
+#if defined(BOTAN_HAS_CBC_MAC)
+ if(request.algo_name() == "CBC-MAC" && request.arg_count() == 1)
+ return new CBC_MAC(af.make_block_cipher(request.arg(0)));
+#endif
+
+#if defined(BOTAN_HAS_CMAC)
+ if(request.algo_name() == "CMAC" && request.arg_count() == 1)
+ return new CMAC(af.make_block_cipher(request.arg(0)));
+#endif
+
+#if defined(BOTAN_HAS_HMAC)
+ if(request.algo_name() == "HMAC" && request.arg_count() == 1)
+ return new HMAC(af.make_hash_function(request.arg(0)));
+#endif
+
+#if defined(BOTAN_HAS_SSL3_MAC)
+ if(request.algo_name() == "SSL3-MAC" && request.arg_count() == 1)
+ return new SSL3_MAC(af.make_hash_function(request.arg(0)));
+#endif
+
+#if defined(BOTAN_HAS_ANSI_X919_MAC)
+ if(request.algo_name() == "X9.19-MAC" && request.arg_count() == 0)
+ return new ANSI_X919_MAC(af.make_block_cipher(SCAN_Name("DES")));
+#endif
+
+ return 0;
+ }
+
+}