aboutsummaryrefslogtreecommitdiffstats
path: root/checks
diff options
context:
space:
mode:
Diffstat (limited to 'checks')
-rw-r--r--checks/bench.cpp19
-rw-r--r--checks/cvc_tests.cpp18
-rw-r--r--checks/ec_tests.cpp10
-rw-r--r--checks/ecdsa.cpp34
-rw-r--r--checks/eckaeg.cpp2
-rw-r--r--checks/gfpmath.cpp14
-rw-r--r--checks/pk.cpp16
-rw-r--r--checks/pk_bench.cpp40
-rw-r--r--checks/timer.cpp5
-rw-r--r--checks/x509.cpp2
10 files changed, 85 insertions, 75 deletions
diff --git a/checks/bench.cpp b/checks/bench.cpp
index 631bf8476..e733c75ec 100644
--- a/checks/bench.cpp
+++ b/checks/bench.cpp
@@ -9,7 +9,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"
@@ -198,17 +201,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..4b2ffa9a6 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());
@@ -390,11 +390,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 +512,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 +542,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 2d25e2153..5ee2002f3 100644
--- a/checks/ec_tests.cpp
+++ b/checks/ec_tests.cpp
@@ -80,8 +80,8 @@ void test_point_turn_on_sp_red_mul()
CHECK_MESSAGE(r1 == r2, "error with point mul after extra turn on sp red mul");
CHECK(r1.get_affine_x().get_value() != BigInt("0"));
- std::tr1::shared_ptr<PointGFp> p_r1(new PointGFp(r1));
- std::tr1::shared_ptr<PointGFp> p_r2(new PointGFp(r2));
+ std::shared_ptr<PointGFp> p_r1(new PointGFp(r1));
+ std::shared_ptr<PointGFp> p_r2(new PointGFp(r2));
p_r1->mult2_in_place(); // wird für Fehler nicht gebraucht
p_r2->turn_on_sp_red_mul(); // 1. t_o() macht nur p_r2 kaputt
@@ -794,11 +794,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 ( GFpElement ( bi_p_secp,bi_a_secp ), GFpElement ( bi_p_secp, bi_b_secp ), bi_p_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)
@@ -981,7 +981,7 @@ void test_point_worksp()
{
EC_Domain_Params dom_pars(get_EC_Dom_Pars_by_oid("1.3.132.0.8"));
- std::tr1::shared_ptr<std::vector<GFpElement> > worksp1;
+ std::shared_ptr<std::vector<GFpElement> > worksp1;
assert(worksp1.get() == 0);
{
PointGFp p = dom_pars.get_base_point();
diff --git a/checks/ecdsa.cpp b/checks/ecdsa.cpp
index 532a1c546..37880b755 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,
@@ -164,7 +164,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");
}
@@ -176,7 +176,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");
@@ -188,7 +188,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");
}
@@ -231,8 +231,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);
@@ -313,11 +313,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");
@@ -350,7 +350,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()))
{
@@ -420,7 +420,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");
@@ -431,7 +431,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");
@@ -442,7 +442,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";
}
@@ -461,7 +461,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");
@@ -497,7 +497,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 f25fbb292..501ad8c3d 100644
--- a/checks/eckaeg.cpp
+++ b/checks/eckaeg.cpp
@@ -103,7 +103,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/gfpmath.cpp b/checks/gfpmath.cpp
index 2352bba7e..6d8e406e3 100644
--- a/checks/gfpmath.cpp
+++ b/checks/gfpmath.cpp
@@ -484,13 +484,13 @@ bool test_gfp_shared_vals()
GFpElement a(p, BigInt("234090"));
GFpElement shcpy_a(1,0);
shcpy_a.share_assign(a);
- std::tr1::shared_ptr<GFpModulus> ptr1 = a.get_ptr_mod();
- std::tr1::shared_ptr<GFpModulus> ptr2 = shcpy_a.get_ptr_mod();
+ std::shared_ptr<GFpModulus> ptr1 = a.get_ptr_mod();
+ std::shared_ptr<GFpModulus> ptr2 = shcpy_a.get_ptr_mod();
CHECK_MESSAGE(ptr1.get() == ptr2.get(), "shared pointers for moduli aren´t equal");
GFpElement b(1,0);
b = a; // create a non shared copy
- std::tr1::shared_ptr<GFpModulus> ptr_b_p = b.get_ptr_mod();
+ std::shared_ptr<GFpModulus> ptr_b_p = b.get_ptr_mod();
CHECK_MESSAGE(ptr1.get() != ptr_b_p.get(), "non shared pointers for moduli are equal");
a.turn_on_sp_red_mul();
@@ -513,15 +513,15 @@ bool test_gfp_shared_vals()
}
swap(a,shcpy_a);
- std::tr1::shared_ptr<GFpModulus> ptr3 = a.get_ptr_mod();
- std::tr1::shared_ptr<GFpModulus> ptr4 = shcpy_a.get_ptr_mod();
+ std::shared_ptr<GFpModulus> ptr3 = a.get_ptr_mod();
+ std::shared_ptr<GFpModulus> ptr4 = shcpy_a.get_ptr_mod();
CHECK_MESSAGE(ptr3.get() == ptr4.get(), "shared pointers for moduli aren´t equal after swap");
CHECK(ptr1.get() == ptr4.get());
CHECK(ptr2.get() == ptr3.get());
swap(a,b);
- std::tr1::shared_ptr<GFpModulus> ptr_a = a.get_ptr_mod();
- std::tr1::shared_ptr<GFpModulus> ptr_b = shcpy_a.get_ptr_mod();
+ std::shared_ptr<GFpModulus> ptr_a = a.get_ptr_mod();
+ std::shared_ptr<GFpModulus> ptr_b = shcpy_a.get_ptr_mod();
CHECK(ptr_a.get() == ptr_b_p.get());
CHECK(ptr_b.get() == ptr3.get());
return pass;
diff --git a/checks/pk.cpp b/checks/pk.cpp
index c02005245..e8746ad04 100644
--- a/checks/pk.cpp
+++ b/checks/pk.cpp
@@ -178,7 +178,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)
@@ -297,7 +297,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]);
@@ -320,7 +320,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());
@@ -329,7 +329,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]);
@@ -355,7 +355,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]);
@@ -411,7 +411,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)
@@ -443,7 +443,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());
@@ -452,7 +452,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 31c48c1da..72c5f53f6 100644
--- a/checks/pk_bench.cpp
+++ b/checks/pk_bench.cpp
@@ -205,17 +205,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);
@@ -260,13 +260,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);
@@ -301,7 +301,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");
@@ -314,14 +314,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);
@@ -387,7 +387,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);
}
@@ -415,7 +415,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");
@@ -430,14 +430,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);
@@ -600,13 +600,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 1bdaebb7f..aaea4b361 100644
--- a/checks/timer.cpp
+++ b/checks/timer.cpp
@@ -1,5 +1,5 @@
#include "timer.h"
-#include <botan/time.h>
+#include <chrono>
#include <iomanip>
Timer::Timer(const std::string& n, u32bit e_mul) :
@@ -32,7 +32,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 69dd29492..0cd2b8045 100644
--- a/checks/x509.cpp
+++ b/checks/x509.cpp
@@ -34,7 +34,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");