From df64fb318acbfee7911bee4fd021100f1d6532ed Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 17 Oct 2016 06:05:37 -0400 Subject: Remove alias logic from SCAN_Name This required taking a global lock and doing a map lookup each time an algorithm was requested (and so many times during a TLS handshake). --- src/lib/pk_pad/emsa.cpp | 52 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 18 deletions(-) (limited to 'src/lib/pk_pad/emsa.cpp') diff --git a/src/lib/pk_pad/emsa.cpp b/src/lib/pk_pad/emsa.cpp index c091319e2..719863557 100644 --- a/src/lib/pk_pad/emsa.cpp +++ b/src/lib/pk_pad/emsa.cpp @@ -44,42 +44,58 @@ EMSA* get_emsa(const std::string& algo_spec) #endif #if defined(BOTAN_HAS_EMSA_PKCS1) - if(req.algo_name() == "EMSA_PKCS1" && req.arg_count() == 1) + if(req.algo_name() == "EMSA_PKCS1" || + req.algo_name() == "EMSA-PKCS1-v1_5" || + req.algo_name() == "EMSA3") { - if(req.arg(0) == "Raw") + if(req.arg_count() == 1) { - return new EMSA_PKCS1v15_Raw; - } - else - { - if(auto hash = HashFunction::create(req.arg(0))) + if(req.arg(0) == "Raw") { - return new EMSA_PKCS1v15(hash.release()); + return new EMSA_PKCS1v15_Raw; + } + else + { + if(auto hash = HashFunction::create(req.arg(0))) + { + return new EMSA_PKCS1v15(hash.release()); + } } } } #endif #if defined(BOTAN_HAS_EMSA_PSSR) - if(req.algo_name() == "PSSR") + if(req.algo_name() == "PSSR" || + req.algo_name() == "EMSA-PSS" || + req.algo_name() == "PSS-MGF1" || + req.algo_name() == "EMSA4") { - if(req.arg(1, "MGF1") != "MGF1") - return nullptr; // not supported - - if(auto h = HashFunction::create(req.arg(0))) + if(req.arg_count_between(2, 3)) { - const size_t salt_size = req.arg_as_integer(2, h->output_length()); - return new PSSR(h.release(), salt_size); + if(req.arg(1, "MGF1") != "MGF1") + return nullptr; // not supported + + if(auto h = HashFunction::create(req.arg(0))) + { + const size_t salt_size = req.arg_as_integer(2, h->output_length()); + return new PSSR(h.release(), salt_size); + } } } #endif #if defined(BOTAN_HAS_EMSA_X931) - if(req.algo_name() == "EMSA_X931" && req.arg_count() == 1) + if(req.algo_name() == "EMSA_X931" || + req.algo_name() == "EMSA2" || + req.algo_name() == "X9.31") { - if(auto hash = HashFunction::create(req.arg(0))) + if(req.arg_count() == 1) { - return new EMSA_X931(hash.release()); + if(auto hash = HashFunction::create(req.arg(0))) + { + return new EMSA_X931(hash.release()); + } } } #endif -- cgit v1.2.3