aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pk_pad/eme.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-10-11 13:00:57 -0400
committerJack Lloyd <[email protected]>2016-10-21 16:53:16 -0400
commit558808900bffc3c48da5e6d79ba602e88e619154 (patch)
treefd76ee2d009c2b707d888683cbd767351c4ff6b3 /src/lib/pk_pad/eme.cpp
parent6aa855bba613c7b6fedfbe71d15930964acb1633 (diff)
Remove Algo_Registry
I repent my use of global constructors. I repent my use of global locks. Hopefully I will never touch this code again. :)
Diffstat (limited to 'src/lib/pk_pad/eme.cpp')
-rw-r--r--src/lib/pk_pad/eme.cpp36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/lib/pk_pad/eme.cpp b/src/lib/pk_pad/eme.cpp
index b36ed6e67..fa569d8e4 100644
--- a/src/lib/pk_pad/eme.cpp
+++ b/src/lib/pk_pad/eme.cpp
@@ -6,7 +6,7 @@
*/
#include <botan/eme.h>
-#include <botan/internal/algo_registry.h>
+#include <botan/scan_name.h>
#if defined(BOTAN_HAS_EME_OAEP)
#include <botan/oaep.h>
@@ -22,34 +22,32 @@
namespace Botan {
-#define BOTAN_REGISTER_EME(name, maker) BOTAN_REGISTER_T(EME, name, maker)
-#define BOTAN_REGISTER_EME_NOARGS(name) BOTAN_REGISTER_T_NOARGS(EME, name)
-
-#define BOTAN_REGISTER_EME_NAMED_NOARGS(type, name) \
- BOTAN_REGISTER_NAMED_T(EME, name, type, make_new_T<type>)
+EME* get_eme(const std::string& algo_spec)
+ {
+ SCAN_Name req(algo_spec);
#if defined(BOTAN_HAS_EME_OAEP)
-BOTAN_REGISTER_NAMED_T(EME, "OAEP", OAEP, OAEP::make);
+ if(req.algo_name() == "OAEP" && req.arg_count_between(1, 2))
+ {
+ if(req.arg_count() == 1 ||
+ (req.arg_count() == 2 && req.arg(1) == "MGF1"))
+ {
+ if(auto hash = HashFunction::create(req.arg(0)))
+ return new OAEP(hash.release());
+ }
+ }
#endif
#if defined(BOTAN_HAS_EME_PKCS1v15)
-BOTAN_REGISTER_EME_NAMED_NOARGS(EME_PKCS1v15, "PKCS1v15");
+ if(req.algo_name() == "PKCS1v15" && req.arg_count() == 0)
+ return new EME_PKCS1v15;
#endif
#if defined(BOTAN_HAS_EME_RAW)
-BOTAN_REGISTER_EME_NAMED_NOARGS(EME_Raw, "Raw");
+ if(req.algo_name() == "Raw" && req.arg_count() == 0)
+ return new EME_Raw;
#endif
-EME* get_eme(const std::string& algo_spec)
- {
- SCAN_Name request(algo_spec);
-
- if(EME* eme = make_a<EME>(Botan::EME::Spec(algo_spec)))
- return eme;
-
- if(request.algo_name() == "Raw")
- return nullptr; // No padding
-
throw Algorithm_Not_Found(algo_spec);
}