diff options
author | lloyd <[email protected]> | 2010-02-25 23:07:38 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-02-25 23:07:38 +0000 |
commit | 5fec937bd0c72858d6cf2f09b58b219294c7d5cc (patch) | |
tree | 811714c0663199782b07b8f20a328eeeeff9e768 /checks | |
parent | 08647db8877585a783797c8db22dc76233b200f0 (diff) | |
parent | 3e95540b28f3d828c4578381c318545f6ad49589 (diff) |
propagate from branch 'net.randombit.botan' (head c1db52e38b60afbc6549af5222d6e10b1b9730dd)
to branch 'net.randombit.botan.c++0x' (head e56dfbfe6bffbd5b4e52b115549d885c5fd04586)
Diffstat (limited to 'checks')
-rw-r--r-- | checks/bench.cpp | 19 | ||||
-rw-r--r-- | checks/cvc_tests.cpp | 21 | ||||
-rw-r--r-- | checks/ec_tests.cpp | 4 | ||||
-rw-r--r-- | checks/ecdsa.cpp | 34 | ||||
-rw-r--r-- | checks/eckaeg.cpp | 2 | ||||
-rw-r--r-- | checks/pk.cpp | 16 | ||||
-rw-r--r-- | checks/pk_bench.cpp | 40 | ||||
-rw-r--r-- | checks/timer.cpp | 5 | ||||
-rw-r--r-- | checks/x509.cpp | 2 |
9 files changed, 76 insertions, 67 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 8ca00e048..7904a2700 100644 --- a/checks/cvc_tests.cpp +++ b/checks/cvc_tests.cpp @@ -163,8 +163,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): @@ -182,7 +182,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_parameters().get_order() == dom_pars.get_order()); @@ -213,7 +213,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_parameters().get_order() == dom_pars.get_order()); @@ -228,7 +228,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(get_EC_Dom_Pars_by_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_parameters().get_order() == dom_pars.get_order()); @@ -350,8 +350,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)); @@ -390,11 +389,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"); @@ -512,7 +511,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 @@ -542,7 +541,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 0c814a136..637e3d988 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 f9dcf5597..862677e63 100644 --- a/checks/ecdsa.cpp +++ b/checks/ecdsa.cpp @@ -70,7 +70,7 @@ void test_hash_larger_than_n(RandomNumberGenerator& rng) { format = "EMSA1_BSI(SHA-1)"; } - std::auto_ptr<PK_Signer> pk_signer(get_pk_signer(priv_key, format)); + std::unique_ptr<PK_Signer> pk_signer(get_pk_signer(priv_key, format)); SecureVector<byte> signature; bool sig_exc = false; try @@ -93,7 +93,7 @@ void test_hash_larger_than_n(RandomNumberGenerator& rng) if(i==0) // makes no sense to check for sha224 { - std::auto_ptr<PK_Verifier> pk_verifier(get_pk_verifier(priv_key, format)); + std::unique_ptr<PK_Verifier> pk_verifier(get_pk_verifier(priv_key, format)); bool ver = pk_verifier->verify_message(message, signature); CHECK(ver); } @@ -103,10 +103,10 @@ void test_hash_larger_than_n(RandomNumberGenerator& rng) // now check that verification alone fails // sign it with the normal EMSA1 - std::auto_ptr<PK_Signer> pk_signer(get_pk_signer(priv_key, "EMSA1(SHA-224)")); + std::unique_ptr<PK_Signer> pk_signer(get_pk_signer(priv_key, "EMSA1(SHA-224)")); SecureVector<byte> signature = pk_signer->sign_message(message, rng); - std::auto_ptr<PK_Verifier> pk_verifier(get_pk_verifier(priv_key, "EMSA1_BSI(SHA-224)")); + std::unique_ptr<PK_Verifier> pk_verifier(get_pk_verifier(priv_key, "EMSA1_BSI(SHA-224)")); // verify against EMSA1_BSI // we make sure it doesn't fail because of the invalid signature, @@ -156,7 +156,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"); } @@ -168,7 +168,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"); @@ -180,7 +180,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"); } @@ -223,8 +223,8 @@ bool test_ec_sign(RandomNumberGenerator& rng) ECDSA_PrivateKey priv_key(rng, dom_pars); std::string pem_encoded_key = PKCS8::PEM_encode(priv_key); - std::auto_ptr<PK_Signer> signer(get_pk_signer(priv_key, "EMSA1(SHA-224)")); - std::auto_ptr<PK_Verifier> verifier(get_pk_verifier(priv_key, "EMSA1(SHA-224)")); + std::unique_ptr<PK_Signer> signer(get_pk_signer(priv_key, "EMSA1(SHA-224)")); + std::unique_ptr<PK_Verifier> verifier(get_pk_verifier(priv_key, "EMSA1(SHA-224)")); for(u32bit i = 0; i != 256; ++i) signer->update((byte)i); @@ -305,11 +305,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"); @@ -342,7 +342,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())) { @@ -412,7 +412,7 @@ void test_read_pkcs8(RandomNumberGenerator& rng) std::cout << "." << std::flush; 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* 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"); @@ -423,7 +423,7 @@ void test_read_pkcs8(RandomNumberGenerator& rng) bool ver_success = loaded_ec_key->verify(sv_message.begin(), sv_message.size(), signature.begin(), signature.size()); CHECK_MESSAGE(ver_success, "generated signature could not be verified positively"); - 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* loaded_ec_key_nodp = dynamic_cast<ECDSA_PrivateKey*>(loaded_key_nodp.get()); CHECK_MESSAGE(loaded_ec_key_nodp, "the loaded key could not be converted into an ECDSA_PrivateKey"); @@ -434,7 +434,7 @@ void test_read_pkcs8(RandomNumberGenerator& rng) CHECK_MESSAGE(ver_success_nodp, "generated signature could not be verified positively (no_dom)"); try { - std::auto_ptr<PKCS8_PrivateKey> loaded_key_withdp(PKCS8::load_key(TEST_DATA_DIR "/withdompar_private.pkcs8.pem", rng)); + 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"; } @@ -453,7 +453,7 @@ void test_cp_and_as_ctors(RandomNumberGenerator& rng) { std::cout << "." << std::flush; - 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::string str_message = ("12345678901234567890abcdef12"); @@ -489,7 +489,7 @@ void test_non_init_ecdsa_keys(RandomNumberGenerator& rng) { std::cout << "." << std::flush; - 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::string str_message = ("12345678901234567890abcdef12"); diff --git a/checks/eckaeg.cpp b/checks/eckaeg.cpp index e5de2e425..3f5443607 100644 --- a/checks/eckaeg.cpp +++ b/checks/eckaeg.cpp @@ -102,7 +102,7 @@ void test_eckaeg_some_dp(RandomNumberGenerator& rng) Botan::EC_Domain_Params dom_pars(Botan::get_EC_Dom_Pars_by_oid(oids[i])); Botan::ECKAEG_PrivateKey private_a(rng, dom_pars); Botan::ECKAEG_PublicKey public_a = private_a; - /*auto_ptr<Botan::X509_Encoder> x509_key_enc = public_a.x509_encoder(); + /*unique_ptr<Botan::X509_Encoder> x509_key_enc = public_a.x509_encoder(); Botan::MemoryVector<Botan::byte> enc_key_a = Botan::DER_Encoder() .start_cons(Botan::SEQUENCE) .encode(x509_key_enc->alg_id()) diff --git a/checks/pk.cpp b/checks/pk.cpp index 07e6aeb10..b50ce17da 100644 --- a/checks/pk.cpp +++ b/checks/pk.cpp @@ -184,7 +184,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) @@ -303,7 +303,7 @@ u32bit validate_rsa_ver(const std::string& algo, std::string emsa = algo.substr(6, std::string::npos); - std::auto_ptr<PK_Verifier> v(get_pk_verifier(key, emsa)); + std::unique_ptr<PK_Verifier> v(get_pk_verifier(key, emsa)); SecureVector<byte> msg = decode_hex(str[2]); SecureVector<byte> sig = decode_hex(str[3]); @@ -326,7 +326,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()); @@ -335,7 +335,7 @@ u32bit validate_rsa_ver_x509(const std::string& algo, std::string emsa = algo.substr(11, std::string::npos); - std::auto_ptr<PK_Verifier> v(get_pk_verifier(*rsakey, emsa)); + std::unique_ptr<PK_Verifier> v(get_pk_verifier(*rsakey, emsa)); SecureVector<byte> msg = decode_hex(str[1]); SecureVector<byte> sig = decode_hex(str[2]); @@ -361,7 +361,7 @@ u32bit validate_rw_ver(const std::string& algo, std::string emsa = algo.substr(5, std::string::npos); - std::auto_ptr<PK_Verifier> v(get_pk_verifier(key, emsa)); + std::unique_ptr<PK_Verifier> v(get_pk_verifier(key, emsa)); SecureVector<byte> msg = decode_hex(str[2]); SecureVector<byte> sig = decode_hex(str[3]); @@ -417,7 +417,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) @@ -449,7 +449,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()); @@ -458,7 +458,7 @@ u32bit validate_dsa_ver(const std::string& algo, std::string emsa = algo.substr(7, std::string::npos); - std::auto_ptr<PK_Verifier> v(get_pk_verifier(*dsakey, emsa)); + std::unique_ptr<PK_Verifier> v(get_pk_verifier(*dsakey, emsa)); SecureVector<byte> msg = decode_hex(str[1]); SecureVector<byte> sig = decode_hex(str[2]); diff --git a/checks/pk_bench.cpp b/checks/pk_bench.cpp index a0ea1d1d3..4a70a5899 100644 --- a/checks/pk_bench.cpp +++ b/checks/pk_bench.cpp @@ -211,17 +211,17 @@ void benchmark_rsa(RandomNumberGenerator& rng, while(verify_timer.seconds() < seconds || sig_timer.seconds() < seconds) { - std::auto_ptr<PK_Encryptor> enc(get_pk_encryptor(key, enc_padding)); - std::auto_ptr<PK_Decryptor> dec(get_pk_decryptor(key, enc_padding)); + std::unique_ptr<PK_Encryptor> enc(get_pk_encryptor(key, enc_padding)); + std::unique_ptr<PK_Decryptor> dec(get_pk_decryptor(key, enc_padding)); benchmark_enc_dec(*enc, *dec, enc_timer, dec_timer, rng, 10000, seconds); - std::auto_ptr<PK_Signer> sig(get_pk_signer(key, sig_padding)); - std::auto_ptr<PK_Verifier> ver(get_pk_verifier(key, sig_padding)); + std::unique_ptr<PK_Signer> sig(get_pk_signer(key, sig_padding)); + std::unique_ptr<PK_Verifier> ver(get_pk_verifier(key, sig_padding)); benchmark_sig_ver(*ver, *sig, verify_timer, 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); @@ -266,13 +266,13 @@ void benchmark_rw(RandomNumberGenerator& rng, RW_PrivateKey key(rng, keylen); 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)); + std::unique_ptr<PK_Signer> sig(get_pk_signer(key, padding)); + std::unique_ptr<PK_Verifier> ver(get_pk_verifier(key, padding)); benchmark_sig_ver(*ver, *sig, verify_timer, sig_timer, 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); @@ -307,7 +307,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"); @@ -320,14 +320,14 @@ void benchmark_ecdsa(RandomNumberGenerator& rng, ECDSA_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)); + std::unique_ptr<PK_Signer> sig(get_pk_signer(key, padding)); + std::unique_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 = "ECDSA-" + to_string(pbits); + const std::string nm = "ECDSA-" + std::to_string(pbits); report.report(nm, keygen_timer); report.report(nm, verify_timer); @@ -393,7 +393,7 @@ void benchmark_eckaeg(RandomNumberGenerator& rng, } } - const std::string nm = "ECKAEG-" + to_string(pbits); + const std::string nm = "ECKAEG-" + std::to_string(pbits); report.report(nm, keygen_timer); report.report(nm, kex_timer); } @@ -421,7 +421,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"); @@ -436,14 +436,14 @@ void benchmark_dsa_nr(RandomNumberGenerator& rng, PRIV_KEY_TYPE key(rng, group); 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)); + std::unique_ptr<PK_Signer> sig(get_pk_signer(key, padding)); + std::unique_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 = 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); @@ -606,13 +606,13 @@ void benchmark_elg(RandomNumberGenerator& rng, ElGamal_PrivateKey key(rng, group); keygen_timer.stop(); - std::auto_ptr<PK_Decryptor> dec(get_pk_decryptor(key, padding)); - std::auto_ptr<PK_Encryptor> enc(get_pk_encryptor(key, padding)); + std::unique_ptr<PK_Decryptor> dec(get_pk_decryptor(key, padding)); + std::unique_ptr<PK_Encryptor> enc(get_pk_encryptor(key, padding)); benchmark_enc_dec(*enc, *dec, enc_timer, dec_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, 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/x509.cpp b/checks/x509.cpp index 8b7ce7d47..3a48f57f9 100644 --- a/checks/x509.cpp +++ b/checks/x509.cpp @@ -40,7 +40,7 @@ namespace { u64bit key_id(const Public_Key* key) { - std::auto_ptr<X509_Encoder> encoder(key->x509_encoder()); + std::unique_ptr<X509_Encoder> encoder(key->x509_encoder()); if(!encoder.get()) throw Internal_Error("Public_Key:key_id: No encoder found"); |