diff options
author | Jack Lloyd <[email protected]> | 2018-03-21 08:13:56 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-03-21 08:13:56 -0400 |
commit | 2821d60c9c159851c3d236fcc2bdeafd2d733849 (patch) | |
tree | ea1a382c8e93f49960b85d32799579fc68b0f385 /src/lib/pk_pad/eme.cpp | |
parent | 9a35a05781688838b9bf951471c86363deba36cd (diff) | |
parent | 13e4658b07f95bef8b48d93c74be25f2d6afde7d (diff) |
Merge GH #1503 Support mixed hashes in OAEP
Diffstat (limited to 'src/lib/pk_pad/eme.cpp')
-rw-r--r-- | src/lib/pk_pad/eme.cpp | 19 |
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 |