aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-02 13:47:06 +0000
committerlloyd <[email protected]>2010-03-02 13:47:06 +0000
commit23a0b9af002a0126ff1fdfc54e16045c84b2f43d (patch)
tree0acf31d94fa17a589e0a5d5e2d3885dd6a9613b0
parentd723232f03eb5073bdf245e0502434ebadbee1cd (diff)
Add GOST 34.10 benchmarks. Kill of last bits of ECKAEG terminology.
-rw-r--r--checks/ecdh.cpp (renamed from checks/eckaeg.cpp)24
-rw-r--r--checks/pk.cpp2
-rw-r--r--checks/pk_bench.cpp88
-rw-r--r--checks/validate.h2
4 files changed, 92 insertions, 24 deletions
diff --git a/checks/eckaeg.cpp b/checks/ecdh.cpp
index 748663eb6..9f98fa56e 100644
--- a/checks/eckaeg.cpp
+++ b/checks/ecdh.cpp
@@ -30,7 +30,7 @@ using namespace Botan;
namespace {
-void test_eckaeg_normal_derivation(RandomNumberGenerator& rng)
+void test_ecdh_normal_derivation(RandomNumberGenerator& rng)
{
std::cout << "." << std::flush;
@@ -87,7 +87,7 @@ void test_eckaeg_normal_derivation(RandomNumberGenerator& rng)
}
}
-void test_eckaeg_some_dp(RandomNumberGenerator& rng)
+void test_ecdh_some_dp(RandomNumberGenerator& rng)
{
std::vector<std::string> oids;
oids.push_back("1.2.840.10045.3.1.7");
@@ -126,7 +126,7 @@ void test_eckaeg_some_dp(RandomNumberGenerator& rng)
}
-void test_eckaeg_der_derivation(RandomNumberGenerator& rng)
+void test_ecdh_der_derivation(RandomNumberGenerator& rng)
{
std::vector<std::string> oids;
oids.push_back("1.2.840.10045.3.1.7");
@@ -156,7 +156,7 @@ void test_eckaeg_der_derivation(RandomNumberGenerator& rng)
/**
* The following test tests the copy ctors and and copy-assignment operators
*/
-void test_eckaeg_cp_ctor_as_op(RandomNumberGenerator& rng)
+void test_ecdh_cp_ctor_as_op(RandomNumberGenerator& rng)
{
std::cout << "." << std::flush;
@@ -214,7 +214,7 @@ void test_eckaeg_cp_ctor_as_op(RandomNumberGenerator& rng)
* The following test tests whether ECDH keys exhibit correct behaviour when it is
* attempted to use them in an uninitialized state
*/
-void test_non_init_eckaeg_keys(RandomNumberGenerator& rng)
+void test_non_init_ecdh_keys(RandomNumberGenerator& rng)
{
std::cout << "." << std::flush;
@@ -266,15 +266,15 @@ void test_non_init_eckaeg_keys(RandomNumberGenerator& rng)
}
-u32bit do_eckaeg_tests(Botan::RandomNumberGenerator& rng)
+u32bit do_ecdh_tests(Botan::RandomNumberGenerator& rng)
{
std::cout << "Testing ECDH (InSiTo unit tests): ";
- test_eckaeg_normal_derivation(rng);
- test_eckaeg_some_dp(rng);
- test_eckaeg_der_derivation(rng);
- test_eckaeg_cp_ctor_as_op(rng);
- test_non_init_eckaeg_keys(rng);
+ test_ecdh_normal_derivation(rng);
+ test_ecdh_some_dp(rng);
+ test_ecdh_der_derivation(rng);
+ test_ecdh_cp_ctor_as_op(rng);
+ test_non_init_ecdh_keys(rng);
std::cout << std::endl;
@@ -282,5 +282,5 @@ u32bit do_eckaeg_tests(Botan::RandomNumberGenerator& rng)
}
#else
-u32bit do_eckaeg_tests(Botan::RandomNumberGenerator&) { return 0; }
+u32bit do_ecdh_tests(Botan::RandomNumberGenerator&) { return 0; }
#endif
diff --git a/checks/pk.cpp b/checks/pk.cpp
index 07e6aeb10..4a2005b81 100644
--- a/checks/pk.cpp
+++ b/checks/pk.cpp
@@ -771,7 +771,7 @@ u32bit do_pk_validation_tests(const std::string& filename,
do_ec_tests(rng);
errors += do_ecdsa_tests(rng);
- errors += do_eckaeg_tests(rng);
+ errors += do_ecdh_tests(rng);
do_pk_keygen_tests(rng);
do_x509_tests(rng);
diff --git a/checks/pk_bench.cpp b/checks/pk_bench.cpp
index e0970ebfb..322e643cc 100644
--- a/checks/pk_bench.cpp
+++ b/checks/pk_bench.cpp
@@ -49,6 +49,10 @@
#include <botan/ecdh.h>
#endif
+#if defined(BOTAN_HAS_GOST_34_10_2001)
+ #include <botan/gost_3410.h>
+#endif
+
using namespace Botan;
#include "common.h"
@@ -338,11 +342,70 @@ void benchmark_ecdsa(RandomNumberGenerator& rng,
#endif
+#if defined(BOTAN_HAS_GOST_34_10_2001)
+
+void benchmark_gost_3410(RandomNumberGenerator& rng,
+ double seconds,
+ Benchmark_Report& report)
+ {
+ const char* domains[] = { "1.3.132.0.6", // secp112r1
+ "1.3.132.0.28", // secp128r1
+ "1.3.132.0.30", // secp160r2
+ "1.3.132.0.33", // secp224r1
+ "1.2.643.2.2.35.1", // gost 256p
+ "1.3.132.0.34", // secp384r1
+ "1.3.132.0.35", // secp512r1
+ NULL };
+
+ for(size_t j = 0; domains[j]; j++)
+ {
+ OID oid(domains[j]);
+ EC_Domain_Params params(oid);
+
+ u32bit pbits = params.get_curve().get_p().bits();
+
+ u32bit hashbits = pbits;
+
+ if(hashbits < 160)
+ hashbits = 160;
+ if(hashbits == 521)
+ hashbits = 512;
+
+ const std::string padding = "EMSA1(SHA-" + to_string(hashbits) + ")";
+
+ Timer keygen_timer("keygen");
+ Timer verify_timer(padding + " verify");
+ Timer sig_timer(padding + " signature");
+
+ while(verify_timer.seconds() < seconds ||
+ sig_timer.seconds() < seconds)
+ {
+ keygen_timer.start();
+ GOST_3410_PrivateKey key(rng, params);
+ keygen_timer.stop();
+
+ std::auto_ptr<PK_Signer> sig(get_pk_signer(key, padding));
+ std::auto_ptr<PK_Verifier> ver(get_pk_verifier(key, padding));
+
+ benchmark_sig_ver(*ver, *sig, verify_timer,
+ sig_timer, rng, 1000, seconds);
+ }
+
+ const std::string nm = "GOST-34.10-" + to_string(pbits);
+
+ report.report(nm, keygen_timer);
+ report.report(nm, verify_timer);
+ report.report(nm, sig_timer);
+ }
+ }
+
+#endif
+
#if defined(BOTAN_HAS_ECDH)
-void benchmark_eckaeg(RandomNumberGenerator& rng,
- double seconds,
- Benchmark_Report& report)
+void benchmark_ecdh(RandomNumberGenerator& rng,
+ double seconds,
+ Benchmark_Report& report)
{
const char* domains[] = { "1.3.132.0.6", // secp112r1
"1.3.132.0.28", // secp128r1
@@ -365,15 +428,15 @@ void benchmark_eckaeg(RandomNumberGenerator& rng,
while(kex_timer.seconds() < seconds)
{
keygen_timer.start();
- ECDH_PrivateKey eckaeg1(rng, params);
+ ECDH_PrivateKey ecdh1(rng, params);
keygen_timer.stop();
keygen_timer.start();
- ECDH_PrivateKey eckaeg2(rng, params);
+ ECDH_PrivateKey ecdh2(rng, params);
keygen_timer.stop();
- ECDH_PublicKey pub1(eckaeg1);
- ECDH_PublicKey pub2(eckaeg2);
+ ECDH_PublicKey pub1(ecdh1);
+ ECDH_PublicKey pub2(ecdh2);
SecureVector<byte> secret1, secret2;
@@ -383,11 +446,11 @@ void benchmark_eckaeg(RandomNumberGenerator& rng,
break;
kex_timer.start();
- secret1 = eckaeg1.derive_key(pub2);
+ secret1 = ecdh1.derive_key(pub2);
kex_timer.stop();
kex_timer.start();
- secret2 = eckaeg2.derive_key(pub1);
+ secret2 = ecdh2.derive_key(pub1);
kex_timer.stop();
if(secret1 != secret2)
@@ -674,7 +737,12 @@ void bench_pk(RandomNumberGenerator& rng,
#if defined(BOTAN_HAS_ECDH)
if(algo == "All" || algo == "ECDH")
- benchmark_eckaeg(rng, seconds, report);
+ benchmark_ecdh(rng, seconds, report);
+#endif
+
+#if defined(BOTAN_HAS_GOST_34_10_2001)
+ if(algo == "All" || algo == "GOST-34.10")
+ benchmark_gost_3410(rng, seconds, report);
#endif
#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
diff --git a/checks/validate.h b/checks/validate.h
index b0e3565f8..9e34d64fb 100644
--- a/checks/validate.h
+++ b/checks/validate.h
@@ -23,7 +23,7 @@ u32bit do_pk_validation_tests(const std::string&,
void do_ec_tests(RandomNumberGenerator& rng);
u32bit do_ecdsa_tests(RandomNumberGenerator& rng);
-u32bit do_eckaeg_tests(RandomNumberGenerator& rng);
+u32bit do_ecdh_tests(RandomNumberGenerator& rng);
u32bit do_cvc_tests(RandomNumberGenerator& rng);
void do_x509_tests(RandomNumberGenerator&);