aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_cvc.cpp
diff options
context:
space:
mode:
authorSimon Warta <[email protected]>2015-06-29 13:11:23 +0200
committerSimon Warta <[email protected]>2015-06-30 10:38:23 +0200
commit8668ce8753b10e944bdc72b6e66d752759c7e710 (patch)
tree787e9829c871748b34594d35f3a5e6569ccdbb31 /src/tests/test_cvc.cpp
parentb90187419f64b6d38d19c888985d58f902336677 (diff)
tests: Convert &vec[0] to vec.data()
Diffstat (limited to 'src/tests/test_cvc.cpp')
-rw-r--r--src/tests/test_cvc.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/tests/test_cvc.cpp b/src/tests/test_cvc.cpp
index a2e398c37..9b11dea7c 100644
--- a/src/tests/test_cvc.cpp
+++ b/src/tests/test_cvc.cpp
@@ -45,7 +45,7 @@ void helper_write_file(EAC_Signed_Object const& to_write, std::string const& fil
{
std::vector<byte> sv = to_write.BER_encode();
std::ofstream cert_file(file_path, std::ios::binary);
- cert_file.write((char*)&sv[0], sv.size());
+ cert_file.write((char*)sv.data(), sv.size());
cert_file.close();
}
@@ -99,7 +99,7 @@ void test_enc_gen_selfsigned(RandomNumberGenerator& rng)
std::ofstream cert_file;
cert_file.open(CVC_TEST_DATA_DIR "/my_cv_cert.ber", std::ios::binary);
//cert_file << der; // this is bad !!!
- cert_file.write((char*)&der[0], der.size());
+ cert_file.write((char*)der.data(), der.size());
cert_file.close();
EAC1_1_CVC cert_in(CVC_TEST_DATA_DIR "/my_cv_cert.ber");
@@ -107,7 +107,7 @@ void test_enc_gen_selfsigned(RandomNumberGenerator& rng)
// encoding it again while it has no dp
std::vector<byte> der2(cert_in.BER_encode());
std::ofstream cert_file2(CVC_TEST_DATA_DIR "/my_cv_cert2.ber", std::ios::binary);
- cert_file2.write((char*)&der2[0], der2.size());
+ cert_file2.write((char*)der2.data(), der2.size());
cert_file2.close();
// read both and compare them
std::ifstream cert_1_in(CVC_TEST_DATA_DIR "/my_cv_cert.ber");
@@ -204,7 +204,7 @@ void test_enc_gen_req(RandomNumberGenerator& rng)
EAC1_1_Req req = CVC_EAC::create_cvc_req(key, opts.chr, opts.hash_alg, rng);
std::vector<byte> der(req.BER_encode());
std::ofstream req_file(CVC_TEST_DATA_DIR "/my_cv_req.ber", std::ios::binary);
- req_file.write((char*)&der[0], der.size());
+ req_file.write((char*)der.data(), der.size());
req_file.close();
// read and check signature...
@@ -255,7 +255,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);
std::vector<byte> der(req.BER_encode());
std::ofstream req_file(CVC_TEST_DATA_DIR "/my_cv_req.ber", std::ios::binary);
- req_file.write((char*)&der[0], der.size());
+ req_file.write((char*)der.data(), der.size());
req_file.close();
// create an ado with that req
@@ -270,7 +270,7 @@ void test_cvc_ado_creation(RandomNumberGenerator& rng)
std::ofstream ado_file(CVC_TEST_DATA_DIR "/ado", std::ios::binary);
std::vector<byte> ado_der(ado.BER_encode());
- ado_file.write((char*)&ado_der[0], ado_der.size());
+ ado_file.write((char*)ado_der.data(), ado_der.size());
ado_file.close();
// read it again and check the signature
EAC1_1_ADO ado2(CVC_TEST_DATA_DIR "/ado");
@@ -324,7 +324,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(CVC_TEST_DATA_DIR "/ado");
// std::vector<byte> ado_der(ado.BER_encode());
- // ado_file.write((char*)&ado_der[0], ado_der.size());
+ // ado_file.write((char*)ado_der.data(), ado_der.size());
// ado_file.close();
// read it again and check the signature
@@ -470,7 +470,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(CVC_TEST_DATA_DIR "/cvc_chain_cvca.cer", std::ios::binary);
std::vector<byte> cvca_sv = cvca_cert.BER_encode();
- cvca_file.write((char*)&cvca_sv[0], cvca_sv.size());
+ cvca_file.write((char*)cvca_sv.data(), cvca_sv.size());
cvca_file.close();
ECDSA_PrivateKey cvca_privk2(rng, dom_pars);
@@ -479,7 +479,7 @@ void test_cvc_chain(RandomNumberGenerator& rng)
EAC1_1_CVC link12 = DE_EAC::link_cvca(cvca_cert, cvca_privk, cvca_cert2, rng);
std::vector<byte> link12_sv = link12.BER_encode();
std::ofstream link12_file(CVC_TEST_DATA_DIR "/cvc_chain_link12.cer", std::ios::binary);
- link12_file.write((char*)&link12_sv[0], link12_sv.size());
+ link12_file.write((char*)link12_sv.data(), link12_sv.size());
link12_file.close();
// verify the link
@@ -494,7 +494,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(CVC_TEST_DATA_DIR "/cvc_chain_dvca_req.cer", std::ios::binary);
std::vector<byte> dvca_sv = dvca_req.BER_encode();
- dvca_file.write((char*)&dvca_sv[0], dvca_sv.size());
+ dvca_file.write((char*)dvca_sv.data(), dvca_sv.size());
dvca_file.close();
// sign the dvca_request
@@ -508,7 +508,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(CVC_TEST_DATA_DIR "/cvc_chain_dvca_req2.cer", std::ios::binary);
std::vector<byte> dvca_sv2 = dvca_req2.BER_encode();
- dvca_file2.write((char*)&dvca_sv2[0], dvca_sv2.size());
+ dvca_file2.write((char*)dvca_sv2.data(), 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);