From 6ac870e6d81d98420a102661a27ad9b521da86f5 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Wed, 21 Jun 2017 14:43:52 -0400 Subject: Add SM2 signature scheme From https://tools.ietf.org/html/draft-shen-sm2-ecdsa-02 This is a contribution from Ribose Inc (@riboseinc). --- src/cli/speed.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/cli/speed.cpp') 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 #endif +#if defined(BOTAN_HAS_SM2) + #include +#endif + #if defined(BOTAN_HAS_NEWHOPE) && defined(BOTAN_HAS_CHACHA) #include #include @@ -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& 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 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& groups, const std::string& provider, -- cgit v1.2.3