diff options
author | Jack Lloyd <[email protected]> | 2015-10-14 19:23:55 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-10-14 19:23:55 -0400 |
commit | 4e90017c204d3297df1444af59337db89f8180d9 (patch) | |
tree | f5a54d34b13035a4fda1a0ec7fd27c3791f6080d /src/cmd | |
parent | 4bfd5d6828f23e0eef04e5cf079c323274136499 (diff) |
Expose providers for public key operations
For PK_Encryptor and company they are requested via a new provider param
to the constructors.
The speed command gets a --provider option so you can see benchmark results
with the different versions.
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/implementation/speed.h | 4 | ||||
-rw-r--r-- | src/cmd/implementation/speed_public_key.cpp | 30 | ||||
-rw-r--r-- | src/cmd/speed.cpp | 13 |
3 files changed, 29 insertions, 18 deletions
diff --git a/src/cmd/implementation/speed.h b/src/cmd/implementation/speed.h index 1f082eb52..3cfd0ef61 100644 --- a/src/cmd/implementation/speed.h +++ b/src/cmd/implementation/speed.h @@ -13,7 +13,9 @@ #include <chrono> void benchmark_public_key(Botan::RandomNumberGenerator& rng, - const std::string& algo, double seconds); + const std::string& algo, + const std::string& provider, + double seconds); std::map<std::string, double> benchmark_is_prime(Botan::RandomNumberGenerator &rng, const std::chrono::milliseconds runtime); diff --git a/src/cmd/implementation/speed_public_key.cpp b/src/cmd/implementation/speed_public_key.cpp index 83c0156ae..00bf4b438 100644 --- a/src/cmd/implementation/speed_public_key.cpp +++ b/src/cmd/implementation/speed_public_key.cpp @@ -202,7 +202,8 @@ void benchmark_sig_ver(PK_Verifier& ver, PK_Signer& sig, */ #if defined(BOTAN_HAS_RSA) -void benchmark_rsa(RandomNumberGenerator& rng, +void benchmark_rsa(const std::string& provider, + RandomNumberGenerator& rng, double seconds, Benchmark_Report& report) { @@ -213,8 +214,8 @@ void benchmark_rsa(RandomNumberGenerator& rng, { size_t keylen = keylens[i]; - //const std::string sig_padding = "EMSA4(SHA-1)"; - //const std::string enc_padding = "EME1(SHA-1)"; + //const std::string sig_padding = "PSSR(SHA-256)"; + //const std::string enc_padding = "OAEP(SHA-1)"; const std::string sig_padding = "EMSA-PKCS1-v1_5(SHA-1)"; const std::string enc_padding = "EME-PKCS1-v1_5"; @@ -243,14 +244,14 @@ void benchmark_rsa(RandomNumberGenerator& rng, while(verify_timer.seconds() < seconds || sig_timer.seconds() < seconds) { - PK_Encryptor_EME enc(key, enc_padding); - PK_Decryptor_EME dec(key, enc_padding); + PK_Encryptor_EME enc(key, enc_padding, provider); + PK_Decryptor_EME dec(key, enc_padding, provider); benchmark_enc_dec(enc, dec, enc_timer, dec_timer, rng, 10000, seconds); - PK_Signer sig(key, sig_padding); - PK_Verifier ver(key, sig_padding); + PK_Signer sig(key, sig_padding, IEEE_1363); + PK_Verifier ver(key, sig_padding, IEEE_1363); benchmark_sig_ver(ver, sig, verify_timer, sig_timer, rng, 10000, seconds); @@ -318,7 +319,8 @@ void benchmark_rw(RandomNumberGenerator& rng, #if defined(BOTAN_HAS_ECDSA) -void benchmark_ecdsa(RandomNumberGenerator& rng, +void benchmark_ecdsa(const std::string& provider, + RandomNumberGenerator& rng, double seconds, Benchmark_Report& report) { @@ -348,8 +350,8 @@ void benchmark_ecdsa(RandomNumberGenerator& rng, ECDSA_PrivateKey key(rng, params); keygen_timer.stop(); - PK_Signer sig(key, padding, IEEE_1363); - PK_Verifier ver(key, padding); + PK_Signer sig(key, padding, IEEE_1363, provider); + PK_Verifier ver(key, padding, IEEE_1363, provider); benchmark_sig_ver(ver, sig, verify_timer, sig_timer, rng, 1000, seconds); @@ -791,7 +793,9 @@ void benchmark_mce(RandomNumberGenerator& rng, } void benchmark_public_key(RandomNumberGenerator& rng, - const std::string& algo, double seconds) + const std::string& algo, + const std::string& provider, + double seconds) { /* There is some strangeness going on here. It looks like algorithms @@ -823,7 +827,7 @@ void benchmark_public_key(RandomNumberGenerator& rng, #if defined(BOTAN_HAS_RSA) if(algo == "All" || algo == "RSA") - benchmark_rsa(rng, seconds, report); + benchmark_rsa(provider, rng, seconds, report); #endif #if defined(BOTAN_HAS_DSA) @@ -833,7 +837,7 @@ void benchmark_public_key(RandomNumberGenerator& rng, #if defined(BOTAN_HAS_ECDSA) if(algo == "All" || algo == "ECDSA") - benchmark_ecdsa(rng, seconds, report); + benchmark_ecdsa(provider, rng, seconds, report); #endif #if defined(BOTAN_HAS_ECDH) diff --git a/src/cmd/speed.cpp b/src/cmd/speed.cpp index 91b2f4fbd..990c6a364 100644 --- a/src/cmd/speed.cpp +++ b/src/cmd/speed.cpp @@ -118,6 +118,7 @@ void report_results(const std::string& algo, } void bench_algo(const std::string& algo, + const std::string& provider, RandomNumberGenerator& rng, double seconds, size_t buf_size) @@ -151,7 +152,7 @@ void bench_algo(const std::string& algo, catch (No_Provider_Found) { #if defined(BOTAN_HAS_PUBLIC_KEY_CRYPTO) - benchmark_public_key(rng, algo, seconds); + benchmark_public_key(rng, algo, provider, seconds); #endif } } @@ -159,7 +160,7 @@ void bench_algo(const std::string& algo, int speed(int argc, char* argv[]) { BOTAN_UNUSED(argc); - OptionParser opts("seconds=|buf-size="); + OptionParser opts("seconds=|buf-size=|provider="); opts.parse(argv); double seconds = .5; @@ -185,7 +186,9 @@ int speed(int argc, char* argv[]) } } - auto args = opts.arguments(); + const std::string provider = opts.value_if_set("provider"); + + std::vector<std::string> args = opts.arguments(); if(args.empty()) args = default_benchmark_list; @@ -199,7 +202,9 @@ int speed(int argc, char* argv[]) AutoSeeded_RNG rng; for(auto alg: args) - bench_algo(alg, rng, seconds, buf_size); + { + bench_algo(alg, provider, rng, seconds, buf_size); + } return 0; } |