aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli/speed.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-06-30 10:57:01 -0400
committerJack Lloyd <[email protected]>2017-06-30 10:57:01 -0400
commit884fd85a05e055e497a68a5d2b0bd937290bfca4 (patch)
tree21e3af1a76855342b9014c909cf427e71eee1a23 /src/cli/speed.cpp
parentc09e7780e1ce3aa6eab5e7fb8fb4ed504493fd37 (diff)
parenta296f8e629d968642989d9d385c2b089840cf6fb (diff)
Merge GH #1082 Add support for SM2 signature scheme
Diffstat (limited to 'src/cli/speed.cpp')
-rw-r--r--src/cli/speed.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp
index 62edf0b75..7f25496e4 100644
--- a/src/cli/speed.cpp
+++ b/src/cli/speed.cpp
@@ -115,6 +115,10 @@
#include <botan/xmss.h>
#endif
+#if defined(BOTAN_HAS_SM2)
+ #include <botan/sm2.h>
+#endif
+
#if defined(BOTAN_HAS_NEWHOPE) && defined(BOTAN_HAS_CHACHA)
#include <botan/newhope.h>
#include <botan/chacha.h>
@@ -735,6 +739,12 @@ class Speed final : public Command
bench_ecdsa(ecc_groups, provider, msec);
}
#endif
+#if defined(BOTAN_HAS_SM2)
+ else if(algo == "SM2")
+ {
+ bench_sm2(ecc_groups, provider, msec);
+ }
+#endif
#if defined(BOTAN_HAS_ECKCDSA)
else if(algo == "ECKCDSA")
{
@@ -1742,6 +1752,28 @@ class Speed final : public Command
}
#endif
+#if defined(BOTAN_HAS_SM2)
+ void bench_sm2(const std::vector<std::string>& groups,
+ const std::string& provider,
+ std::chrono::milliseconds msec)
+ {
+ for(std::string grp : groups)
+ {
+ const std::string nm = "SM2-" + grp;
+
+ Timer keygen_timer(nm, provider, "keygen");
+
+ std::unique_ptr<Botan::Private_Key> key(keygen_timer.run([&]
+ {
+ return new Botan::SM2_Signature_PrivateKey(rng(), Botan::EC_Group(grp));
+ }));
+
+ output() << Timer::result_string_ops(keygen_timer);
+ bench_pk_sig(*key, nm, provider, "SM3", msec);
+ }
+ }
+#endif
+
#if defined(BOTAN_HAS_ECGDSA)
void bench_ecgdsa(const std::vector<std::string>& groups,
const std::string& provider,