aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-03-21 06:45:06 -0400
committerJack Lloyd <[email protected]>2018-03-21 06:45:06 -0400
commit29bbabad6e833a2b0047a41fe8bed8960b8e1116 (patch)
tree915e973afebf76890333ed8c2f1a04c90f70b987 /src/lib
parente7689444a0ef4ab5c252235968d84acf6685819a (diff)
Support "mixed" OAEP hashes
Test vectors from pyca/cryptography Fixes GH #109
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/pk_pad/eme.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/lib/pk_pad/eme.cpp b/src/lib/pk_pad/eme.cpp
index aa62f4196..23c444506 100644
--- a/src/lib/pk_pad/eme.cpp
+++ b/src/lib/pk_pad/eme.cpp
@@ -8,6 +8,7 @@
#include <botan/eme.h>
#include <botan/scan_name.h>
#include <botan/exceptn.h>
+#include <botan/parsing.h>
#if defined(BOTAN_HAS_EME_OAEP)
#include <botan/oaep.h>
@@ -42,12 +43,26 @@ EME* get_eme(const std::string& algo_spec)
req.algo_name() == "EME-OAEP" ||
req.algo_name() == "EME1")
{
- if(req.arg_count() == 1 ||
- (req.arg_count() == 2 && req.arg(1) == "MGF1"))
+ 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());
}
+ else if(req.arg_count() == 2)
+ {
+ auto mgf_params = parse_algorithm_name(req.arg(1));
+
+ if(mgf_params.size() == 2 && mgf_params[0] == "MGF1")
+ {
+ auto hash = HashFunction::create(req.arg(0));
+ auto mgf1_hash = HashFunction::create(mgf_params[1]);
+
+ if(hash && mgf1_hash)
+ {
+ return new OAEP(hash.release(), mgf1_hash.release());
+ }
+ }
+ }
}
#endif