diff options
author | Jack Lloyd <[email protected]> | 2017-06-21 14:43:52 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-06-29 12:38:37 -0400 |
commit | 6ac870e6d81d98420a102661a27ad9b521da86f5 (patch) | |
tree | 0341a30bbf1003614e81e54f98b0a08105b6d9d1 /src/cli/speed.cpp | |
parent | 8b0986310ae9fdf7fa93e28e2820d818cc954cdd (diff) |
Add SM2 signature scheme
From https://tools.ietf.org/html/draft-shen-sm2-ecdsa-02
This is a contribution from Ribose Inc (@riboseinc).
Diffstat (limited to 'src/cli/speed.cpp')
-rw-r--r-- | src/cli/speed.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp index 296b4b07a..cae11e52f 100644 --- a/src/cli/speed.cpp +++ b/src/cli/speed.cpp @@ -112,6 +112,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> @@ -499,6 +503,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") { @@ -1387,6 +1397,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, |