aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pk_pad/emsa.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/pk_pad/emsa.cpp')
-rw-r--r--src/lib/pk_pad/emsa.cpp55
1 files changed, 43 insertions, 12 deletions
diff --git a/src/lib/pk_pad/emsa.cpp b/src/lib/pk_pad/emsa.cpp
index 66e58fb0d..3851f85a7 100644
--- a/src/lib/pk_pad/emsa.cpp
+++ b/src/lib/pk_pad/emsa.cpp
@@ -8,23 +8,27 @@
#include <botan/scan_name.h>
#if defined(BOTAN_HAS_EMSA1)
- #include <botan/emsa1.h>
+ #include <botan/emsa1.h>
#endif
#if defined(BOTAN_HAS_EMSA_X931)
- #include <botan/emsa_x931.h>
+ #include <botan/emsa_x931.h>
#endif
#if defined(BOTAN_HAS_EMSA_PKCS1)
- #include <botan/emsa_pkcs1.h>
+ #include <botan/emsa_pkcs1.h>
#endif
#if defined(BOTAN_HAS_EMSA_PSSR)
- #include <botan/pssr.h>
+ #include <botan/pssr.h>
#endif
#if defined(BOTAN_HAS_EMSA_RAW)
- #include <botan/emsa_raw.h>
+ #include <botan/emsa_raw.h>
+#endif
+
+#if defined(BOTAN_HAS_ISO_9796)
+ #include <botan/iso9796.h>
#endif
namespace Botan {
@@ -45,8 +49,8 @@ EMSA* get_emsa(const std::string& algo_spec)
#if defined(BOTAN_HAS_EMSA_PKCS1)
if(req.algo_name() == "EMSA_PKCS1" ||
- req.algo_name() == "EMSA-PKCS1-v1_5" ||
- req.algo_name() == "EMSA3")
+ req.algo_name() == "EMSA-PKCS1-v1_5" ||
+ req.algo_name() == "EMSA3")
{
if(req.arg_count() == 1)
{
@@ -67,9 +71,9 @@ EMSA* get_emsa(const std::string& algo_spec)
#if defined(BOTAN_HAS_EMSA_PSSR)
if(req.algo_name() == "PSSR" ||
- req.algo_name() == "EMSA-PSS" ||
- req.algo_name() == "PSS-MGF1" ||
- req.algo_name() == "EMSA4")
+ req.algo_name() == "EMSA-PSS" ||
+ req.algo_name() == "PSS-MGF1" ||
+ req.algo_name() == "EMSA4")
{
if(req.arg_count_between(1, 3))
{
@@ -85,10 +89,37 @@ EMSA* get_emsa(const std::string& algo_spec)
}
#endif
+#if defined(BOTAN_HAS_ISO_9796)
+ if(req.algo_name() == "ISO_9796_DS2")
+ {
+ if(req.arg_count_between(1, 3))
+ {
+ if(auto h = HashFunction::create(req.arg(0)))
+ {
+ const size_t salt_size = req.arg_as_integer(2, h->output_length());
+ const bool implicit = req.arg(1, "exp") == "imp";
+ return new ISO_9796_DS2(h.release(), implicit, salt_size);
+ }
+ }
+ }
+ //ISO-9796-2 DS 3 is deterministic and DS2 without a salt
+ if(req.algo_name() == "ISO_9796_DS3")
+ {
+ if(req.arg_count_between(1, 2))
+ {
+ if(auto h = HashFunction::create(req.arg(0)))
+ {
+ const bool implicit = req.arg(1, "exp") == "imp";
+ return new ISO_9796_DS3(h.release(), implicit);
+ }
+ }
+ }
+#endif
+
#if defined(BOTAN_HAS_EMSA_X931)
if(req.algo_name() == "EMSA_X931" ||
- req.algo_name() == "EMSA2" ||
- req.algo_name() == "X9.31")
+ req.algo_name() == "EMSA2" ||
+ req.algo_name() == "X9.31")
{
if(req.arg_count() == 1)
{