diff options
Diffstat (limited to 'checks')
-rw-r--r-- | checks/bench.cpp | 19 | ||||
-rw-r--r-- | checks/cvc_tests.cpp | 23 | ||||
-rw-r--r-- | checks/ec_tests.cpp | 4 | ||||
-rw-r--r-- | checks/ecdsa.cpp | 18 | ||||
-rw-r--r-- | checks/pk.cpp | 8 | ||||
-rw-r--r-- | checks/pk_bench.cpp | 18 | ||||
-rw-r--r-- | checks/timer.cpp | 5 | ||||
-rw-r--r-- | checks/validate.dat | 2 |
8 files changed, 53 insertions, 44 deletions
diff --git a/checks/bench.cpp b/checks/bench.cpp index e9eb92199..8f7f6c77f 100644 --- a/checks/bench.cpp +++ b/checks/bench.cpp @@ -14,9 +14,12 @@ #include <botan/engine.h> #include <botan/parsing.h> #include <botan/symkey.h> -#include <botan/time.h> #include <botan/hex.h> +#include <chrono> + +typedef std::chrono::high_resolution_clock benchmark_clock; + #include "common.h" #include "bench.h" @@ -236,17 +239,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 334fb8581..1197c2d30 100644 --- a/checks/cvc_tests.cpp +++ b/checks/cvc_tests.cpp @@ -162,12 +162,12 @@ 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()); 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): - //cout << "encoding = " << p_ecdsa_pk->get_parameter_encoding() << std::endl; + CHECK(p_ecdsa_pk->domain_format() == EC_DOMPAR_ENC_IMPLICITCA); bool exc = false; try @@ -181,7 +181,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()); @@ -212,7 +212,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()); @@ -227,7 +227,7 @@ void test_cvc_req_ext(RandomNumberGenerator&) EAC1_1_Req req_in(TEST_DATA_DIR "/DE1_flen_chars_cvcRequest_ECDSA.der"); EC_Group 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()); @@ -349,8 +349,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)); @@ -389,11 +388,9 @@ 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)); - //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"); @@ -511,7 +508,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 @@ -541,7 +538,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 8ed975603..e308a5291 100644 --- a/checks/ec_tests.cpp +++ b/checks/ec_tests.cpp @@ -621,11 +621,11 @@ void test_enc_dec_uncompressed_521_prime_too_large() BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], 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))); if(!p_G->on_the_curve()) throw Internal_Error("Point not on the curve"); } diff --git a/checks/ecdsa.cpp b/checks/ecdsa.cpp index 5cf353e58..3110bf0fe 100644 --- a/checks/ecdsa.cpp +++ b/checks/ecdsa.cpp @@ -104,7 +104,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"); } @@ -116,7 +116,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"); @@ -128,7 +128,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"); } @@ -251,11 +251,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"); @@ -289,7 +289,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())) { @@ -365,7 +365,7 @@ void test_read_pkcs8(RandomNumberGenerator& rng) try { - 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* ecdsa = dynamic_cast<ECDSA_PrivateKey*>(loaded_key.get()); CHECK_MESSAGE(ecdsa, "the loaded key could not be converted into an ECDSA_PrivateKey"); @@ -385,7 +385,7 @@ void test_read_pkcs8(RandomNumberGenerator& rng) try { - std::auto_ptr<PKCS8_PrivateKey> loaded_key_nodp(PKCS8::load_key(TEST_DATA_DIR "/nodompar_private.pkcs8.pem", rng)); + std::unique_ptr<PKCS8_PrivateKey> loaded_key_nodp(PKCS8::load_key(TEST_DATA_DIR "/nodompar_private.pkcs8.pem", rng)); // anew in each test with unregistered domain-parameters ECDSA_PrivateKey* ecdsa_nodp = dynamic_cast<ECDSA_PrivateKey*>(loaded_key_nodp.get()); CHECK_MESSAGE(ecdsa_nodp, "the loaded key could not be converted into an ECDSA_PrivateKey"); @@ -400,7 +400,7 @@ void test_read_pkcs8(RandomNumberGenerator& rng) try { - std::auto_ptr<PKCS8_PrivateKey> loaded_key_withdp( + std::unique_ptr<PKCS8_PrivateKey> loaded_key_withdp( PKCS8::load_key(TEST_DATA_DIR "/withdompar_private.pkcs8.pem", rng)); std::cout << "Unexpected success: loaded key with unknown OID\n"; diff --git a/checks/pk.cpp b/checks/pk.cpp index 6291b1566..e11578523 100644 --- a/checks/pk.cpp +++ b/checks/pk.cpp @@ -247,7 +247,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) @@ -388,7 +388,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()); @@ -476,7 +476,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) @@ -561,7 +561,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 de8ad0730..449ff7730 100644 --- a/checks/pk_bench.cpp +++ b/checks/pk_bench.cpp @@ -240,7 +240,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); @@ -292,7 +292,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); @@ -319,7 +319,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"); @@ -339,7 +339,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); @@ -381,7 +381,7 @@ void benchmark_gost_3410(RandomNumberGenerator& rng, sig_timer, rng, 1000, seconds); } - const std::string nm = "GOST-34.10-" + to_string(pbits); + const std::string nm = "GOST-34.10-" + std::to_string(pbits); report.report(nm, keygen_timer); report.report(nm, verify_timer); @@ -439,7 +439,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); } @@ -465,7 +465,7 @@ void benchmark_dsa_nr(RandomNumberGenerator& rng, size_t pbits = to_u32bit(split_on(domains[j], '/')[2]); size_t 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"); @@ -488,7 +488,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); @@ -657,7 +657,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) diff --git a/checks/validate.dat b/checks/validate.dat index 6b9a49e52..7b8588aac 100644 --- a/checks/validate.dat +++ b/checks/validate.dat @@ -67685,6 +67685,8 @@ DC37E008CF9EE69BF11F00ED9ABA26901DD7C28CDEC066CC6AF42E40F82F3A1E\ [Parallel(MD5,SHA-1)] :D41D8CD98F00B204E9800998ECF8427EDA39A3EE5E6B4B0D3255BFEF95601890AFD80709 +61:0CC175B9C0F1B6A831C399E26977266186F7E437FAA5A7FCE15D1DDCB9EAEAEA377667B8 + [Parallel(SHA-160,Tiger(24,3))] :DA39A3EE5E6B4B0D3255BFEF95601890AFD807093293AC630\ C13F0245F92BBB1766E16167A4E58492DDE73F3 |