aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pk_pad/emsa.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-10-17 06:05:37 -0400
committerJack Lloyd <[email protected]>2016-10-21 16:53:17 -0400
commitdf64fb318acbfee7911bee4fd021100f1d6532ed (patch)
tree20238e6f96c7d6e31539389c398255850177d970 /src/lib/pk_pad/emsa.cpp
parent558808900bffc3c48da5e6d79ba602e88e619154 (diff)
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).
Diffstat (limited to 'src/lib/pk_pad/emsa.cpp')
-rw-r--r--src/lib/pk_pad/emsa.cpp52
1 files changed, 34 insertions, 18 deletions
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