aboutsummaryrefslogtreecommitdiffstats
path: root/checks
diff options
context:
space:
mode:
Diffstat (limited to 'checks')
-rw-r--r--checks/common.h4
-rw-r--r--checks/cvc_tests.cpp22
-rw-r--r--checks/ec_tests.cpp76
-rw-r--r--checks/ecdsa.cpp10
-rw-r--r--checks/pk_bench.cpp4
5 files changed, 58 insertions, 58 deletions
diff --git a/checks/common.h b/checks/common.h
index 493e2fc74..6b504c454 100644
--- a/checks/common.h
+++ b/checks/common.h
@@ -69,12 +69,12 @@ class Fixed_Output_RNG : public Botan::RandomNumberGenerator
Fixed_Output_RNG(const Botan::SecureVector<byte>& in)
{
- buf.insert(buf.end(), in.begin(), in.begin() + in.size());
+ 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);
- buf.insert(buf.end(), in.begin(), in.begin() + in.size());
+ buf.insert(buf.end(), in.begin(), in.end());
}
Fixed_Output_RNG() {}
diff --git a/checks/cvc_tests.cpp b/checks/cvc_tests.cpp
index 5bd671ba6..ab0158351 100644
--- a/checks/cvc_tests.cpp
+++ b/checks/cvc_tests.cpp
@@ -42,7 +42,7 @@ void helper_write_file(EAC_Signed_Object const& to_write, std::string const& fil
{
SecureVector<byte> sv = to_write.BER_encode();
std::ofstream cert_file(file_path.c_str(), std::ios::binary);
- cert_file.write((char*)sv.begin(), sv.size());
+ cert_file.write((char*)&sv[0], sv.size());
cert_file.close();
}
@@ -98,7 +98,7 @@ void test_enc_gen_selfsigned(RandomNumberGenerator& rng)
std::ofstream cert_file;
cert_file.open(TEST_DATA_DIR "/my_cv_cert.ber", std::ios::binary);
//cert_file << der; // this is bad !!!
- cert_file.write((char*)der.begin(), der.size());
+ cert_file.write((char*)&der[0], der.size());
cert_file.close();
EAC1_1_CVC cert_in(TEST_DATA_DIR "/my_cv_cert.ber");
@@ -106,7 +106,7 @@ void test_enc_gen_selfsigned(RandomNumberGenerator& rng)
// encoding it again while it has no dp
SecureVector<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.begin(), der2.size());
+ 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");
@@ -205,7 +205,7 @@ void test_enc_gen_req(RandomNumberGenerator& rng)
EAC1_1_Req req = CVC_EAC::create_cvc_req(key, opts.chr, opts.hash_alg, rng);
SecureVector<byte> der(req.BER_encode());
std::ofstream req_file(TEST_DATA_DIR "/my_cv_req.ber", std::ios::binary);
- req_file.write((char*)der.begin(), der.size());
+ req_file.write((char*)&der[0], der.size());
req_file.close();
// read and check signature...
@@ -262,7 +262,7 @@ void test_cvc_ado_creation(RandomNumberGenerator& rng)
EAC1_1_Req req = CVC_EAC::create_cvc_req(req_key, opts.chr, opts.hash_alg, rng);
SecureVector<byte> der(req.BER_encode());
std::ofstream req_file(TEST_DATA_DIR "/my_cv_req.ber", std::ios::binary);
- req_file.write((char*)der.begin(), der.size());
+ req_file.write((char*)&der[0], der.size());
req_file.close();
// create an ado with that req
@@ -277,7 +277,7 @@ void test_cvc_ado_creation(RandomNumberGenerator& rng)
std::ofstream ado_file(TEST_DATA_DIR "/ado", std::ios::binary);
SecureVector<byte> ado_der(ado.BER_encode());
- ado_file.write((char*)ado_der.begin(), ado_der.size());
+ ado_file.write((char*)&ado_der[0], ado_der.size());
ado_file.close();
// read it again and check the signature
EAC1_1_ADO ado2(TEST_DATA_DIR "/ado");
@@ -333,7 +333,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());
- // ado_file.write((char*)ado_der.begin(), ado_der.size());
+ // ado_file.write((char*)&ado_der[0], ado_der.size());
// ado_file.close();
// read it again and check the signature
@@ -494,7 +494,7 @@ void test_cvc_chain(RandomNumberGenerator& rng)
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();
- cvca_file.write((char*)cvca_sv.begin(), cvca_sv.size());
+ cvca_file.write((char*)&cvca_sv[0], cvca_sv.size());
cvca_file.close();
ECDSA_PrivateKey cvca_privk2(rng, dom_pars);
@@ -503,7 +503,7 @@ void test_cvc_chain(RandomNumberGenerator& rng)
EAC1_1_CVC link12 = DE_EAC::link_cvca(cvca_cert, cvca_privk, cvca_cert2, rng);
SecureVector<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.begin(), link12_sv.size());
+ link12_file.write((char*)&link12_sv[0], link12_sv.size());
link12_file.close();
// verify the link
@@ -518,7 +518,7 @@ void test_cvc_chain(RandomNumberGenerator& rng)
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();
- dvca_file.write((char*)dvca_sv.begin(), dvca_sv.size());
+ dvca_file.write((char*)&dvca_sv[0], dvca_sv.size());
dvca_file.close();
// sign the dvca_request
@@ -532,7 +532,7 @@ void test_cvc_chain(RandomNumberGenerator& rng)
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();
- dvca_file2.write((char*)dvca_sv2.begin(), dvca_sv2.size());
+ 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,
ASN1_Car(dvca_cert1.get_chr().iso_8859()), rng);
diff --git a/checks/ec_tests.cpp b/checks/ec_tests.cpp
index 39ca1ded5..1f31cb2cf 100644
--- a/checks/ec_tests.cpp
+++ b/checks/ec_tests.cpp
@@ -75,9 +75,9 @@ void test_point_turn_on_sp_red_mul()
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);
- BigInt bi_p_secp = BigInt::decode(sv_p_secp.begin(), sv_p_secp.size());
- BigInt bi_a_secp = BigInt::decode(sv_a_secp.begin(), sv_a_secp.size());
- BigInt bi_b_secp = BigInt::decode(sv_b_secp.begin(), sv_b_secp.size());
+ 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 secp160r1(bi_p_secp, bi_a_secp, bi_b_secp);
PointGFp p_G = OS2ECP(sv_G_secp_comp, secp160r1);
@@ -139,9 +139,9 @@ void test_coordinates()
SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
SecureVector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
- BigInt bi_p_secp = BigInt::decode ( sv_p_secp.begin(), sv_p_secp.size() );
- BigInt bi_a_secp = BigInt::decode ( sv_a_secp.begin(), sv_a_secp.size() );
- BigInt bi_b_secp = BigInt::decode ( sv_b_secp.begin(), sv_b_secp.size() );
+ 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 secp160r1 (bi_p_secp, bi_a_secp, bi_b_secp);
PointGFp p_G = OS2ECP ( sv_G_secp_comp, secp160r1 );
PointGFp p0 = p_G;
@@ -214,9 +214,9 @@ void test_point_negative()
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 );
- BigInt bi_p_secp = BigInt::decode ( sv_p_secp.begin(), sv_p_secp.size() );
- BigInt bi_a_secp = BigInt::decode ( sv_a_secp.begin(), sv_a_secp.size() );
- BigInt bi_b_secp = BigInt::decode ( sv_b_secp.begin(), sv_b_secp.size() );
+ 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 secp160r1(bi_p_secp, bi_a_secp, bi_b_secp);
PointGFp p_G = OS2ECP ( sv_G_secp_comp, secp160r1 );
@@ -326,9 +326,9 @@ void test_add_point()
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 );
- BigInt bi_p_secp = BigInt::decode ( sv_p_secp.begin(), sv_p_secp.size() );
- BigInt bi_a_secp = BigInt::decode ( sv_a_secp.begin(), sv_a_secp.size() );
- BigInt bi_b_secp = BigInt::decode ( sv_b_secp.begin(), sv_b_secp.size() );
+ 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 secp160r1(bi_p_secp, bi_a_secp, bi_b_secp);
PointGFp p_G = OS2ECP ( sv_G_secp_comp, secp160r1 );
@@ -362,9 +362,9 @@ void test_sub_point()
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 );
- BigInt bi_p_secp = BigInt::decode ( sv_p_secp.begin(), sv_p_secp.size() );
- BigInt bi_a_secp = BigInt::decode ( sv_a_secp.begin(), sv_a_secp.size() );
- BigInt bi_b_secp = BigInt::decode ( sv_b_secp.begin(), sv_b_secp.size() );
+ 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 secp160r1(bi_p_secp, bi_a_secp, bi_b_secp);
PointGFp p_G = OS2ECP ( sv_G_secp_comp, secp160r1 );
@@ -397,9 +397,9 @@ void test_mult_point()
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 );
- BigInt bi_p_secp = BigInt::decode ( sv_p_secp.begin(), sv_p_secp.size() );
- BigInt bi_a_secp = BigInt::decode ( sv_a_secp.begin(), sv_a_secp.size() );
- BigInt bi_b_secp = BigInt::decode ( sv_b_secp.begin(), sv_b_secp.size() );
+ 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 secp160r1(bi_p_secp, bi_a_secp, bi_b_secp);
PointGFp p_G = OS2ECP ( sv_G_secp_comp, secp160r1 );
@@ -426,9 +426,9 @@ void test_basic_operations()
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 );
- BigInt bi_p_secp = BigInt::decode ( sv_p_secp.begin(), sv_p_secp.size() );
- BigInt bi_a_secp = BigInt::decode ( sv_a_secp.begin(), sv_a_secp.size() );
- BigInt bi_b_secp = BigInt::decode ( sv_b_secp.begin(), sv_b_secp.size() );
+ 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 secp160r1(bi_p_secp, bi_a_secp, bi_b_secp);
PointGFp p_G = OS2ECP ( sv_G_secp_comp, secp160r1 );
@@ -490,9 +490,9 @@ void test_enc_dec_compressed_160()
SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
SecureVector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
- BigInt bi_p_secp = BigInt::decode ( sv_p_secp.begin(), sv_p_secp.size() );
- BigInt bi_a_secp = BigInt::decode ( sv_a_secp.begin(), sv_a_secp.size() );
- BigInt bi_b_secp = BigInt::decode ( sv_b_secp.begin(), sv_b_secp.size() );
+ 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 secp160r1(bi_p_secp, bi_a_secp, bi_b_secp);
@@ -519,9 +519,9 @@ void test_enc_dec_compressed_256()
SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
SecureVector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
- BigInt bi_p_secp = BigInt::decode ( sv_p_secp.begin(), sv_p_secp.size() );
- BigInt bi_a_secp = BigInt::decode ( sv_a_secp.begin(), sv_a_secp.size() );
- BigInt bi_b_secp = BigInt::decode ( sv_b_secp.begin(), sv_b_secp.size() );
+ 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 secp160r1(bi_p_secp, bi_a_secp, bi_b_secp);
@@ -550,9 +550,9 @@ void test_enc_dec_uncompressed_112()
SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
SecureVector<byte> sv_G_secp_uncomp = hex_decode ( G_secp_uncomp );
- BigInt bi_p_secp = BigInt::decode ( sv_p_secp.begin(), sv_p_secp.size() );
- BigInt bi_a_secp = BigInt::decode ( sv_a_secp.begin(), sv_a_secp.size() );
- BigInt bi_b_secp = BigInt::decode ( sv_b_secp.begin(), sv_b_secp.size() );
+ 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 secp160r1(bi_p_secp, bi_a_secp, bi_b_secp);
@@ -579,17 +579,17 @@ void test_enc_dec_uncompressed_521()
SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
SecureVector<byte> sv_G_secp_uncomp = hex_decode ( G_secp_uncomp );
- BigInt bi_p_secp = BigInt::decode ( sv_p_secp.begin(), sv_p_secp.size() );
- BigInt bi_a_secp = BigInt::decode ( sv_a_secp.begin(), sv_a_secp.size() );
- BigInt bi_b_secp = BigInt::decode ( sv_b_secp.begin(), sv_b_secp.size() );
+ 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 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);
- std::string result = hex_encode(sv_result.begin(), sv_result.size());
- std::string exp_result = hex_encode(sv_G_secp_uncomp.begin(), sv_G_secp_uncomp.size());
+ 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());
CHECK_MESSAGE( sv_result == sv_G_secp_uncomp, "\ncalc. result = " << result << "\nexp. result = " << exp_result << "\n");
}
@@ -611,9 +611,9 @@ void test_enc_dec_uncompressed_521_prime_too_large()
SecureVector<byte> sv_b_secp = hex_decode ( b_secp );
SecureVector<byte> sv_G_secp_uncomp = hex_decode ( G_secp_uncomp );
- BigInt bi_p_secp = BigInt::decode ( sv_p_secp.begin(), sv_p_secp.size() );
- BigInt bi_a_secp = BigInt::decode ( sv_a_secp.begin(), sv_a_secp.size() );
- BigInt bi_b_secp = BigInt::decode ( sv_b_secp.begin(), sv_b_secp.size() );
+ 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;
diff --git a/checks/ecdsa.cpp b/checks/ecdsa.cpp
index d9a1784fe..9cacad70a 100644
--- a/checks/ecdsa.cpp
+++ b/checks/ecdsa.cpp
@@ -33,7 +33,7 @@ namespace {
std::string to_hex(const SecureVector<byte>& bin)
{
- return hex_encode(bin.begin(), bin.size());
+ return hex_encode(&bin[0], bin.size());
}
/**
@@ -295,11 +295,11 @@ void test_create_and_verify(RandomNumberGenerator& rng)
SecureVector<byte> sv_G_secp_comp = hex_decode ( G_secp_comp );
SecureVector<byte> sv_order_g = hex_decode ( order_g );
- // BigInt bi_p_secp = BigInt::decode ( sv_p_secp.begin(), sv_p_secp.size() );
+ // BigInt bi_p_secp = BigInt::decode ( &sv_p_secp[0], sv_p_secp.size() );
BigInt bi_p_secp("2117607112719756483104013348936480976596328609518055062007450442679169492999007105354629105748524349829824407773719892437896937279095106809");
- BigInt bi_a_secp = BigInt::decode ( sv_a_secp.begin(), sv_a_secp.size() );
- BigInt bi_b_secp = BigInt::decode ( sv_b_secp.begin(), sv_b_secp.size() );
- BigInt bi_order_g = BigInt::decode ( sv_order_g.begin(), sv_order_g.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() );
+ BigInt bi_order_g = BigInt::decode ( &sv_order_g[0], sv_order_g.size() );
CurveGFp curve(bi_p_secp, bi_a_secp, bi_b_secp);
PointGFp p_G = OS2ECP ( sv_G_secp_comp, curve );
diff --git a/checks/pk_bench.cpp b/checks/pk_bench.cpp
index 41344f104..41108d9ac 100644
--- a/checks/pk_bench.cpp
+++ b/checks/pk_bench.cpp
@@ -106,7 +106,7 @@ void benchmark_enc_dec(PK_Encryptor& enc, PK_Decryptor& dec,
// Ensure for Raw, etc, it stays large
if((i % 100) == 0)
{
- rng.randomize(plaintext.begin(), plaintext.size());
+ rng.randomize(&plaintext[0], plaintext.size());
plaintext[0] |= 0x80;
}
@@ -143,7 +143,7 @@ void benchmark_sig_ver(PK_Verifier& ver, PK_Signer& sig,
if((i % 100) == 0)
{
message.resize(48);
- rng.randomize(message.begin(), message.size());
+ rng.randomize(&message[0], message.size());
}
sig_timer.start();