aboutsummaryrefslogtreecommitdiffstats
path: root/checks
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-05-25 22:52:00 +0000
committerlloyd <[email protected]>2012-05-25 22:52:00 +0000
commit12090a7148d9ee73572cc1a7268fc489504a8173 (patch)
tree51e50ce0852c56231e9e6dc13f168b10edd45d01 /checks
parent9594979caf775dc4062850044715b804d1fda60c (diff)
parent65cc04445f8d40497f02a14bd8cb97081790e54b (diff)
propagate from branch 'net.randombit.botan.x509-path-validation' (head 63b5a20eab129ca13287fda33d2d02eec329708f)
to branch 'net.randombit.botan' (head 8b8150f09c55184f028f2929c4e7f7cd0d46d96e)
Diffstat (limited to 'checks')
-rw-r--r--checks/bench.cpp36
-rw-r--r--checks/common.h4
-rw-r--r--checks/cvc_tests.cpp54
-rw-r--r--checks/dolook.cpp30
-rw-r--r--checks/ec_tests.cpp122
-rw-r--r--checks/ecdh.cpp4
-rw-r--r--checks/ecdsa.cpp54
-rw-r--r--checks/pk.cpp76
-rw-r--r--checks/pk_bench.cpp42
-rw-r--r--checks/timer.cpp5
-rw-r--r--checks/validate.cpp18
-rw-r--r--checks/validate.dat55
-rw-r--r--checks/x509.cpp3
13 files changed, 277 insertions, 226 deletions
diff --git a/checks/bench.cpp b/checks/bench.cpp
index e9eb92199..5faba00db 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"
@@ -150,18 +153,6 @@ void report_results(const std::string& algo,
std::cout << algo;
-#if defined(__SUNPRO_CC)
- #define REVERSE_ITERATOR_BUG 1
-#elif defined(__GNUC__) && __GNUC__ <= 3
- #define REVERSE_ITERATOR_BUG 1
-#elif defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 0)
- #define REVERSE_ITERATOR_BUG 1
-#endif
-
-#ifndef REVERSE_ITERATOR_BUG
- #define REVERSE_ITERATOR_BUG 0
-#endif
-
#if (defined(__GNUC__) && __GNUC__ <= 3) || defined(__SUNPRO_CC)
// Work around GCC 3.x bug, reverse iterators don't work
for(std::map<double, std::string>::const_iterator i = results.begin(); i != results.end(); ++i)
@@ -184,10 +175,11 @@ bool bench_algo(const std::string& algo,
{
Botan::Algorithm_Factory& af = Botan::global_state().algorithm_factory();
- u32bit milliseconds = static_cast<u32bit>(seconds * 1000);
+ std::chrono::milliseconds ms(
+ static_cast<std::chrono::milliseconds::rep>(seconds * 1000));
std::map<std::string, double> speeds =
- algorithm_benchmark(algo, af, rng, milliseconds, buf_size);
+ algorithm_benchmark(algo, af, rng, ms, buf_size);
if(speeds.empty()) // maybe a cipher mode, then?
{
@@ -236,17 +228,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/common.h b/checks/common.h
index 33499a99d..05a6fb974 100644
--- a/checks/common.h
+++ b/checks/common.h
@@ -55,13 +55,13 @@ class Fixed_Output_RNG : public Botan::RandomNumberGenerator
void clear() throw() {}
- Fixed_Output_RNG(const Botan::SecureVector<byte>& in)
+ Fixed_Output_RNG(const Botan::secure_vector<byte>& in)
{
buf.insert(buf.end(), in.begin(), in.end());
}
Fixed_Output_RNG(const std::string& in_str)
{
- Botan::SecureVector<byte> in = Botan::hex_decode(in_str);
+ Botan::secure_vector<byte> in = Botan::hex_decode(in_str);
buf.insert(buf.end(), in.begin(), in.end());
}
diff --git a/checks/cvc_tests.cpp b/checks/cvc_tests.cpp
index 334fb8581..9dc56610c 100644
--- a/checks/cvc_tests.cpp
+++ b/checks/cvc_tests.cpp
@@ -27,7 +27,6 @@
#include <botan/cvc_self.h>
#include <botan/cvc_cert.h>
#include <botan/cvc_ado.h>
-#include <botan/time.h>
#define TEST_DATA_DIR "checks/ecc_testdata"
@@ -41,7 +40,7 @@ namespace {
// helper functions
void helper_write_file(EAC_Signed_Object const& to_write, std::string const& file_path)
{
- SecureVector<byte> sv = to_write.BER_encode();
+ std::vector<byte> sv = to_write.BER_encode();
std::ofstream cert_file(file_path.c_str(), std::ios::binary);
cert_file.write((char*)&sv[0], sv.size());
cert_file.close();
@@ -51,8 +50,8 @@ bool helper_files_equal(std::string const& file_path1, std::string const& file_p
{
std::ifstream cert_1_in(file_path1.c_str());
std::ifstream cert_2_in(file_path2.c_str());
- SecureVector<byte> sv1;
- SecureVector<byte> sv2;
+ std::vector<byte> sv1;
+ std::vector<byte> sv2;
if (!cert_1_in || !cert_2_in)
{
return false;
@@ -95,7 +94,7 @@ void test_enc_gen_selfsigned(RandomNumberGenerator& rng)
key.set_parameter_encoding(EC_DOMPAR_ENC_IMPLICITCA);
EAC1_1_CVC cert = CVC_EAC::create_self_signed_cert(key, opts, rng);
- SecureVector<byte> der(cert.BER_encode());
+ std::vector<byte> der(cert.BER_encode());
std::ofstream cert_file;
cert_file.open(TEST_DATA_DIR "/my_cv_cert.ber", std::ios::binary);
//cert_file << der; // this is bad !!!
@@ -105,15 +104,15 @@ void test_enc_gen_selfsigned(RandomNumberGenerator& rng)
EAC1_1_CVC cert_in(TEST_DATA_DIR "/my_cv_cert.ber");
CHECK(cert == cert_in);
// encoding it again while it has no dp
- SecureVector<byte> der2(cert_in.BER_encode());
+ std::vector<byte> der2(cert_in.BER_encode());
std::ofstream cert_file2(TEST_DATA_DIR "/my_cv_cert2.ber", std::ios::binary);
cert_file2.write((char*)&der2[0], der2.size());
cert_file2.close();
// read both and compare them
std::ifstream cert_1_in(TEST_DATA_DIR "/my_cv_cert.ber");
std::ifstream cert_2_in(TEST_DATA_DIR "/my_cv_cert2.ber");
- SecureVector<byte> sv1;
- SecureVector<byte> sv2;
+ std::vector<byte> sv1;
+ std::vector<byte> sv2;
if (!cert_1_in || !cert_2_in)
{
CHECK_MESSAGE(false, "could not read certificate files");
@@ -162,12 +161,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 +180,7 @@ void test_enc_gen_selfsigned(RandomNumberGenerator& rng)
CHECK(exc);
// set them and try again
//cert_in.set_domain_parameters(dom_pars);
- std::auto_ptr<Public_Key> p_pk2(cert_in.subject_public_key());
+ std::unique_ptr<Public_Key> p_pk2(cert_in.subject_public_key());
ECDSA_PublicKey* p_ecdsa_pk2 = dynamic_cast<ECDSA_PublicKey*>(p_pk2.get());
//p_ecdsa_pk2->set_domain_parameters(dom_pars);
CHECK(p_ecdsa_pk2->domain().get_order() == dom_pars.get_order());
@@ -204,7 +203,7 @@ void test_enc_gen_req(RandomNumberGenerator& rng)
ECDSA_PrivateKey key(rng, dom_pars);
key.set_parameter_encoding(EC_DOMPAR_ENC_IMPLICITCA);
EAC1_1_Req req = CVC_EAC::create_cvc_req(key, opts.chr, opts.hash_alg, rng);
- SecureVector<byte> der(req.BER_encode());
+ std::vector<byte> der(req.BER_encode());
std::ofstream req_file(TEST_DATA_DIR "/my_cv_req.ber", std::ios::binary);
req_file.write((char*)&der[0], der.size());
req_file.close();
@@ -212,7 +211,7 @@ void test_enc_gen_req(RandomNumberGenerator& rng)
// read and check signature...
EAC1_1_Req req_in(TEST_DATA_DIR "/my_cv_req.ber");
//req_in.set_domain_parameters(dom_pars);
- std::auto_ptr<Public_Key> p_pk(req_in.subject_public_key());
+ std::unique_ptr<Public_Key> p_pk(req_in.subject_public_key());
ECDSA_PublicKey* p_ecdsa_pk = dynamic_cast<ECDSA_PublicKey*>(p_pk.get());
//p_ecdsa_pk->set_domain_parameters(dom_pars);
CHECK(p_ecdsa_pk->domain().get_order() == dom_pars.get_order());
@@ -227,7 +226,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());
@@ -261,7 +260,7 @@ void test_cvc_ado_creation(RandomNumberGenerator& rng)
req_key.set_parameter_encoding(EC_DOMPAR_ENC_IMPLICITCA);
//EAC1_1_Req req = CVC_EAC::create_cvc_req(req_key, opts);
EAC1_1_Req req = CVC_EAC::create_cvc_req(req_key, opts.chr, opts.hash_alg, rng);
- SecureVector<byte> der(req.BER_encode());
+ std::vector<byte> der(req.BER_encode());
std::ofstream req_file(TEST_DATA_DIR "/my_cv_req.ber", std::ios::binary);
req_file.write((char*)&der[0], der.size());
req_file.close();
@@ -277,7 +276,7 @@ void test_cvc_ado_creation(RandomNumberGenerator& rng)
CHECK_MESSAGE(ado.check_signature(ado_key), "failure of ado verification after creation");
std::ofstream ado_file(TEST_DATA_DIR "/ado", std::ios::binary);
- SecureVector<byte> ado_der(ado.BER_encode());
+ std::vector<byte> ado_der(ado.BER_encode());
ado_file.write((char*)&ado_der[0], ado_der.size());
ado_file.close();
// read it again and check the signature
@@ -333,7 +332,7 @@ void test_cvc_ado_comparison(RandomNumberGenerator& rng)
CHECK_MESSAGE(ado != ado2, "ado's found to be equal where they are not");
// std::ofstream ado_file(TEST_DATA_DIR "/ado");
- // SecureVector<byte> ado_der(ado.BER_encode());
+ // std::vector<byte> ado_der(ado.BER_encode());
// ado_file.write((char*)&ado_der[0], ado_der.size());
// ado_file.close();
// read it again and check the signature
@@ -349,8 +348,7 @@ void test_eac_time(RandomNumberGenerator&)
{
std::cout << "." << std::flush;
- const u64bit current_time = system_time();
- EAC_Time time(current_time);
+ EAC_Time time(std::chrono::system_clock::now());
// std::cout << "time as std::string = " << time.as_string() << std::endl;
EAC_Time sooner("", ASN1_Tag(99));
//X509_Time sooner("", ASN1_Tag(99));
@@ -389,11 +387,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");
@@ -494,7 +490,7 @@ void test_cvc_chain(RandomNumberGenerator& rng)
ASN1_Car car("DECVCA00001");
EAC1_1_CVC cvca_cert = DE_EAC::create_cvca(cvca_privk, hash, car, true, true, 12, rng);
std::ofstream cvca_file(TEST_DATA_DIR "/cvc_chain_cvca.cer", std::ios::binary);
- SecureVector<byte> cvca_sv = cvca_cert.BER_encode();
+ std::vector<byte> cvca_sv = cvca_cert.BER_encode();
cvca_file.write((char*)&cvca_sv[0], cvca_sv.size());
cvca_file.close();
@@ -502,7 +498,7 @@ void test_cvc_chain(RandomNumberGenerator& rng)
ASN1_Car car2("DECVCA00002");
EAC1_1_CVC cvca_cert2 = DE_EAC::create_cvca(cvca_privk2, hash, car2, true, true, 12, rng);
EAC1_1_CVC link12 = DE_EAC::link_cvca(cvca_cert, cvca_privk, cvca_cert2, rng);
- SecureVector<byte> link12_sv = link12.BER_encode();
+ std::vector<byte> link12_sv = link12.BER_encode();
std::ofstream link12_file(TEST_DATA_DIR "/cvc_chain_link12.cer", std::ios::binary);
link12_file.write((char*)&link12_sv[0], link12_sv.size());
link12_file.close();
@@ -511,14 +507,14 @@ 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
ECDSA_PrivateKey dvca_priv_key(rng, dom_pars);
EAC1_1_Req dvca_req = DE_EAC::create_cvc_req(dvca_priv_key, ASN1_Chr("DEDVCAEPASS"), hash, rng);
std::ofstream dvca_file(TEST_DATA_DIR "/cvc_chain_dvca_req.cer", std::ios::binary);
- SecureVector<byte> dvca_sv = dvca_req.BER_encode();
+ std::vector<byte> dvca_sv = dvca_req.BER_encode();
dvca_file.write((char*)&dvca_sv[0], dvca_sv.size());
dvca_file.close();
@@ -532,7 +528,7 @@ void test_cvc_chain(RandomNumberGenerator& rng)
ECDSA_PrivateKey dvca_priv_key2(rng, dom_pars);
EAC1_1_Req dvca_req2 = DE_EAC::create_cvc_req(dvca_priv_key2, ASN1_Chr("DEDVCAEPASS"), hash, rng);
std::ofstream dvca_file2(TEST_DATA_DIR "/cvc_chain_dvca_req2.cer", std::ios::binary);
- SecureVector<byte> dvca_sv2 = dvca_req2.BER_encode();
+ std::vector<byte> dvca_sv2 = dvca_req2.BER_encode();
dvca_file2.write((char*)&dvca_sv2[0], dvca_sv2.size());
dvca_file2.close();
EAC1_1_ADO dvca_ado2 = CVC_EAC::create_ado_req(dvca_priv_key, dvca_req2,
@@ -541,7 +537,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/dolook.cpp b/checks/dolook.cpp
index a8e08a96b..364a3f8c3 100644
--- a/checks/dolook.cpp
+++ b/checks/dolook.cpp
@@ -83,14 +83,14 @@ class PBKDF_Filter : public Filter
pbkdf = algo;
outlen = o;
iterations = i;
- salt = s.bits_of();
+ salt = unlock(s.bits_of());
}
~PBKDF_Filter() { delete pbkdf; }
private:
std::string passphrase;
PBKDF* pbkdf;
- SecureVector<byte> salt;
+ std::vector<byte> salt;
u32bit outlen, iterations;
};
@@ -126,12 +126,12 @@ class KDF_Filter : public Filter
{
kdf = algo;
outlen = o;
- salt = s.bits_of();
+ salt = unlock(s.bits_of());
}
~KDF_Filter() { delete kdf; }
private:
- SecureVector<byte> secret;
- SecureVector<byte> salt;
+ std::vector<byte> secret;
+ std::vector<byte> salt;
KDF* kdf;
u32bit outlen;
};
@@ -139,7 +139,7 @@ class KDF_Filter : public Filter
Filter* lookup_pbkdf(const std::string& algname,
const std::vector<std::string>& params)
{
- PBKDF* pbkdf = 0;
+ PBKDF* pbkdf = nullptr;
try {
pbkdf = get_pbkdf(algname);
@@ -149,7 +149,7 @@ Filter* lookup_pbkdf(const std::string& algname,
if(pbkdf)
return new PBKDF_Filter(pbkdf, params[0], to_u32bit(params[1]),
to_u32bit(params[2]));
- return 0;
+ return nullptr;
}
void RNG_Filter::write(const byte[], size_t length)
@@ -163,7 +163,7 @@ void RNG_Filter::write(const byte[], size_t length)
Filter* lookup_rng(const std::string& algname,
const std::string& key)
{
- RandomNumberGenerator* prng = 0;
+ RandomNumberGenerator* prng = nullptr;
#if defined(BOTAN_HAS_AUTO_SEEDING_RNG)
if(algname == "AutoSeeded")
@@ -233,21 +233,21 @@ Filter* lookup_rng(const std::string& algname,
return new RNG_Filter(prng);
}
- return 0;
+ return nullptr;
}
Filter* lookup_kdf(const std::string& algname, const std::string& salt,
const std::string& params)
{
- KDF* kdf = 0;
+ KDF* kdf = nullptr;
try {
kdf = get_kdf(algname);
}
- catch(...) { return 0; }
+ catch(...) { return nullptr; }
if(kdf)
return new KDF_Filter(kdf, salt, to_u32bit(params));
- return 0;
+ return nullptr;
}
Filter* lookup_encoder(const std::string& algname)
@@ -278,7 +278,7 @@ Filter* lookup_encoder(const std::string& algname)
return new Zlib_Decompression;
#endif
- return 0;
+ return nullptr;
}
}
@@ -288,7 +288,7 @@ Filter* lookup(const std::string& algname,
{
std::string key = params[0];
std::string iv = params[1];
- Filter* filter = 0;
+ Filter* filter = nullptr;
// The order of the lookup has to change based on how the names are
// formatted and parsed.
@@ -304,6 +304,6 @@ Filter* lookup(const std::string& algname,
filter = lookup_pbkdf(algname, params);
if(filter) return filter;
- return 0;
+ return nullptr;
}
diff --git a/checks/ec_tests.cpp b/checks/ec_tests.cpp
index 8ed975603..39c32de37 100644
--- a/checks/ec_tests.cpp
+++ b/checks/ec_tests.cpp
@@ -76,10 +76,10 @@ void test_point_turn_on_sp_red_mul()
std::string a_secp = "ffffffffffffffffffffffffffffffff7ffffffc";
std::string b_secp = "1c97befc54bd7a8b65acf89f81d4d4adc565fa45";
std::string G_secp_comp = "024a96b5688ef573284664698968c38bb913cbfc82";
- SecureVector<byte> sv_p_secp = hex_decode(p_secp);
- SecureVector<byte> sv_a_secp = hex_decode(a_secp);
- SecureVector<byte> sv_b_secp = hex_decode(b_secp);
- SecureVector<byte> sv_G_secp_comp = hex_decode(G_secp_comp);
+ secure_vector<byte> sv_p_secp = hex_decode(p_secp);
+ secure_vector<byte> sv_a_secp = hex_decode(a_secp);
+ secure_vector<byte> sv_b_secp = hex_decode(b_secp);
+ secure_vector<byte> sv_G_secp_comp = hex_decode(G_secp_comp);
BigInt bi_p_secp = BigInt::decode(&sv_p_secp[0], sv_p_secp.size());
BigInt bi_a_secp = BigInt::decode(&sv_a_secp[0], sv_a_secp.size());
BigInt bi_b_secp = BigInt::decode(&sv_b_secp[0], sv_b_secp.size());
@@ -139,10 +139,10 @@ void test_coordinates()
std::string a_secp = "ffffffffffffffffffffffffffffffff7ffffffc";
std::string b_secp = "1c97befc54bd7a8b65acf89f81d4d4adc565fa45";
std::string G_secp_comp = "024a96b5688ef573284664698968c38bb913cbfc82";
- SecureVector<byte> sv_p_secp = hex_decode ( p_secp );
- SecureVector<byte> sv_a_secp = hex_decode ( a_secp );
- SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
- SecureVector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
+ secure_vector<byte> sv_p_secp = hex_decode ( p_secp );
+ secure_vector<byte> sv_a_secp = hex_decode ( a_secp );
+ secure_vector<byte> sv_b_secp = hex_decode ( b_secp );
+ secure_vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() );
BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() );
@@ -196,7 +196,7 @@ void test_point_mult ()
const CurveGFp& curve = secp160r1.get_curve();
std::string G_secp_comp = "024a96b5688ef573284664698968c38bb913cbfc82";
- SecureVector<byte> sv_G_secp_comp = hex_decode(G_secp_comp);
+ secure_vector<byte> sv_G_secp_comp = hex_decode(G_secp_comp);
PointGFp p_G = OS2ECP(sv_G_secp_comp, curve);
BigInt d_U("0xaa374ffc3ce144e6b073307972cb6d57b2a4e982");
@@ -215,10 +215,10 @@ void test_point_negative()
std::string a_secp = "ffffffffffffffffffffffffffffffff7ffffffc";
std::string b_secp = "1c97befc54bd7a8b65acf89f81d4d4adc565fa45";
std::string G_secp_comp = "024a96b5688ef573284664698968c38bb913cbfc82";
- SecureVector<byte> sv_p_secp = hex_decode ( p_secp );
- SecureVector<byte> sv_a_secp = hex_decode ( a_secp );
- SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
- SecureVector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
+ secure_vector<byte> sv_p_secp = hex_decode ( p_secp );
+ secure_vector<byte> sv_a_secp = hex_decode ( a_secp );
+ secure_vector<byte> sv_b_secp = hex_decode ( b_secp );
+ secure_vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() );
BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() );
BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() );
@@ -242,7 +242,7 @@ void test_zeropoint()
std::string G_secp_comp = "024a96b5688ef573284664698968c38bb913cbfc82";
- SecureVector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
+ secure_vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
BigInt bi_p_secp("0xffffffffffffffffffffffffffffffff7fffffff");
BigInt bi_a_secp("0xffffffffffffffffffffffffffffffff7ffffffc");
BigInt bi_b_secp("0x1c97befc54bd7a8b65acf89f81d4d4adc565fa45");
@@ -273,7 +273,7 @@ void test_zeropoint_enc_dec()
CHECK_MESSAGE( p.is_zero(), "by constructor created zeropoint is no zeropoint!");
- SecureVector<byte> sv_p = EC2OSP(p, PointGFp::UNCOMPRESSED);
+ secure_vector<byte> sv_p = EC2OSP(p, PointGFp::UNCOMPRESSED);
PointGFp p_encdec = OS2ECP(sv_p, curve);
CHECK_MESSAGE( p == p_encdec, "encoded-decoded (uncompressed) point is not equal the original!");
@@ -291,7 +291,7 @@ void test_calc_with_zeropoint()
std::cout << "." << std::flush;
std::string G_secp_comp = "024a96b5688ef573284664698968c38bb913cbfc82";
- SecureVector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
+ secure_vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
BigInt bi_p_secp("0xffffffffffffffffffffffffffffffff7fffffff");
BigInt bi_a_secp("0xffffffffffffffffffffffffffffffff7ffffffc");
BigInt bi_b_secp("0x1c97befc54bd7a8b65acf89f81d4d4adc565fa45");
@@ -327,10 +327,10 @@ void test_add_point()
std::string a_secp = "ffffffffffffffffffffffffffffffff7ffffffc";
std::string b_secp = "1c97befc54bd7a8b65acf89f81d4d4adc565fa45";
std::string G_secp_comp = "024a96b5688ef573284664698968c38bb913cbfc82";
- SecureVector<byte> sv_p_secp = hex_decode ( p_secp );
- SecureVector<byte> sv_a_secp = hex_decode ( a_secp );
- SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
- SecureVector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
+ secure_vector<byte> sv_p_secp = hex_decode ( p_secp );
+ secure_vector<byte> sv_a_secp = hex_decode ( a_secp );
+ secure_vector<byte> sv_b_secp = hex_decode ( b_secp );
+ secure_vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() );
BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() );
BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() );
@@ -363,10 +363,10 @@ void test_sub_point()
std::string a_secp = "ffffffffffffffffffffffffffffffff7ffffffc";
std::string b_secp = "1c97befc54bd7a8b65acf89f81d4d4adc565fa45";
std::string G_secp_comp = "024a96b5688ef573284664698968c38bb913cbfc82";
- SecureVector<byte> sv_p_secp = hex_decode ( p_secp );
- SecureVector<byte> sv_a_secp = hex_decode ( a_secp );
- SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
- SecureVector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
+ secure_vector<byte> sv_p_secp = hex_decode ( p_secp );
+ secure_vector<byte> sv_a_secp = hex_decode ( a_secp );
+ secure_vector<byte> sv_b_secp = hex_decode ( b_secp );
+ secure_vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() );
BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() );
BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() );
@@ -398,10 +398,10 @@ void test_mult_point()
std::string a_secp = "ffffffffffffffffffffffffffffffff7ffffffc";
std::string b_secp = "1c97befc54bd7a8b65acf89f81d4d4adc565fa45";
std::string G_secp_comp = "024a96b5688ef573284664698968c38bb913cbfc82";
- SecureVector<byte> sv_p_secp = hex_decode ( p_secp );
- SecureVector<byte> sv_a_secp = hex_decode ( a_secp );
- SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
- SecureVector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
+ secure_vector<byte> sv_p_secp = hex_decode ( p_secp );
+ secure_vector<byte> sv_a_secp = hex_decode ( a_secp );
+ secure_vector<byte> sv_b_secp = hex_decode ( b_secp );
+ secure_vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() );
BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() );
BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() );
@@ -427,10 +427,10 @@ void test_basic_operations()
std::string a_secp = "ffffffffffffffffffffffffffffffff7ffffffc";
std::string b_secp = "1c97befc54bd7a8b65acf89f81d4d4adc565fa45";
std::string G_secp_comp = "024a96b5688ef573284664698968c38bb913cbfc82";
- SecureVector<byte> sv_p_secp = hex_decode ( p_secp );
- SecureVector<byte> sv_a_secp = hex_decode ( a_secp );
- SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
- SecureVector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
+ secure_vector<byte> sv_p_secp = hex_decode ( p_secp );
+ secure_vector<byte> sv_a_secp = hex_decode ( a_secp );
+ secure_vector<byte> sv_b_secp = hex_decode ( b_secp );
+ secure_vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() );
BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() );
BigInt bi_b_secp = BigInt::decode ( &sv_b_secp[0], sv_b_secp.size() );
@@ -490,10 +490,10 @@ void test_enc_dec_compressed_160()
std::string G_secp_comp = "024A96B5688EF573284664698968C38BB913CBFC82";
std::string G_order_secp_comp = "0100000000000000000001F4C8F927AED3CA752257";
- SecureVector<byte> sv_p_secp = hex_decode ( p_secp );
- SecureVector<byte> sv_a_secp = hex_decode ( a_secp );
- SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
- SecureVector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
+ secure_vector<byte> sv_p_secp = hex_decode ( p_secp );
+ secure_vector<byte> sv_a_secp = hex_decode ( a_secp );
+ secure_vector<byte> sv_b_secp = hex_decode ( b_secp );
+ secure_vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() );
BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() );
@@ -502,7 +502,7 @@ void test_enc_dec_compressed_160()
CurveGFp secp160r1(bi_p_secp, bi_a_secp, bi_b_secp);
PointGFp p_G = OS2ECP ( sv_G_secp_comp, secp160r1 );
- SecureVector<byte> sv_result = EC2OSP(p_G, PointGFp::COMPRESSED);
+ secure_vector<byte> sv_result = EC2OSP(p_G, PointGFp::COMPRESSED);
CHECK( sv_result == sv_G_secp_comp);
}
@@ -519,10 +519,10 @@ void test_enc_dec_compressed_256()
std::string G_secp_comp = "036B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296";
std::string G_order_secp_comp = "ffffffff00000000ffffffffffffffffBCE6FAADA7179E84F3B9CAC2FC632551";
- SecureVector<byte> sv_p_secp = hex_decode ( p_secp );
- SecureVector<byte> sv_a_secp = hex_decode ( a_secp );
- SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
- SecureVector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
+ secure_vector<byte> sv_p_secp = hex_decode ( p_secp );
+ secure_vector<byte> sv_a_secp = hex_decode ( a_secp );
+ secure_vector<byte> sv_b_secp = hex_decode ( b_secp );
+ secure_vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() );
BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() );
@@ -531,7 +531,7 @@ void test_enc_dec_compressed_256()
CurveGFp secp160r1(bi_p_secp, bi_a_secp, bi_b_secp);
PointGFp p_G = OS2ECP ( sv_G_secp_comp, secp160r1 );
- SecureVector<byte> sv_result = EC2OSP(p_G, PointGFp::COMPRESSED);
+ secure_vector<byte> sv_result = EC2OSP(p_G, PointGFp::COMPRESSED);
CHECK( sv_result == sv_G_secp_comp);
}
@@ -550,10 +550,10 @@ void test_enc_dec_uncompressed_112()
std::string G_secp_uncomp = "044BA30AB5E892B4E1649DD0928643ADCD46F5882E3747DEF36E956E97";
std::string G_order_secp_uncomp = "36DF0AAFD8B8D7597CA10520D04B";
- SecureVector<byte> sv_p_secp = hex_decode ( p_secp );
- SecureVector<byte> sv_a_secp = hex_decode ( a_secp );
- SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
- SecureVector<byte> sv_G_secp_uncomp = hex_decode ( G_secp_uncomp );
+ secure_vector<byte> sv_p_secp = hex_decode ( p_secp );
+ secure_vector<byte> sv_a_secp = hex_decode ( a_secp );
+ secure_vector<byte> sv_b_secp = hex_decode ( b_secp );
+ secure_vector<byte> sv_G_secp_uncomp = hex_decode ( G_secp_uncomp );
BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() );
BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() );
@@ -562,7 +562,7 @@ void test_enc_dec_uncompressed_112()
CurveGFp secp160r1(bi_p_secp, bi_a_secp, bi_b_secp);
PointGFp p_G = OS2ECP ( sv_G_secp_uncomp, secp160r1 );
- SecureVector<byte> sv_result = EC2OSP(p_G, PointGFp::UNCOMPRESSED);
+ secure_vector<byte> sv_result = EC2OSP(p_G, PointGFp::UNCOMPRESSED);
CHECK( sv_result == sv_G_secp_uncomp);
}
@@ -579,10 +579,10 @@ void test_enc_dec_uncompressed_521()
std::string G_secp_uncomp = "0400C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2ffA8DE3348B3C1856A429BF97E7E31C2E5BD66011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650";
std::string G_order_secp_uncomp = "01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409";
- SecureVector<byte> sv_p_secp = hex_decode ( p_secp );
- SecureVector<byte> sv_a_secp = hex_decode ( a_secp );
- SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
- SecureVector<byte> sv_G_secp_uncomp = hex_decode ( G_secp_uncomp );
+ secure_vector<byte> sv_p_secp = hex_decode ( p_secp );
+ secure_vector<byte> sv_a_secp = hex_decode ( a_secp );
+ secure_vector<byte> sv_b_secp = hex_decode ( b_secp );
+ secure_vector<byte> sv_G_secp_uncomp = hex_decode ( G_secp_uncomp );
BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() );
BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() );
@@ -592,7 +592,7 @@ void test_enc_dec_uncompressed_521()
PointGFp p_G = OS2ECP ( sv_G_secp_uncomp, secp160r1 );
- SecureVector<byte> sv_result = EC2OSP(p_G, PointGFp::UNCOMPRESSED);
+ secure_vector<byte> sv_result = EC2OSP(p_G, PointGFp::UNCOMPRESSED);
std::string result = hex_encode(&sv_result[0], sv_result.size());
std::string exp_result = hex_encode(&sv_G_secp_uncomp[0], sv_G_secp_uncomp.size());
@@ -611,21 +611,21 @@ void test_enc_dec_uncompressed_521_prime_too_large()
std::string G_secp_uncomp = "0400C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2ffA8DE3348B3C1856A429BF97E7E31C2E5BD66011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650";
std::string G_order_secp_uncomp = "01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409";
- SecureVector<byte> sv_p_secp = hex_decode ( p_secp );
- SecureVector<byte> sv_a_secp = hex_decode ( a_secp );
- SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
- SecureVector<byte> sv_G_secp_uncomp = hex_decode ( G_secp_uncomp );
+ secure_vector<byte> sv_p_secp = hex_decode ( p_secp );
+ secure_vector<byte> sv_a_secp = hex_decode ( a_secp );
+ secure_vector<byte> sv_b_secp = hex_decode ( b_secp );
+ secure_vector<byte> sv_G_secp_uncomp = hex_decode ( G_secp_uncomp );
BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() );
BigInt bi_a_secp = BigInt::decode ( &sv_a_secp[0], sv_a_secp.size() );
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");
}
@@ -648,7 +648,7 @@ void test_gfp_store_restore()
PointGFp p = dom_pars.get_base_point();
//store point (to std::string)
- SecureVector<byte> sv_mes = EC2OSP(p, PointGFp::COMPRESSED);
+ secure_vector<byte> sv_mes = EC2OSP(p, PointGFp::COMPRESSED);
PointGFp new_p = OS2ECP(sv_mes, dom_pars.get_curve());
CHECK_MESSAGE( p == new_p, "original and restored point are different!");
@@ -662,7 +662,7 @@ void test_cdc_curve_33()
std::string G_secp_uncomp = "04081523d03d4f12cd02879dea4bf6a4f3a7df26ed888f10c5b2235a1274c386a2f218300dee6ed217841164533bcdc903f07a096f9fbf4ee95bac098a111f296f5830fe5c35b3e344d5df3a2256985f64fbe6d0edcc4c61d18bef681dd399df3d0194c5a4315e012e0245ecea56365baa9e8be1f7";
- SecureVector<byte> sv_G_uncomp = hex_decode ( G_secp_uncomp );
+ secure_vector<byte> sv_G_uncomp = hex_decode ( G_secp_uncomp );
BigInt bi_p_secp = BigInt("2117607112719756483104013348936480976596328609518055062007450442679169492999007105354629105748524349829824407773719892437896937279095106809");
BigInt bi_a_secp("0xa377dede6b523333d36c78e9b0eaa3bf48ce93041f6d4fc34014d08f6833807498deedd4290101c5866e8dfb589485d13357b9e78c2d7fbe9fe");
@@ -689,7 +689,7 @@ void test_more_zeropoint()
// by Falko
std::string G = "024a96b5688ef573284664698968c38bb913cbfc82";
- SecureVector<byte> sv_G_secp_comp = hex_decode ( G );
+ secure_vector<byte> sv_G_secp_comp = hex_decode ( G );
BigInt bi_p("0xffffffffffffffffffffffffffffffff7fffffff");
BigInt bi_a("0xffffffffffffffffffffffffffffffff7ffffffc");
BigInt bi_b("0x1c97befc54bd7a8b65acf89f81d4d4adc565fa45");
diff --git a/checks/ecdh.cpp b/checks/ecdh.cpp
index c641796d6..841bce55b 100644
--- a/checks/ecdh.cpp
+++ b/checks/ecdh.cpp
@@ -96,8 +96,8 @@ void test_ecdh_der_derivation(RandomNumberGenerator& rng)
ECDH_PrivateKey private_a(rng, dom_pars);
ECDH_PrivateKey private_b(rng, dom_pars);
- MemoryVector<byte> key_a = private_a.public_value();
- MemoryVector<byte> key_b = private_b.public_value();
+ std::vector<byte> key_a = private_a.public_value();
+ std::vector<byte> key_b = private_b.public_value();
PK_Key_Agreement ka(private_a, "KDF2(SHA-1)");
PK_Key_Agreement kb(private_b, "KDF2(SHA-1)");
diff --git a/checks/ecdsa.cpp b/checks/ecdsa.cpp
index 5cf353e58..554f72dd7 100644
--- a/checks/ecdsa.cpp
+++ b/checks/ecdsa.cpp
@@ -32,7 +32,7 @@ using namespace Botan;
namespace {
-std::string to_hex(const SecureVector<byte>& bin)
+std::string to_hex(const std::vector<byte>& bin)
{
return hex_encode(&bin[0], bin.size());
}
@@ -54,7 +54,7 @@ void test_hash_larger_than_n(RandomNumberGenerator& rng)
ECDSA_PrivateKey priv_key(rng, dom_pars);
- SecureVector<byte> message(20);
+ std::vector<byte> message(20);
for(size_t i = 0; i != message.size(); ++i)
message[i] = i;
@@ -64,14 +64,14 @@ void test_hash_larger_than_n(RandomNumberGenerator& rng)
PK_Signer pk_signer_224(priv_key, "EMSA1_BSI(SHA-224)");
// Verify we can sign and verify with SHA-160
- SecureVector<byte> signature_160 = pk_signer_160.sign_message(message, rng);
+ std::vector<byte> signature_160 = pk_signer_160.sign_message(message, rng);
CHECK(pk_verifier_160.verify_message(message, signature_160));
bool signature_failed = false;
try
{
- SecureVector<byte> signature_224 = pk_signer_224.sign_message(message, rng);
+ std::vector<byte> signature_224 = pk_signer_224.sign_message(message, rng);
}
catch(Encoding_Error)
{
@@ -84,7 +84,7 @@ void test_hash_larger_than_n(RandomNumberGenerator& rng)
// sign it with the normal EMSA1
PK_Signer pk_signer(priv_key, "EMSA1(SHA-224)");
- SecureVector<byte> signature = pk_signer.sign_message(message, rng);
+ std::vector<byte> signature = pk_signer.sign_message(message, rng);
PK_Verifier pk_verifier(priv_key, "EMSA1_BSI(SHA-224)");
@@ -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");
}
@@ -142,8 +142,8 @@ void test_sign_then_ver(RandomNumberGenerator& rng)
PK_Signer signer(ecdsa, "EMSA1(SHA-1)");
- SecureVector<byte> msg = hex_decode("12345678901234567890abcdef12");
- SecureVector<byte> sig = signer.sign_message(msg, rng);
+ secure_vector<byte> msg = hex_decode("12345678901234567890abcdef12");
+ std::vector<byte> sig = signer.sign_message(msg, rng);
PK_Verifier verifier(ecdsa, "EMSA1(SHA-1)");
@@ -174,7 +174,7 @@ bool test_ec_sign(RandomNumberGenerator& rng)
for(size_t i = 0; i != 256; ++i)
signer.update(static_cast<byte>(i));
- SecureVector<byte> sig = signer.signature(rng);
+ std::vector<byte> sig = signer.signature(rng);
for(u32bit i = 0; i != 256; ++i)
verifier.update(static_cast<byte>(i));
@@ -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");
@@ -267,11 +267,11 @@ void test_create_and_verify(RandomNumberGenerator& rng)
std::string G_secp_comp = "04081523d03d4f12cd02879dea4bf6a4f3a7df26ed888f10c5b2235a1274c386a2f218300dee6ed217841164533bcdc903f07a096f9fbf4ee95bac098a111f296f5830fe5c35b3e344d5df3a2256985f64fbe6d0edcc4c61d18bef681dd399df3d0194c5a4315e012e0245ecea56365baa9e8be1f7";
std::string order_g = "0e1a16196e6000000000bc7f1618d867b15bb86474418f";
- // ::SecureVector<byte> sv_p_secp = hex_decode ( p_secp );
- SecureVector<byte> sv_a_secp = hex_decode ( a_secp );
- SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
- SecureVector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
- SecureVector<byte> sv_order_g = hex_decode ( order_g );
+ // ::std::vector<byte> sv_p_secp = hex_decode ( p_secp );
+ secure_vector<byte> sv_a_secp = hex_decode ( a_secp );
+ secure_vector<byte> sv_b_secp = hex_decode ( b_secp );
+ secure_vector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
+ secure_vector<byte> sv_order_g = hex_decode ( order_g );
// BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() );
BigInt bi_p_secp("2117607112719756483104013348936480976596328609518055062007450442679169492999007105354629105748524349829824407773719892437896937279095106809");
@@ -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()))
{
@@ -343,8 +343,8 @@ void test_curve_registry(RandomNumberGenerator& rng)
PK_Signer signer(ecdsa, "EMSA1(SHA-1)");
PK_Verifier verifier(ecdsa, "EMSA1(SHA-1)");
- SecureVector<byte> msg = hex_decode("12345678901234567890abcdef12");
- SecureVector<byte> sig = signer.sign_message(msg, rng);
+ secure_vector<byte> msg = hex_decode("12345678901234567890abcdef12");
+ std::vector<byte> sig = signer.sign_message(msg, rng);
if(!verifier.verify_message(msg, sig))
std::cout << "Failed testing ECDSA sig for curve " << oids[i] << "\n";
@@ -361,17 +361,17 @@ void test_read_pkcs8(RandomNumberGenerator& rng)
{
std::cout << "." << std::flush;
- SecureVector<byte> msg = hex_decode("12345678901234567890abcdef12");
+ secure_vector<byte> msg = hex_decode("12345678901234567890abcdef12");
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");
PK_Signer signer(*ecdsa, "EMSA1(SHA-1)");
- SecureVector<byte> sig = signer.sign_message(msg, rng);
+ std::vector<byte> sig = signer.sign_message(msg, rng);
PK_Verifier verifier(*ecdsa, "EMSA1(SHA-1)");
@@ -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");
@@ -393,14 +393,14 @@ void test_read_pkcs8(RandomNumberGenerator& rng)
PK_Signer signer(*ecdsa_nodp, "EMSA1(SHA-1)");
PK_Verifier verifier(*ecdsa_nodp, "EMSA1(SHA-1)");
- SecureVector<byte> signature_nodp = signer.sign_message(msg, rng);
+ std::vector<byte> signature_nodp = signer.sign_message(msg, rng);
CHECK_MESSAGE(verifier.verify_message(msg, signature_nodp),
"generated signature could not be verified positively (no_dom)");
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..5ef5df94b 100644
--- a/checks/pk.cpp
+++ b/checks/pk.cpp
@@ -14,6 +14,12 @@
#include <botan/botan.h>
#include <botan/oids.h>
+#if defined(BOTAN_HAS_PUBLIC_KEY_CRYPTO)
+ #include <botan/x509_key.h>
+ #include <botan/pkcs8.h>
+ #include <botan/pubkey.h>
+#endif
+
#if defined(BOTAN_HAS_RSA)
#include <botan/rsa.h>
#endif
@@ -79,8 +85,8 @@ BigInt to_bigint(std::string input)
input.length(), BigInt::Hexadecimal);
}
-void dump_data(const SecureVector<byte>& out,
- const SecureVector<byte>& expected)
+void dump_data(const std::vector<byte>& out,
+ const std::vector<byte>& expected)
{
Pipe pipe(new Hex_Encoder);
@@ -102,7 +108,7 @@ void validate_save_and_load(const Private_Key* priv_key,
DataSource_Memory input_pub(pub_pem);
std::auto_ptr<Public_Key> restored_pub(X509::load_key(input_pub));
- if(restored_pub.get() == 0)
+ if(!restored_pub.get())
std::cout << "Could not recover " << name << " public key\n";
else if(restored_pub->check_key(rng, true) == false)
std::cout << "Restored pubkey failed self tests " << name << "\n";
@@ -122,7 +128,7 @@ void validate_save_and_load(const Private_Key* priv_key,
std::auto_ptr<Private_Key> restored_priv(
PKCS8::load_key(input_priv, rng));
- if(restored_priv.get() == 0)
+ if(!restored_priv.get())
std::cout << "Could not recover " << name << " privlic key\n";
else if(restored_priv->check_key(rng, true) == false)
std::cout << "Restored privkey failed self tests " << name << "\n";
@@ -136,11 +142,11 @@ void validate_save_and_load(const Private_Key* priv_key,
}
void validate_decryption(PK_Decryptor& d, const std::string& algo,
- const SecureVector<byte> ctext,
- const SecureVector<byte> ptext,
+ const std::vector<byte> ctext,
+ const std::vector<byte> ptext,
bool& failure)
{
- SecureVector<byte> decrypted = d.decrypt(ctext);
+ std::vector<byte> decrypted = unlock(d.decrypt(ctext));
if(decrypted != ptext)
{
std::cout << "FAILED (decrypt): " << algo << std::endl;
@@ -154,11 +160,11 @@ void validate_encryption(PK_Encryptor& e, PK_Decryptor& d,
const std::string& random, const std::string& exp,
bool& failure)
{
- SecureVector<byte> message = hex_decode(input);
- SecureVector<byte> expected = hex_decode(exp);
+ std::vector<byte> message = unlock(hex_decode(input));
+ std::vector<byte> expected = unlock(hex_decode(exp));
Fixed_Output_RNG rng(hex_decode(random));
- SecureVector<byte> out = e.encrypt(message, rng);
+ std::vector<byte> out = e.encrypt(message, rng);
if(out != expected)
{
std::cout << "FAILED (encrypt): " << algo << std::endl;
@@ -174,11 +180,11 @@ void validate_signature(PK_Verifier& v, PK_Signer& s, const std::string& algo,
RandomNumberGenerator& rng,
const std::string& exp, bool& failure)
{
- SecureVector<byte> message = hex_decode(input);
+ std::vector<byte> message = unlock(hex_decode(input));
- SecureVector<byte> expected = hex_decode(exp);
+ std::vector<byte> expected = unlock(hex_decode(exp));
- SecureVector<byte> sig = s.sign_message(message, rng);
+ std::vector<byte> sig = s.sign_message(message, rng);
if(sig != expected)
{
@@ -214,18 +220,18 @@ void validate_signature(PK_Verifier& v, PK_Signer& s, const std::string& algo,
}
void validate_kas(PK_Key_Agreement& kas, const std::string& algo,
- const SecureVector<byte>& pubkey, const std::string& output,
+ const std::vector<byte>& pubkey, const std::string& output,
u32bit keylen, bool& failure)
{
- SecureVector<byte> expected = hex_decode(output);
+ secure_vector<byte> expected = hex_decode(output);
- SecureVector<byte> got = kas.derive_key(keylen,
- pubkey).bits_of();
+ secure_vector<byte> got = kas.derive_key(keylen,
+ pubkey).bits_of();
if(got != expected)
{
std::cout << "FAILED: " << algo << std::endl;
- dump_data(got, expected);
+ dump_data(unlock(got), unlock(expected));
failure = true;
}
}
@@ -247,7 +253,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)
@@ -319,8 +325,8 @@ u32bit validate_elg_enc(const std::string& algo,
validate_encryption(e, d, algo, str[4], str[5], str[6], failure);
}
else
- validate_decryption(d, algo, hex_decode(str[5]),
- hex_decode(str[4]), failure);
+ validate_decryption(d, algo, unlock(hex_decode(str[5])),
+ unlock(hex_decode(str[4])), failure);
return (failure ? 1 : 0);
#endif
@@ -367,8 +373,8 @@ u32bit validate_rsa_ver(const std::string& algo,
PK_Verifier v(key, emsa);
- SecureVector<byte> msg = hex_decode(str[2]);
- SecureVector<byte> sig = hex_decode(str[3]);
+ std::vector<byte> msg = unlock(hex_decode(str[2]));
+ std::vector<byte> sig = unlock(hex_decode(str[3]));
bool passed = true;
passed = v.verify_message(msg, sig);
@@ -388,7 +394,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());
@@ -399,8 +405,8 @@ u32bit validate_rsa_ver_x509(const std::string& algo,
PK_Verifier v(*rsakey, emsa);
- SecureVector<byte> msg = hex_decode(str[1]);
- SecureVector<byte> sig = hex_decode(str[2]);
+ std::vector<byte> msg = unlock(hex_decode(str[1]));
+ std::vector<byte> sig = unlock(hex_decode(str[2]));
bool passed = v.verify_message(msg, sig);
return (passed ? 0 : 1);
@@ -423,8 +429,8 @@ u32bit validate_rw_ver(const std::string& algo,
PK_Verifier v(key, emsa);
- SecureVector<byte> msg = hex_decode(str[2]);
- SecureVector<byte> sig = hex_decode(str[3]);
+ std::vector<byte> msg = unlock(hex_decode(str[2]));
+ std::vector<byte> sig = unlock(hex_decode(str[3]));
bool passed = true;
passed = v.verify_message(msg, sig);
@@ -476,7 +482,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)
@@ -532,7 +538,7 @@ u32bit validate_gost_ver(const std::string& algo,
EC_Group group(OIDS::lookup(str[0]));
- PointGFp public_point = OS2ECP(hex_decode(str[1]), group.get_curve());
+ PointGFp public_point = OS2ECP(unlock(hex_decode(str[1])), group.get_curve());
GOST_3410_PublicKey gost(group, public_point);
@@ -540,8 +546,8 @@ u32bit validate_gost_ver(const std::string& algo,
PK_Verifier v(gost, emsa);
- SecureVector<byte> msg = hex_decode(str[2]);
- SecureVector<byte> sig = hex_decode(str[3]);
+ std::vector<byte> msg = unlock(hex_decode(str[2]));
+ std::vector<byte> sig = unlock(hex_decode(str[3]));
bool passed = v.verify_message(msg, sig);
return (passed ? 0 : 1);
@@ -561,7 +567,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());
@@ -572,8 +578,8 @@ u32bit validate_dsa_ver(const std::string& algo,
PK_Verifier v(*dsakey, emsa);
- SecureVector<byte> msg = hex_decode(str[1]);
- SecureVector<byte> sig = hex_decode(str[2]);
+ std::vector<byte> msg = unlock(hex_decode(str[1]));
+ std::vector<byte> sig = unlock(hex_decode(str[2]));
v.set_input_format(DER_SEQUENCE);
bool passed = v.verify_message(msg, sig);
diff --git a/checks/pk_bench.cpp b/checks/pk_bench.cpp
index de8ad0730..da2221b90 100644
--- a/checks/pk_bench.cpp
+++ b/checks/pk_bench.cpp
@@ -10,6 +10,12 @@
#include <botan/oids.h>
#include <map>
+#if defined(BOTAN_HAS_PUBLIC_KEY_CRYPTO)
+ #include <botan/x509_key.h>
+ #include <botan/pkcs8.h>
+ #include <botan/pubkey.h>
+#endif
+
#if defined(BOTAN_HAS_RSA)
#include <botan/rsa.h>
#endif
@@ -77,7 +83,7 @@ const char* ec_domains[] = {
"secp256r1",
"secp384r1",
"secp521r1",
- 0
+ nullptr
};
class Benchmark_Report
@@ -98,7 +104,7 @@ void benchmark_enc_dec(PK_Encryptor& enc, PK_Decryptor& dec,
RandomNumberGenerator& rng,
u32bit runs, double seconds)
{
- SecureVector<byte> plaintext, ciphertext;
+ std::vector<byte> plaintext, ciphertext;
for(u32bit i = 0; i != runs; ++i)
{
@@ -121,7 +127,7 @@ void benchmark_enc_dec(PK_Encryptor& enc, PK_Decryptor& dec,
if(dec_timer.seconds() < seconds)
{
dec_timer.start();
- SecureVector<byte> plaintext_out = dec.decrypt(ciphertext);
+ std::vector<byte> plaintext_out = unlock(dec.decrypt(ciphertext));
dec_timer.stop();
if(plaintext_out != plaintext)
@@ -137,7 +143,7 @@ void benchmark_sig_ver(PK_Verifier& ver, PK_Signer& sig,
RandomNumberGenerator& rng,
u32bit runs, double seconds)
{
- SecureVector<byte> message, signature, sig_random;
+ std::vector<byte> message, signature, sig_random;
for(u32bit i = 0; i != runs; ++i)
{
@@ -165,7 +171,7 @@ void benchmark_sig_ver(PK_Verifier& ver, PK_Signer& sig,
if((i % 100) == 0)
{
- sig_random = rng.random_vec(signature.size());
+ sig_random = unlock(rng.random_vec(signature.size()));
verify_timer.start();
const bool verified_bad = ver.verify_message(message, sig_random);
@@ -240,7 +246,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 +298,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 +325,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 +345,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 +387,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 +445,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);
}
@@ -456,7 +462,7 @@ void benchmark_dsa_nr(RandomNumberGenerator& rng,
const char* domains[] = { "dsa/jce/1024",
"dsa/botan/2048",
"dsa/botan/3072",
- NULL };
+ nullptr };
std::string algo_name;
@@ -465,7 +471,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 +494,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);
@@ -507,7 +513,7 @@ void benchmark_dh(RandomNumberGenerator& rng,
"modp/ietf/4096",
"modp/ietf/6144",
"modp/ietf/8192",
- NULL };
+ nullptr };
for(size_t j = 0; domains[j]; j++)
{
@@ -568,7 +574,7 @@ void benchmark_dlies(RandomNumberGenerator& rng,
"modp/ietf/4096",
"modp/ietf/6144",
"modp/ietf/8192",
- NULL };
+ nullptr };
for(size_t j = 0; domains[j]; j++)
{
@@ -627,7 +633,7 @@ void benchmark_elg(RandomNumberGenerator& rng,
"modp/ietf/4096",
"modp/ietf/6144",
"modp/ietf/8192",
- NULL };
+ nullptr };
const std::string algo_name = "ElGamal";
@@ -657,7 +663,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.cpp b/checks/validate.cpp
index 65317604e..bae5e857f 100644
--- a/checks/validate.cpp
+++ b/checks/validate.cpp
@@ -110,6 +110,7 @@ bool keywrap_test(const char* key_str,
bool ok = true;
+#if defined(BOTAN_HAS_RFC3394_KEYWRAP)
try
{
SymmetricKey key(key_str);
@@ -118,7 +119,7 @@ bool keywrap_test(const char* key_str,
Algorithm_Factory& af = global_state().algorithm_factory();
- SecureVector<byte> enc = rfc3394_keywrap(key.bits_of(), kek, af);
+ secure_vector<byte> enc = rfc3394_keywrap(key.bits_of(), kek, af);
if(enc != expected.bits_of())
{
@@ -127,7 +128,7 @@ bool keywrap_test(const char* key_str,
ok = false;
}
- SecureVector<byte> dec = rfc3394_keyunwrap(expected.bits_of(), kek, af);
+ secure_vector<byte> dec = rfc3394_keyunwrap(expected.bits_of(), kek, af);
if(dec != key.bits_of())
{
@@ -140,6 +141,7 @@ bool keywrap_test(const char* key_str,
{
std::cout << e.what() << "\n";
}
+#endif
return ok;
}
@@ -339,7 +341,7 @@ u32bit do_validation_tests(const std::string& filename,
if(should_pass)
std::cout << "Testing " << algorithm << "..." << std::endl;
else
- std::cout << "Testing (expecing failure) "
+ std::cout << "Testing (expecting failure) "
<< algorithm << "..." << std::endl;
#endif
alg_count = 0;
@@ -472,8 +474,10 @@ bool failed_test(const std::string& algo,
try {
Botan::Filter* test = lookup(algo, params);
- if(test == 0 && is_extension) return !exp_pass;
- if(test == 0)
+
+ if(!test && is_extension) return !exp_pass;
+
+ if(!test)
{
if(algo != last_missing)
{
@@ -488,7 +492,7 @@ bool failed_test(const std::string& algo,
pipe.append(test);
pipe.append(new Botan::Hex_Encoder);
- Botan::SecureVector<byte> data = Botan::hex_decode(in);
+ secure_vector<byte> data = Botan::hex_decode(in);
const byte* data_ptr = &data[0];
// this can help catch errors with buffering, etc
@@ -536,7 +540,7 @@ bool failed_test(const std::string& algo,
size_t offset = random_word(rng, pipe.remaining() - 1);
size_t length = random_word(rng, pipe.remaining() - offset);
- Botan::SecureVector<byte> peekbuf(length);
+ std::vector<byte> peekbuf(length);
pipe.peek(&peekbuf[0], peekbuf.size(), offset);
output = pipe.read_all_as_string();
diff --git a/checks/validate.dat b/checks/validate.dat
index 6b9a49e52..7b221db49 100644
--- a/checks/validate.dat
+++ b/checks/validate.dat
@@ -4123,25 +4123,64 @@ F0E1D2C3B4A5968778695A4B3C2D1E0F00112233445566
FEDCBA9876543210:05044B62FA52D080:\
F0E1D2C3B4A5968778695A4B3C2D1E0F0011223344556677
-[Camellia]
+[Camellia-128]
# From RFC 3713
-
0123456789ABCDEFFEDCBA9876543210:67673138549669730857065648EABE43:\
0123456789ABCDEFFEDCBA9876543210
+# Nessie
+00000000000000000000000000000000:6C227F749319A3AA7DA235A9BBA05A2C:\
+80000000000000000000000000000000
+
+00000000000000000000000000000000:F04D51E45E70FB6DEE0D16A204FBBA16:\
+40000000000000000000000000000000
+
+00000000000000000000000000000000:ED44242E619F8C32EAA2D3641DA47EA4:\
+20000000000000000000000000000000
+
+EFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEF:5CA8B8A4B8AF15A6184259831B18BBB5:\
+EFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEF
+
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:25DD9EB9DD67FBC6E8431F56F4FBE651:\
+FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+
+
+[Camellia-192]
+# From RFC 3713
0123456789ABCDEFFEDCBA9876543210:B4993401B3E996F84EE5CEE7D79B09B9:\
0123456789ABCDEFFEDCBA98765432100011223344556677
+# Nessie
+
+00000000000000000000000000000000:1B6220D365C2176C1D41A5826520FCA1:\
+800000000000000000000000000000000000000000000000
+
+FEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFE:A2F5A98929658AF4A9700B9923DAF014:\
+FEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFE
+
+[Camellia-256]
+# From RFC 3713
0123456789ABCDEFFEDCBA9876543210:9ACC237DFF16D76C20EF7C919E3A7509:\
0123456789ABCDEFFEDCBA987654321000112233445566778899AABBCCDDEEFF
-# From NESSIE
+00000000000000000000000000000000:2136FABDA091DFB5171B94B8EFBB5D08:\
+8000000000000000000000000000000000000000000000000000000000000000
-00000000000000000000000000000000:6C227F749319A3AA7DA235A9BBA05A2C:\
-80000000000000000000000000000000
+00000000000000000000000000000000:E18B0CB1980124504B46A46A6F4273F3:\
+0000000000000200000000000000000000000000000000000000000000000000
-FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:25DD9EB9DD67FBC6E8431F56F4FBE651:\
-FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+00000000000000000000000000000001:9CDB269B5D293BC5DB9C55B057D9B591:\
+0000000000000000000000000000000000000000000000000000000000000000
+
+0000000000000000000000000000000000000000000000000000000000000001\
+0000000000000000000000000000000200000000000000000000000000000004\
+0000000000000000000000000000000800000000000000000000000000000010\
+0000000000000000000000000000002000000000000000000000000000000040:\
+396154111ADEFC500CF6E5C99038BC179CDB269B5D293BC5DB9C55B057D9B591\
+3D4B2CDE666761BA5DFB305178E667FB6A3F25AAB7E92D9CF378E5D9C040F26B\
+7C92854D801A1648F65CA81813DDBF83BA664AC39855518DFDEE10D1B3111FAE\
+7A6985778D3A66E97F23E01F0D0E45E78B1F247802E47C91BEE2AA34ECFD7A01:\
+0000000000000000000000000000000000000000000000000000000000000000
# First one is from RFC 2144. The rest were done with OpenSSL and bits taken
# from /dev/urandom
@@ -67685,6 +67724,8 @@ DC37E008CF9EE69BF11F00ED9ABA26901DD7C28CDEC066CC6AF42E40F82F3A1E\
[Parallel(MD5,SHA-1)]
:D41D8CD98F00B204E9800998ECF8427EDA39A3EE5E6B4B0D3255BFEF95601890AFD80709
+61:0CC175B9C0F1B6A831C399E26977266186F7E437FAA5A7FCE15D1DDCB9EAEAEA377667B8
+
[Parallel(SHA-160,Tiger(24,3))]
:DA39A3EE5E6B4B0D3255BFEF95601890AFD807093293AC630\
C13F0245F92BBB1766E16167A4E58492DDE73F3
diff --git a/checks/x509.cpp b/checks/x509.cpp
index 138d1b346..46b748da6 100644
--- a/checks/x509.cpp
+++ b/checks/x509.cpp
@@ -49,7 +49,7 @@ u64bit key_id(const Public_Key* key)
pipe.write(key->x509_subject_public_key());
pipe.end_msg();
- SecureVector<byte> output = pipe.read_all();
+ secure_vector<byte> output = pipe.read_all();
if(output.size() != 8)
throw Internal_Error("Public_Key::key_id: Incorrect output size");
@@ -147,7 +147,6 @@ void do_x509_tests(RandomNumberGenerator& rng)
std::cout << '.' << std::flush;
/* Create user #1's key and cert request */
- std::cout << '.' << std::flush;
DSA_PrivateKey user1_key(rng, DL_Group("dsa/botan/2048"));
std::cout << '.' << std::flush;