aboutsummaryrefslogtreecommitdiffstats
path: root/checks
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-09 02:53:56 +0000
committerlloyd <[email protected]>2010-03-09 02:53:56 +0000
commitcdcd3a9aba28cefcccb64f91fb56d3847f6c9130 (patch)
tree6f4efd137aad848e698f9f4fc48a8bc9145fea12 /checks
parent4a9afbb99bb73e43bcb3a30379d6a2dd59dae76a (diff)
parent3c15bd259f0921f1fa08ec91ee3cf2621c64a02d (diff)
propagate from branch 'net.randombit.botan' (head 9932d4d63417f7fcc199ada244cbaa6c1c32d9c1)
to branch 'net.randombit.botan.c++0x' (head f4a385a376311edc62ef506c72cc56f69e6efd5a)
Diffstat (limited to 'checks')
-rw-r--r--checks/bench.cpp19
-rw-r--r--checks/cvc_tests.cpp21
-rw-r--r--checks/ec_tests.cpp4
-rw-r--r--checks/ecdsa.cpp12
-rw-r--r--checks/pk.cpp8
-rw-r--r--checks/pk_bench.cpp16
-rw-r--r--checks/timer.cpp5
7 files changed, 47 insertions, 38 deletions
diff --git a/checks/bench.cpp b/checks/bench.cpp
index cfb44070d..9b917c99d 100644
--- a/checks/bench.cpp
+++ b/checks/bench.cpp
@@ -14,7 +14,10 @@
#include <botan/engine.h>
#include <botan/parsing.h>
#include <botan/symkey.h>
-#include <botan/time.h>
+
+#include <chrono>
+
+typedef std::chrono::high_resolution_clock benchmark_clock;
#include "common.h"
#include "bench.h"
@@ -206,17 +209,23 @@ bool bench_algo(const std::string& algo,
Botan::Pipe pipe(filt, new Botan::BitBucket);
pipe.start_msg();
- const u64bit start = Botan::get_nanoseconds_clock();
- u64bit nanoseconds_used = 0;
+ std::chrono::nanoseconds max_time(nanoseconds_max);
+ std::chrono::nanoseconds time_used(0);
+
+ auto start = benchmark_clock::now();
+
u64bit reps = 0;
- while(nanoseconds_used < nanoseconds_max)
+ while(time_used < max_time)
{
pipe.write(&buf[0], buf.size());
++reps;
- nanoseconds_used = Botan::get_nanoseconds_clock() - start;
+ time_used = benchmark_clock::now() - start;
}
+ u64bit nanoseconds_used =
+ std::chrono::duration_cast<std::chrono::nanoseconds>(time_used).count();
+
double mbytes_per_second =
(953.67 * (buf.size() * reps)) / nanoseconds_used;
diff --git a/checks/cvc_tests.cpp b/checks/cvc_tests.cpp
index 5bd671ba6..68b669996 100644
--- a/checks/cvc_tests.cpp
+++ b/checks/cvc_tests.cpp
@@ -161,8 +161,8 @@ void test_enc_gen_selfsigned(RandomNumberGenerator& rng)
}
CHECK(ill_date_exc2);
//cout << "readable = '" << cert_in.get_ced().readable_string() << "'\n";
- std::auto_ptr<Public_Key> p_pk = cert_in.subject_public_key();
- //auto_ptr<ECDSA_PublicKey> ecdsa_pk = dynamic_cast<auto_ptr<ECDSA_PublicKey> >(p_pk);
+ std::unique_ptr<Public_Key> p_pk = cert_in.subject_public_key();
+ //unique_ptr<ECDSA_PublicKey> ecdsa_pk = dynamic_cast<auto_ptr<ECDSA_PublicKey> >(p_pk);
ECDSA_PublicKey* p_ecdsa_pk = dynamic_cast<ECDSA_PublicKey*>(p_pk.get());
// let´s see if encoding is truely implicitca, because this is what the key should have
// been set to when decoding (see above)(because it has no domain params):
@@ -180,7 +180,7 @@ void test_enc_gen_selfsigned(RandomNumberGenerator& rng)
CHECK(exc);
// set them and try again
//cert_in.set_domain_parameters(dom_pars);
- std::auto_ptr<Public_Key> p_pk2 = cert_in.subject_public_key();
+ std::unique_ptr<Public_Key> p_pk2 = cert_in.subject_public_key();
ECDSA_PublicKey* p_ecdsa_pk2 = dynamic_cast<ECDSA_PublicKey*>(p_pk2.get());
//p_ecdsa_pk2->set_domain_parameters(dom_pars);
CHECK(p_ecdsa_pk2->domain().get_order() == dom_pars.get_order());
@@ -211,7 +211,7 @@ void test_enc_gen_req(RandomNumberGenerator& rng)
// read and check signature...
EAC1_1_Req req_in(TEST_DATA_DIR "/my_cv_req.ber");
//req_in.set_domain_parameters(dom_pars);
- std::auto_ptr<Public_Key> p_pk = req_in.subject_public_key();
+ std::unique_ptr<Public_Key> p_pk = req_in.subject_public_key();
ECDSA_PublicKey* p_ecdsa_pk = dynamic_cast<ECDSA_PublicKey*>(p_pk.get());
//p_ecdsa_pk->set_domain_parameters(dom_pars);
CHECK(p_ecdsa_pk->domain().get_order() == dom_pars.get_order());
@@ -226,7 +226,7 @@ void test_cvc_req_ext(RandomNumberGenerator&)
EAC1_1_Req req_in(TEST_DATA_DIR "/DE1_flen_chars_cvcRequest_ECDSA.der");
EC_Domain_Params dom_pars(OID("1.3.36.3.3.2.8.1.1.5")); // "german curve"
//req_in.set_domain_parameters(dom_pars);
- std::auto_ptr<Public_Key> p_pk = req_in.subject_public_key();
+ std::unique_ptr<Public_Key> p_pk = req_in.subject_public_key();
ECDSA_PublicKey* p_ecdsa_pk = dynamic_cast<ECDSA_PublicKey*>(p_pk.get());
//p_ecdsa_pk->set_domain_parameters(dom_pars);
CHECK(p_ecdsa_pk->domain().get_order() == dom_pars.get_order());
@@ -348,8 +348,7 @@ void test_eac_time(RandomNumberGenerator&)
{
std::cout << "." << std::flush;
- const u64bit current_time = system_time();
- EAC_Time time(current_time);
+ EAC_Time time(std::chrono::system_clock::now());
// std::cout << "time as std::string = " << time.as_string() << std::endl;
EAC_Time sooner("", ASN1_Tag(99));
//X509_Time sooner("", ASN1_Tag(99));
@@ -388,11 +387,11 @@ void test_ver_cvca(RandomNumberGenerator&)
EAC1_1_CVC req_in(TEST_DATA_DIR "/cvca01.cv.crt");
- //auto_ptr<ECDSA_PublicKey> ecdsa_pk = dynamic_cast<auto_ptr<ECDSA_PublicKey> >(p_pk);
+ //unique_ptr<ECDSA_PublicKey> ecdsa_pk = dynamic_cast<auto_ptr<ECDSA_PublicKey> >(p_pk);
//ECDSA_PublicKey* p_ecdsa_pk = dynamic_cast<ECDSA_PublicKey*>(p_pk.get());
bool exc = false;
- std::auto_ptr<Public_Key> p_pk2 = req_in.subject_public_key();
+ std::unique_ptr<Public_Key> p_pk2 = req_in.subject_public_key();
ECDSA_PublicKey* p_ecdsa_pk2 = dynamic_cast<ECDSA_PublicKey*>(p_pk2.get());
bool ver_ec = req_in.check_signature(*p_pk2);
CHECK_MESSAGE(ver_ec, "could not positively verify correct selfsigned cvca certificate");
@@ -510,7 +509,7 @@ void test_cvc_chain(RandomNumberGenerator& rng)
CHECK(link12.check_signature(cvca_privk));
EAC1_1_CVC link12_reloaded(TEST_DATA_DIR "/cvc_chain_link12.cer");
EAC1_1_CVC cvca1_reloaded(TEST_DATA_DIR "/cvc_chain_cvca.cer");
- std::auto_ptr<Public_Key> cvca1_rel_pk = cvca1_reloaded.subject_public_key();
+ std::unique_ptr<Public_Key> cvca1_rel_pk = cvca1_reloaded.subject_public_key();
CHECK(link12_reloaded.check_signature(*cvca1_rel_pk));
// create first round dvca-req
@@ -540,7 +539,7 @@ void test_cvc_chain(RandomNumberGenerator& rng)
// verify the ado and sign the request too
- std::auto_ptr<Public_Key> ap_pk = dvca_cert1.subject_public_key();
+ std::unique_ptr<Public_Key> ap_pk = dvca_cert1.subject_public_key();
ECDSA_PublicKey* cert_pk = dynamic_cast<ECDSA_PublicKey*>(ap_pk.get());
//cert_pk->set_domain_parameters(dom_pars);
diff --git a/checks/ec_tests.cpp b/checks/ec_tests.cpp
index 0532e35fe..485639e76 100644
--- a/checks/ec_tests.cpp
+++ b/checks/ec_tests.cpp
@@ -679,11 +679,11 @@ void test_enc_dec_uncompressed_521_prime_too_large()
BigInt bi_b_secp = BigInt::decode ( sv_b_secp.begin(), sv_b_secp.size() );
CurveGFp secp521r1 (bi_p_secp, bi_a_secp, bi_b_secp);
- std::auto_ptr<PointGFp> p_G;
+ std::unique_ptr<PointGFp> p_G;
bool exc = false;
try
{
- p_G = std::auto_ptr<PointGFp>(new PointGFp(OS2ECP ( sv_G_secp_uncomp, secp521r1)));
+ p_G = std::unique_ptr<PointGFp>(new PointGFp(OS2ECP ( sv_G_secp_uncomp, secp521r1)));
p_G->check_invariants();
}
catch (std::exception e)
diff --git a/checks/ecdsa.cpp b/checks/ecdsa.cpp
index d46ebb25e..7e585b584 100644
--- a/checks/ecdsa.cpp
+++ b/checks/ecdsa.cpp
@@ -126,7 +126,7 @@ void test_decode_ecdsa_X509()
CHECK_MESSAGE(to_hex(cert.authority_key_id()) == "0096452DE588F966C4CCDF161DD1F3F5341B71E7", "error reading authority key id from x509 ecdsa certificate");
CHECK_MESSAGE(to_hex(cert.subject_key_id()) == "0096452DE588F966C4CCDF161DD1F3F5341B71E7", "error reading Subject key id from x509 ecdsa certificate");
- std::auto_ptr<X509_PublicKey> pubkey(cert.subject_public_key());
+ std::unique_ptr<X509_PublicKey> pubkey(cert.subject_public_key());
bool ver_ec = cert.check_signature(*pubkey);
CHECK_MESSAGE(ver_ec, "could not positively verify correct selfsigned x509-ecdsa certificate");
}
@@ -138,7 +138,7 @@ void test_decode_ver_link_SHA256()
X509_Certificate root_cert(TEST_DATA_DIR "/root2_SHA256.cer");
X509_Certificate link_cert(TEST_DATA_DIR "/link_SHA256.cer");
- std::auto_ptr<X509_PublicKey> pubkey(root_cert.subject_public_key());
+ std::unique_ptr<X509_PublicKey> pubkey(root_cert.subject_public_key());
bool ver_ec = link_cert.check_signature(*pubkey);
CHECK_MESSAGE(ver_ec, "could not positively verify correct SHA256 link x509-ecdsa certificate");
@@ -150,7 +150,7 @@ void test_decode_ver_link_SHA1()
X509_Certificate root_cert(TEST_DATA_DIR "/root_SHA1.163.crt");
X509_Certificate link_cert(TEST_DATA_DIR "/link_SHA1.166.crt");
- std::auto_ptr<X509_PublicKey> pubkey(root_cert.subject_public_key());
+ std::unique_ptr<X509_PublicKey> pubkey(root_cert.subject_public_key());
bool ver_ec = link_cert.check_signature(*pubkey);
CHECK_MESSAGE(ver_ec, "could not positively verify correct SHA1 link x509-ecdsa certificate");
}
@@ -273,11 +273,11 @@ void test_create_and_verify(RandomNumberGenerator& rng)
std::ofstream priv_key(TEST_DATA_DIR "/dompar_private.pkcs8.pem");
priv_key << PKCS8::PEM_encode(key);
- std::auto_ptr<PKCS8_PrivateKey> loaded_key(PKCS8::load_key(TEST_DATA_DIR "/wo_dompar_private.pkcs8.pem", rng));
+ std::unique_ptr<PKCS8_PrivateKey> loaded_key(PKCS8::load_key(TEST_DATA_DIR "/wo_dompar_private.pkcs8.pem", rng));
ECDSA_PrivateKey* loaded_ec_key = dynamic_cast<ECDSA_PrivateKey*>(loaded_key.get());
CHECK_MESSAGE(loaded_ec_key, "the loaded key could not be converted into an ECDSA_PrivateKey");
- std::auto_ptr<PKCS8_PrivateKey> loaded_key_1(PKCS8::load_key(TEST_DATA_DIR "/rsa_private.pkcs8.pem", rng));
+ std::unique_ptr<PKCS8_PrivateKey> loaded_key_1(PKCS8::load_key(TEST_DATA_DIR "/rsa_private.pkcs8.pem", rng));
ECDSA_PrivateKey* loaded_rsa_key = dynamic_cast<ECDSA_PrivateKey*>(loaded_key_1.get());
CHECK_MESSAGE(!loaded_rsa_key, "the loaded key is ECDSA_PrivateKey -> shouldn't be, is a RSA-Key");
@@ -310,7 +310,7 @@ void test_create_and_verify(RandomNumberGenerator& rng)
std::string key_odd_oid_str = PKCS8::PEM_encode(key_odd_oid);
DataSource_Memory key_data_src(key_odd_oid_str);
- std::auto_ptr<PKCS8_PrivateKey> loaded_key2(PKCS8::load_key(key_data_src, rng));
+ std::unique_ptr<PKCS8_PrivateKey> loaded_key2(PKCS8::load_key(key_data_src, rng));
if(!dynamic_cast<ECDSA_PrivateKey*>(loaded_key.get()))
{
diff --git a/checks/pk.cpp b/checks/pk.cpp
index bc1308f1c..da6c6277d 100644
--- a/checks/pk.cpp
+++ b/checks/pk.cpp
@@ -238,7 +238,7 @@ u32bit validate_rsa_enc_pkcs8(const std::string& algo,
DataSource_Memory keysource(reinterpret_cast<const byte*>(str[0].c_str()),
str[0].length());
- std::auto_ptr<Private_Key> privkey(PKCS8::load_key(keysource, rng, pass));
+ std::unique_ptr<Private_Key> privkey(PKCS8::load_key(keysource, rng, pass));
RSA_PrivateKey* rsapriv = dynamic_cast<RSA_PrivateKey*>(privkey.get());
if(!rsapriv)
@@ -379,7 +379,7 @@ u32bit validate_rsa_ver_x509(const std::string& algo,
DataSource_Memory keysource(reinterpret_cast<const byte*>(str[0].c_str()),
str[0].length());
- std::auto_ptr<Public_Key> key(X509::load_key(keysource));
+ std::unique_ptr<Public_Key> key(X509::load_key(keysource));
RSA_PublicKey* rsakey = dynamic_cast<RSA_PublicKey*>(key.get());
@@ -467,7 +467,7 @@ u32bit validate_dsa_sig(const std::string& algo,
DataSource_Memory keysource(reinterpret_cast<const byte*>(str[0].c_str()),
str[0].length());
- std::auto_ptr<Private_Key> privkey(PKCS8::load_key(keysource, rng, pass));
+ std::unique_ptr<Private_Key> privkey(PKCS8::load_key(keysource, rng, pass));
DSA_PrivateKey* dsapriv = dynamic_cast<DSA_PrivateKey*>(privkey.get());
if(!dsapriv)
@@ -523,7 +523,7 @@ u32bit validate_dsa_ver(const std::string& algo,
#if defined(BOTAN_HAS_DSA)
- std::auto_ptr<Public_Key> key(X509::load_key(keysource));
+ std::unique_ptr<Public_Key> key(X509::load_key(keysource));
DSA_PublicKey* dsakey = dynamic_cast<DSA_PublicKey*>(key.get());
diff --git a/checks/pk_bench.cpp b/checks/pk_bench.cpp
index c9e79e997..a180778a6 100644
--- a/checks/pk_bench.cpp
+++ b/checks/pk_bench.cpp
@@ -227,7 +227,7 @@ void benchmark_rsa(RandomNumberGenerator& rng,
sig_timer, rng, 10000, seconds);
}
- const std::string rsa_keylen = "RSA-" + to_string(keylen);
+ const std::string rsa_keylen = "RSA-" + std::to_string(keylen);
report.report(rsa_keylen, keygen_timer);
report.report(rsa_keylen, verify_timer);
@@ -279,7 +279,7 @@ void benchmark_rw(RandomNumberGenerator& rng,
rng, 10000, seconds);
}
- const std::string nm = "RW-" + to_string(keylen);
+ const std::string nm = "RW-" + std::to_string(keylen);
report.report(nm, keygen_timer);
report.report(nm, verify_timer);
report.report(nm, sig_timer);
@@ -315,7 +315,7 @@ void benchmark_ecdsa(RandomNumberGenerator& rng,
if(hashbits == 521)
hashbits = 512;
- const std::string padding = "EMSA1(SHA-" + to_string(hashbits) + ")";
+ const std::string padding = "EMSA1(SHA-" + std::to_string(hashbits) + ")";
Timer keygen_timer("keygen");
Timer verify_timer(padding + " verify");
@@ -335,7 +335,7 @@ void benchmark_ecdsa(RandomNumberGenerator& rng,
sig_timer, rng, 1000, seconds);
}
- const std::string nm = "ECDSA-" + to_string(pbits);
+ const std::string nm = "ECDSA-" + std::to_string(pbits);
report.report(nm, keygen_timer);
report.report(nm, verify_timer);
@@ -461,7 +461,7 @@ void benchmark_ecdh(RandomNumberGenerator& rng,
}
}
- const std::string nm = "ECDH-" + to_string(pbits);
+ const std::string nm = "ECDH-" + std::to_string(pbits);
report.report(nm, keygen_timer);
report.report(nm, kex_timer);
}
@@ -489,7 +489,7 @@ void benchmark_dsa_nr(RandomNumberGenerator& rng,
u32bit pbits = to_u32bit(split_on(domains[j], '/')[2]);
u32bit qbits = (pbits <= 1024) ? 160 : 256;
- const std::string padding = "EMSA1(SHA-" + to_string(qbits) + ")";
+ const std::string padding = "EMSA1(SHA-" + std::to_string(qbits) + ")";
Timer keygen_timer("keygen");
Timer verify_timer(padding + " verify");
@@ -512,7 +512,7 @@ void benchmark_dsa_nr(RandomNumberGenerator& rng,
sig_timer, rng, 1000, seconds);
}
- const std::string nm = algo_name + "-" + to_string(pbits);
+ const std::string nm = algo_name + "-" + std::to_string(pbits);
report.report(nm, keygen_timer);
report.report(nm, verify_timer);
report.report(nm, sig_timer);
@@ -682,7 +682,7 @@ void benchmark_elg(RandomNumberGenerator& rng,
rng, 1000, seconds);
}
- const std::string nm = algo_name + "-" + to_string(pbits);
+ const std::string nm = algo_name + "-" + std::to_string(pbits);
report.report(nm, keygen_timer);
report.report(nm, enc_timer);
report.report(nm, dec_timer);
diff --git a/checks/timer.cpp b/checks/timer.cpp
index 3736a4779..9f3d34607 100644
--- a/checks/timer.cpp
+++ b/checks/timer.cpp
@@ -5,7 +5,7 @@
*/
#include "timer.h"
-#include <botan/time.h>
+#include <chrono>
#include <iomanip>
Timer::Timer(const std::string& n, u32bit e_mul) :
@@ -38,7 +38,8 @@ void Timer::stop()
u64bit Timer::get_clock()
{
- return Botan::get_nanoseconds_clock();
+ auto now = std::chrono::high_resolution_clock::now().time_since_epoch();
+ return std::chrono::duration_cast<std::chrono::nanoseconds>(now).count();
}
std::ostream& operator<<(std::ostream& out, Timer& timer)