aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pk_pad/eme.cpp
diff options
context:
space:
mode:
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);
}