diff options
author | Jack Lloyd <[email protected]> | 2018-02-18 16:29:27 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-02-18 16:29:27 -0500 |
commit | 9792c0eb8203a4982d28afebb19b027444753f90 (patch) | |
tree | e28766f6678d37573cde3ea1213dacfad2f19d78 /src/cli | |
parent | 238ec6202d1fc6d402ac124cc51a8b8856402f04 (diff) |
Add benchmarks for ElGamal and DSA
Weird these didn't already exist
Diffstat (limited to 'src/cli')
-rw-r--r-- | src/cli/speed.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp index e6ea877e0..78cbdccf6 100644 --- a/src/cli/speed.cpp +++ b/src/cli/speed.cpp @@ -799,6 +799,18 @@ class Speed final : public Command bench_dh(provider, msec); } #endif +#if defined(BOTAN_HAS_DSA) + else if(algo == "DSA") + { + bench_dsa(provider, msec); + } +#endif +#if defined(BOTAN_HAS_ELGAMAL) + else if(algo == "ElGamal") + { + bench_elgamal(provider, msec); + } +#endif #if defined(BOTAN_HAS_ECDH) else if(algo == "ECDH") { @@ -1730,6 +1742,53 @@ class Speed final : public Command } #endif +#if defined(BOTAN_HAS_DSA) + void bench_dsa(const std::string& provider, std::chrono::milliseconds msec) + { + for(size_t bits : { 1024, 2048, 3072 }) + { + const std::string nm = "DSA-" + std::to_string(bits); + + const std::string params = + (bits == 1024) ? "dsa/jce/1024" : ("dsa/botan/" + std::to_string(bits)); + + Timer keygen_timer(nm, provider, "keygen"); + + std::unique_ptr<Botan::Private_Key> key(keygen_timer.run([&] + { + return Botan::create_private_key("DSA", rng(), params); + })); + + record_result(keygen_timer); + + bench_pk_sig(*key, nm, provider, "EMSA1(SHA-256)", msec); + } + } +#endif + +#if defined(BOTAN_HAS_ELGAMAL) + void bench_elgamal(const std::string& provider, std::chrono::milliseconds msec) + { + for(size_t keylen : { 1024, 2048, 3072, 4096 }) + { + const std::string nm = "ElGamal-" + std::to_string(keylen); + + const std::string params = "modp/ietf/" + std::to_string(keylen); + + Timer keygen_timer(nm, provider, "keygen"); + + std::unique_ptr<Botan::Private_Key> key(keygen_timer.run([&] + { + return Botan::create_private_key("ElGamal", rng(), params); + })); + + record_result(keygen_timer); + + bench_pk_enc(*key, nm, provider, "EME-PKCS1-v1_5", msec); + } + } +#endif + #if defined(BOTAN_HAS_ECDH) void bench_ecdh(const std::vector<std::string>& groups, const std::string& provider, |