aboutsummaryrefslogtreecommitdiffstats
path: root/checks
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-01-21 16:36:12 +0000
committerlloyd <[email protected]>2010-01-21 16:36:12 +0000
commit412a13fc607a57bd9986155d247353ba8e5fb203 (patch)
treecbdf63aaa7e9f28a748dedda286e79a138573f74 /checks
parent41bed2fa0c4d96faf805cd33850166972dcac114 (diff)
parent9b82bb5a720f32e3e7878550310b1151cac188b8 (diff)
propagate from branch 'net.randombit.botan' (head 12382647ef0a28fcb11c824c77b670cc88a4f721)
to branch 'net.randombit.botan.c++0x' (head b586a3286d2c4d547ad3add5af9df1455bf4b87b)
Diffstat (limited to 'checks')
-rw-r--r--checks/bench.cpp19
-rw-r--r--checks/cvc_tests.cpp21
-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, 86 insertions, 77 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 8727a4624..fdd333b1f 100644
--- a/checks/ec_tests.cpp
+++ b/checks/ec_tests.cpp
@@ -85,8 +85,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
@@ -799,11 +799,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)
@@ -986,7 +986,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 c86668baf..8991c8a6d 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 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 9c243f1cf..cb25c9212 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");