aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tests/test_cvc.cpp66
-rw-r--r--src/tests/test_fuzzer.cpp4
-rw-r--r--src/tests/tests.cpp17
-rw-r--r--src/tests/tests.h33
-rw-r--r--src/tests/unit_ecdsa.cpp28
5 files changed, 88 insertions, 60 deletions
diff --git a/src/tests/test_cvc.cpp b/src/tests/test_cvc.cpp
index 74b91d0ed..dc4b50ebd 100644
--- a/src/tests/test_cvc.cpp
+++ b/src/tests/test_cvc.cpp
@@ -19,8 +19,6 @@
#include <botan/cvc_cert.h>
#include <botan/cvc_ado.h>
-#define CVC_TEST_DATA_DIR TEST_DATA_DIR "/ecc"
-
#endif
namespace Botan_Tests {
@@ -124,22 +122,22 @@ Test::Result test_enc_gen_selfsigned()
std::vector<byte> der(cert.BER_encode());
std::ofstream cert_file;
- cert_file.open(CVC_TEST_DATA_DIR "/my_cv_cert.ber", std::ios::binary);
+ cert_file.open(Test::data_file("ecc/my_cv_cert.ber"), std::ios::binary);
cert_file.write((char*)der.data(), der.size());
cert_file.close();
- EAC1_1_CVC cert_in(CVC_TEST_DATA_DIR "/my_cv_cert.ber");
+ EAC1_1_CVC cert_in(Test::data_file("ecc/my_cv_cert.ber"));
result.confirm("reloaded cert matches", cert_in == cert);
// 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);
+ std::ofstream cert_file2(Test::data_file("ecc/my_cv_cert2.ber"), std::ios::binary);
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");
- std::ifstream cert_2_in(CVC_TEST_DATA_DIR "/my_cv_cert2.ber");
+ std::ifstream cert_1_in(Test::data_file("ecc/my_cv_cert.ber"));
+ std::ifstream cert_2_in(Test::data_file("ecc/my_cv_cert2.ber"));
std::vector<byte> sv1;
std::vector<byte> sv2;
if (!cert_1_in || cert_2_in)
@@ -225,12 +223,12 @@ Test::Result test_enc_gen_req()
key.set_parameter_encoding(EC_DOMPAR_ENC_IMPLICITCA);
EAC1_1_Req req = CVC_EAC::create_cvc_req(key, opts.chr, opts.hash_alg, Test::rng());
std::vector<byte> der(req.BER_encode());
- std::ofstream req_file(CVC_TEST_DATA_DIR "/my_cv_req.ber", std::ios::binary);
+ std::ofstream req_file(Test::data_file("ecc/my_cv_req.ber"), std::ios::binary);
req_file.write((char*)der.data(), der.size());
req_file.close();
// read and check signature...
- EAC1_1_Req req_in(CVC_TEST_DATA_DIR "/my_cv_req.ber");
+ EAC1_1_Req req_in(Test::data_file("ecc/my_cv_req.ber"));
//req_in.set_domain_parameters(dom_pars);
std::unique_ptr<Public_Key> p_pk(req_in.subject_public_key());
ECDSA_PublicKey* p_ecdsa_pk = dynamic_cast<ECDSA_PublicKey*>(p_pk.get());
@@ -243,7 +241,7 @@ Test::Result test_enc_gen_req()
Test::Result test_cvc_req_ext()
{
- EAC1_1_Req req_in(CVC_TEST_DATA_DIR "/DE1_flen_chars_cvcRequest_ECDSA.der");
+ EAC1_1_Req req_in(Test::data_file("ecc/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::unique_ptr<Public_Key> p_pk(req_in.subject_public_key());
@@ -271,7 +269,7 @@ Test::Result test_cvc_ado_creation()
//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, Test::rng());
std::vector<byte> der(req.BER_encode());
- std::ofstream req_file(CVC_TEST_DATA_DIR "/my_cv_req.ber", std::ios::binary);
+ std::ofstream req_file(Test::data_file("ecc/my_cv_req.ber"), std::ios::binary);
req_file.write((char*)der.data(), der.size());
req_file.close();
@@ -285,12 +283,12 @@ Test::Result test_cvc_ado_creation()
EAC1_1_ADO ado = CVC_EAC::create_ado_req(ado_key, req, ado_opts.car, Test::rng());
result.confirm("ADO signature verifies", ado.check_signature(ado_key));
- std::ofstream ado_file(CVC_TEST_DATA_DIR "/ado", std::ios::binary);
+ std::ofstream ado_file(Test::data_file("ecc/ado"), std::ios::binary);
std::vector<byte> ado_der(ado.BER_encode());
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");
+ EAC1_1_ADO ado2(Test::data_file("ecc/ado"));
result.confirm("ADOs match", ado == ado2);
result.confirm("ADO signature valid", ado2.check_signature(ado_key));
@@ -341,13 +339,13 @@ Test::Result test_cvc_ado_comparison()
result.confirm("ADO signature after creation", ado2.check_signature(ado_key2));
result.confirm("ADOs should not be equal", ado != ado2);
- // std::ofstream ado_file(CVC_TEST_DATA_DIR "/ado");
+ // std::ofstream ado_file(Test::data_file("ecc/ado"));
// std::vector<byte> ado_der(ado.BER_encode());
// 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");
+ // EAC1_1_ADO ado2(Test::data_file("ecc/ado"));
// ECDSA_PublicKey* p_ado_pk = dynamic_cast<ECDSA_PublicKey*>(&ado_key);
// //bool ver = ado2.check_signature(*p_ado_pk);
// bool ver = ado2.check_signature(ado_key);
@@ -396,7 +394,7 @@ Test::Result test_ver_cvca()
{
Test::Result result("CVC");
- EAC1_1_CVC cvc(CVC_TEST_DATA_DIR "/cvca01.cv.crt");
+ EAC1_1_CVC cvc(Test::data_file("ecc/cvca01.cv.crt"));
std::unique_ptr<Public_Key> p_pk2(cvc.subject_public_key());
result.confirm("verified CVCA cert", cvc.check_signature(*p_pk2));
@@ -419,20 +417,20 @@ Test::Result test_copy_and_assignment()
{
Test::Result result("CVC");
- EAC1_1_CVC cert_in(CVC_TEST_DATA_DIR "/cvca01.cv.crt");
+ EAC1_1_CVC cert_in(Test::data_file("ecc/cvca01.cv.crt"));
EAC1_1_CVC cert_cp(cert_in);
EAC1_1_CVC cert_ass = cert_in;
result.confirm("same cert", cert_in == cert_cp);
result.confirm("same cert", cert_in == cert_ass);
- EAC1_1_ADO ado_in(CVC_TEST_DATA_DIR "/ado.cvcreq");
+ EAC1_1_ADO ado_in(Test::data_file("ecc/ado.cvcreq"));
EAC1_1_ADO ado_cp(ado_in);
EAC1_1_ADO ado_ass = ado_in;
result.confirm("same", ado_in == ado_cp);
result.confirm("same", ado_in == ado_ass);
- EAC1_1_Req req_in(CVC_TEST_DATA_DIR "/DE1_flen_chars_cvcRequest_ECDSA.der");
+ EAC1_1_Req req_in(Test::data_file("ecc/DE1_flen_chars_cvcRequest_ECDSA.der"));
EAC1_1_Req req_cp(req_in);
EAC1_1_Req req_ass = req_in;
result.confirm("same", req_in == req_cp);
@@ -447,14 +445,14 @@ Test::Result test_eac_str_illegal_values()
try
{
- EAC1_1_CVC(CVC_TEST_DATA_DIR "/cvca_illegal_chars.cv.crt");
+ EAC1_1_CVC(Test::data_file("ecc/cvca_illegal_chars.cv.crt"));
result.test_failure("Accepted invalid EAC 1.1 CVC");
}
catch (Decoding_Error) {}
try
{
- EAC1_1_CVC(CVC_TEST_DATA_DIR "/cvca_illegal_chars2.cv.crt");
+ EAC1_1_CVC(Test::data_file("ecc/cvca_illegal_chars2.cv.crt"));
result.test_failure("Accepted invalid EAC 1.1 CVC #2");
}
catch (Decoding_Error) {}
@@ -484,7 +482,7 @@ Test::Result test_cvc_chain()
std::string hash("SHA-224");
ASN1_Car car("DECVCA00001");
EAC1_1_CVC cvca_cert = DE_EAC::create_cvca(cvca_privk, hash, car, true, true, 12, Test::rng());
- std::ofstream cvca_file(CVC_TEST_DATA_DIR "/cvc_chain_cvca.cer", std::ios::binary);
+ std::ofstream cvca_file(Test::data_file("ecc/cvc_chain_cvca.cer"), std::ios::binary);
std::vector<byte> cvca_sv = cvca_cert.BER_encode();
cvca_file.write((char*)cvca_sv.data(), cvca_sv.size());
cvca_file.close();
@@ -494,21 +492,21 @@ Test::Result test_cvc_chain()
EAC1_1_CVC cvca_cert2 = DE_EAC::create_cvca(cvca_privk2, hash, car2, true, true, 12, Test::rng());
EAC1_1_CVC link12 = DE_EAC::link_cvca(cvca_cert, cvca_privk, cvca_cert2, Test::rng());
std::vector<byte> link12_sv = link12.BER_encode();
- std::ofstream link12_file(CVC_TEST_DATA_DIR "/cvc_chain_link12.cer", std::ios::binary);
+ std::ofstream link12_file(Test::data_file("ecc/cvc_chain_link12.cer"), std::ios::binary);
link12_file.write((char*)link12_sv.data(), link12_sv.size());
link12_file.close();
// verify the link
result.confirm("signature valid", link12.check_signature(cvca_privk));
- EAC1_1_CVC link12_reloaded(CVC_TEST_DATA_DIR "/cvc_chain_link12.cer");
- EAC1_1_CVC cvca1_reloaded(CVC_TEST_DATA_DIR "/cvc_chain_cvca.cer");
+ EAC1_1_CVC link12_reloaded(Test::data_file("ecc/cvc_chain_link12.cer"));
+ EAC1_1_CVC cvca1_reloaded(Test::data_file("ecc/cvc_chain_cvca.cer"));
std::unique_ptr<Public_Key> cvca1_rel_pk(cvca1_reloaded.subject_public_key());
result.confirm("signature valid", link12_reloaded.check_signature(*cvca1_rel_pk));
// create first round dvca-req
ECDSA_PrivateKey dvca_priv_key(Test::rng(), dom_pars);
EAC1_1_Req dvca_req = DE_EAC::create_cvc_req(dvca_priv_key, ASN1_Chr("DEDVCAEPASS"), hash, Test::rng());
- std::ofstream dvca_file(CVC_TEST_DATA_DIR "/cvc_chain_dvca_req.cer", std::ios::binary);
+ std::ofstream dvca_file(Test::data_file("ecc/cvc_chain_dvca_req.cer"), std::ios::binary);
std::vector<byte> dvca_sv = dvca_req.BER_encode();
dvca_file.write((char*)dvca_sv.data(), dvca_sv.size());
dvca_file.close();
@@ -517,18 +515,18 @@ Test::Result test_cvc_chain()
EAC1_1_CVC dvca_cert1 = DE_EAC::sign_request(cvca_cert, cvca_privk, dvca_req, 1, 5, true, 3, 1, Test::rng());
result.test_eq("DVCA car", dvca_cert1.get_car().iso_8859(), "DECVCA00001");
result.test_eq("DVCA chr", dvca_cert1.get_chr().iso_8859(), "DEDVCAEPASS00001");
- helper_write_file(dvca_cert1, CVC_TEST_DATA_DIR "/cvc_chain_dvca_cert1.cer");
+ helper_write_file(dvca_cert1, Test::data_file("ecc/cvc_chain_dvca_cert1.cer"));
// make a second round dvca ado request
ECDSA_PrivateKey dvca_priv_key2(Test::rng(), dom_pars);
EAC1_1_Req dvca_req2 = DE_EAC::create_cvc_req(dvca_priv_key2, ASN1_Chr("DEDVCAEPASS"), hash, Test::rng());
- std::ofstream dvca_file2(CVC_TEST_DATA_DIR "/cvc_chain_dvca_req2.cer", std::ios::binary);
+ std::ofstream dvca_file2(Test::data_file("ecc/cvc_chain_dvca_req2.cer"), std::ios::binary);
std::vector<byte> dvca_sv2 = dvca_req2.BER_encode();
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()), Test::rng());
- helper_write_file(dvca_ado2, CVC_TEST_DATA_DIR "/cvc_chain_dvca_ado2.cer");
+ helper_write_file(dvca_ado2, Test::data_file("ecc/cvc_chain_dvca_ado2.cer"));
// verify the ado and sign the request too
@@ -536,13 +534,13 @@ Test::Result test_cvc_chain()
ECDSA_PublicKey* cert_pk = dynamic_cast<ECDSA_PublicKey*>(ap_pk.get());
//cert_pk->set_domain_parameters(dom_pars);
- EAC1_1_CVC dvca_cert1_reread(CVC_TEST_DATA_DIR "/cvc_chain_cvca.cer");
+ EAC1_1_CVC dvca_cert1_reread(Test::data_file("ecc/cvc_chain_cvca.cer"));
result.confirm("signature valid", dvca_ado2.check_signature(*cert_pk));
result.confirm("signature valid", dvca_ado2.check_signature(dvca_priv_key)); // must also work
EAC1_1_Req dvca_req2b = dvca_ado2.get_request();
- helper_write_file(dvca_req2b, CVC_TEST_DATA_DIR "/cvc_chain_dvca_req2b.cer");
- result.confirm("files match", helper_files_equal(CVC_TEST_DATA_DIR "/cvc_chain_dvca_req2b.cer", CVC_TEST_DATA_DIR "/cvc_chain_dvca_req2.cer"));
+ helper_write_file(dvca_req2b, Test::data_file("ecc/cvc_chain_dvca_req2b.cer"));
+ result.confirm("files match", helper_files_equal(Test::data_file("ecc/cvc_chain_dvca_req2b.cer"), Test::data_file("ecc/cvc_chain_dvca_req2.cer")));
EAC1_1_CVC dvca_cert2 = DE_EAC::sign_request(cvca_cert, cvca_privk, dvca_req2b, 2, 5, true, 3, 1, Test::rng());
result.test_eq("DVCA car", dvca_cert2.get_car().iso_8859(), "DECVCA00001");
result.test_eq("DVCA chr", dvca_cert2.get_chr().iso_8859(), "DEDVCAEPASS00002");
@@ -550,14 +548,14 @@ Test::Result test_cvc_chain()
// make a first round IS request
ECDSA_PrivateKey is_priv_key(Test::rng(), dom_pars);
EAC1_1_Req is_req = DE_EAC::create_cvc_req(is_priv_key, ASN1_Chr("DEIS"), hash, Test::rng());
- helper_write_file(is_req, CVC_TEST_DATA_DIR "/cvc_chain_is_req.cer");
+ helper_write_file(is_req, Test::data_file("ecc/cvc_chain_is_req.cer"));
// sign the IS request
//dvca_cert1.set_domain_parameters(dom_pars);
EAC1_1_CVC is_cert1 = DE_EAC::sign_request(dvca_cert1, dvca_priv_key, is_req, 1, 5, true, 3, 1, Test::rng());
result.test_eq("EAC 1.1 CVC car", is_cert1.get_car().iso_8859(), "DEDVCAEPASS00001");
result.test_eq("EAC 1.1 CVC chr", is_cert1.get_chr().iso_8859(), "DEIS00001");
- helper_write_file(is_cert1, CVC_TEST_DATA_DIR "/cvc_chain_is_cert.cer");
+ helper_write_file(is_cert1, Test::data_file("ecc/cvc_chain_is_cert.cer"));
// verify the signature of the certificate
result.confirm("valid signature", is_cert1.check_signature(dvca_priv_key));
diff --git a/src/tests/test_fuzzer.cpp b/src/tests/test_fuzzer.cpp
index 7ce972a33..91d301826 100644
--- a/src/tests/test_fuzzer.cpp
+++ b/src/tests/test_fuzzer.cpp
@@ -35,15 +35,13 @@ class Fuzzer_Input_Tests : public Test
#if defined(BOTAN_HAS_X509_CERTIFICATES)
Test::Result test_x509_fuzz()
{
- const std::string TEST_DATA_DIR_FUZZ_X509 = TEST_DATA_DIR "/fuzz/x509";
-
Test::Result result("X.509 fuzzing");
std::vector<std::string> files;
try
{
- files = Botan::get_files_recursive(TEST_DATA_DIR_FUZZ_X509);
+ files = Botan::get_files_recursive(Test::data_dir("fuzz/x509"));
}
catch(Botan::No_Filesystem_Access)
{
diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp
index 294ef303b..e421d245c 100644
--- a/src/tests/tests.cpp
+++ b/src/tests/tests.cpp
@@ -14,6 +14,9 @@
namespace Botan_Tests {
+#define TEST_DATA_DIR "src/tests/data"
+#define TEST_OUTDATA_DIR "src/tests/outdata"
+
Test::Registration::Registration(const std::string& name, Test* test)
{
if(Test::global_registry().count(name) == 0)
@@ -54,11 +57,15 @@ void Test::Result::end_timer()
}
}
-void Test::Result::test_note(const std::string& note)
+void Test::Result::test_note(const std::string& note, const char* extra)
{
if(note != "")
{
- m_log.push_back(who() + " " + note);
+ std::ostringstream out;
+ out << who() << " " << note;
+ if(extra)
+ out << ": " << extra;
+ m_log.push_back(out.str());
}
}
@@ -445,6 +452,12 @@ std::string Test::data_file(const std::string& what)
return std::string(TEST_DATA_DIR) + "/" + what;
}
+//static
+std::string Test::full_path_for_output_file(const std::string& base)
+ {
+ return std::string(TEST_OUTDATA_DIR) + "/" + base;
+ }
+
// static member variables of Test
Botan::RandomNumberGenerator* Test::m_test_rng = nullptr;
size_t Test::m_soak_level = 0;
diff --git a/src/tests/tests.h b/src/tests/tests.h
index 273035cbf..9f511c4fb 100644
--- a/src/tests/tests.h
+++ b/src/tests/tests.h
@@ -82,9 +82,31 @@ class Test
return r;
}
+ static Result OfExpectedFailure(bool expecting_failure,
+ const Test::Result& result)
+ {
+ if(!expecting_failure)
+ {
+ return result;
+ }
+
+ if(result.tests_failed() == 0)
+ {
+ Result r = result;
+ r.test_failure("Expected this test to fail, but it did not");
+ return r;
+ }
+ else
+ {
+ Result r(result.who());
+ r.test_note("Got expected failure " + result.result_string());
+ return r;
+ }
+ }
+
void merge(const Result& other);
- void test_note(const std::string& note);
+ void test_note(const std::string& note, const char* extra = nullptr);
void note_missing(const std::string& thing);
@@ -119,7 +141,9 @@ class Test
std::ostringstream out;
out << m_who;
if(what)
+ {
out << " " << what;
+ }
if(produced == expected)
{
@@ -237,6 +261,7 @@ class Test
static std::string data_dir(const std::string& what);
static std::string data_file(const std::string& what);
+ static std::string full_path_for_output_file(const std::string& base);
template<typename Alloc>
static std::vector<uint8_t, Alloc> mutate_vec(const std::vector<uint8_t, Alloc>& v, bool maybe_resize = false)
@@ -350,10 +375,4 @@ class Text_Based_Test : public Test
}
-#define TEST_DATA_DIR "src/tests/data"
-#define TEST_DATA_DIR_PK "src/tests/data/pubkey"
-#define TEST_DATA_DIR_ECC "src/tests/data/ecc"
-
-#define TEST_OUTDATA_DIR "src/tests/outdata"
-
#endif
diff --git a/src/tests/unit_ecdsa.cpp b/src/tests/unit_ecdsa.cpp
index f47d0ae71..ed9096083 100644
--- a/src/tests/unit_ecdsa.cpp
+++ b/src/tests/unit_ecdsa.cpp
@@ -90,7 +90,7 @@ Test::Result test_hash_larger_than_n()
Test::Result test_decode_ecdsa_X509()
{
Test::Result result("ECDSA Unit");
- Botan::X509_Certificate cert(TEST_DATA_DIR_ECC "/CSCA.CSCA.csca-germany.1.crt");
+ Botan::X509_Certificate cert(Test::data_file("ecc/CSCA.CSCA.csca-germany.1.crt"));
result.test_eq("correct signature oid", Botan::OIDS::lookup(cert.signature_algorithm().oid), "ECDSA/EMSA1(SHA-224)");
@@ -107,8 +107,8 @@ Test::Result test_decode_ecdsa_X509()
Test::Result test_decode_ver_link_SHA256()
{
Test::Result result("ECDSA Unit");
- Botan::X509_Certificate root_cert(TEST_DATA_DIR_ECC "/root2_SHA256.cer");
- Botan::X509_Certificate link_cert(TEST_DATA_DIR_ECC "/link_SHA256.cer");
+ Botan::X509_Certificate root_cert(Test::data_file("ecc/root2_SHA256.cer"));
+ Botan::X509_Certificate link_cert(Test::data_file("ecc/link_SHA256.cer"));
std::unique_ptr<Botan::Public_Key> pubkey(root_cert.subject_public_key());
result.confirm("verified self-signed signature", link_cert.check_signature(*pubkey));
@@ -117,8 +117,8 @@ Test::Result test_decode_ver_link_SHA256()
Test::Result test_decode_ver_link_SHA1()
{
- Botan::X509_Certificate root_cert(TEST_DATA_DIR_ECC "/root_SHA1.163.crt");
- Botan::X509_Certificate link_cert(TEST_DATA_DIR_ECC "/link_SHA1.166.crt");
+ Botan::X509_Certificate root_cert(Test::data_file("ecc/root_SHA1.163.crt"));
+ Botan::X509_Certificate link_cert(Test::data_file("ecc/link_SHA1.166.crt"));
Test::Result result("ECDSA Unit");
std::unique_ptr<Botan::Public_Key> pubkey(root_cert.subject_public_key());
@@ -206,7 +206,7 @@ Test::Result test_create_pkcs8()
#if defined(BOTAN_HAS_RSA)
Botan::RSA_PrivateKey rsa_key(Test::rng(), 1024);
- std::ofstream rsa_priv_key(TEST_OUTDATA_DIR "/rsa_private.pkcs8.pem");
+ std::ofstream rsa_priv_key(Test::full_path_for_output_file("rsa_private.pkcs8.pem"));
rsa_priv_key << Botan::PKCS8::PEM_encode(rsa_key);
#endif
@@ -214,7 +214,7 @@ Test::Result test_create_pkcs8()
Botan::ECDSA_PrivateKey key(Test::rng(), dom_pars);
// later used by other tests :(
- std::ofstream priv_key(TEST_OUTDATA_DIR "/wo_dompar_private.pkcs8.pem");
+ std::ofstream priv_key(Test::full_path_for_output_file("wo_dompar_private.pkcs8.pem"));
priv_key << Botan::PKCS8::PEM_encode(key);
}
catch (std::exception& e)
@@ -231,15 +231,15 @@ Test::Result test_create_and_verify()
Botan::EC_Group dom_pars(Botan::OID("1.3.132.0.8"));
Botan::ECDSA_PrivateKey key(Test::rng(), dom_pars);
- std::ofstream priv_key(TEST_OUTDATA_DIR "/dompar_private.pkcs8.pem");
+ std::ofstream priv_key(Test::full_path_for_output_file("dompar_private.pkcs8.pem"));
priv_key << Botan::PKCS8::PEM_encode(key);
- std::unique_ptr<Botan::Private_Key> loaded_key(Botan::PKCS8::load_key(TEST_OUTDATA_DIR "/wo_dompar_private.pkcs8.pem", Test::rng()));
+ std::unique_ptr<Botan::Private_Key> loaded_key(Botan::PKCS8::load_key(Test::full_path_for_output_file("wo_dompar_private.pkcs8.pem"), Test::rng()));
Botan::ECDSA_PrivateKey* loaded_ec_key = dynamic_cast<Botan::ECDSA_PrivateKey*>(loaded_key.get());
result.confirm("the loaded key could not be converted into an ECDSA_PrivateKey", loaded_ec_key);
#if defined(BOTAN_HAS_RSA)
- std::unique_ptr<Botan::Private_Key> loaded_key_1(Botan::PKCS8::load_key(TEST_OUTDATA_DIR "/rsa_private.pkcs8.pem", Test::rng()));
+ std::unique_ptr<Botan::Private_Key> loaded_key_1(Botan::PKCS8::load_key(Test::full_path_for_output_file("rsa_private.pkcs8.pem"), Test::rng()));
Botan::ECDSA_PrivateKey* loaded_rsa_key = dynamic_cast<Botan::ECDSA_PrivateKey*>(loaded_key_1.get());
result.test_eq("loaded key type corrected", loaded_key_1->algo_name(), "RSA");
result.confirm("RSA key cannot be casted to ECDSA", !loaded_rsa_key);
@@ -336,7 +336,7 @@ Test::Result test_read_pkcs8()
try
{
- std::unique_ptr<Botan::Private_Key> loaded_key(Botan::PKCS8::load_key(TEST_OUTDATA_DIR "/wo_dompar_private.pkcs8.pem", Test::rng()));
+ std::unique_ptr<Botan::Private_Key> loaded_key(Botan::PKCS8::load_key(Test::full_path_for_output_file("wo_dompar_private.pkcs8.pem"), Test::rng()));
Botan::ECDSA_PrivateKey* ecdsa = dynamic_cast<Botan::ECDSA_PrivateKey*>(loaded_key.get());
result.confirm("key loaded", ecdsa);
@@ -355,7 +355,7 @@ Test::Result test_read_pkcs8()
try
{
- std::unique_ptr<Botan::Private_Key> loaded_key_nodp(Botan::PKCS8::load_key(TEST_DATA_DIR_ECC "/nodompar_private.pkcs8.pem", Test::rng()));
+ std::unique_ptr<Botan::Private_Key> loaded_key_nodp(Botan::PKCS8::load_key(Test::data_file("ecc/nodompar_private.pkcs8.pem"), Test::rng()));
// anew in each test with unregistered domain-parameters
Botan::ECDSA_PrivateKey* ecdsa_nodp = dynamic_cast<Botan::ECDSA_PrivateKey*>(loaded_key_nodp.get());
result.confirm("key loaded", ecdsa_nodp);
@@ -370,7 +370,7 @@ Test::Result test_read_pkcs8()
try
{
std::unique_ptr<Botan::Private_Key> loaded_key_withdp(
- Botan::PKCS8::load_key(TEST_DATA_DIR_ECC "/withdompar_private.pkcs8.pem", Test::rng()));
+ Botan::PKCS8::load_key(Test::data_file("ecc/withdompar_private.pkcs8.pem"), Test::rng()));
result.test_failure("loaded key with unknown OID");
}
@@ -394,7 +394,7 @@ Test::Result test_ecc_key_with_rfc5915_extensions()
try
{
std::unique_ptr<Botan::Private_Key> pkcs8(
- Botan::PKCS8::load_key(TEST_DATA_DIR_ECC "/ecc_private_with_rfc5915_ext.pem", Test::rng()));
+ Botan::PKCS8::load_key(Test::data_file("ecc/ecc_private_with_rfc5915_ext.pem"), Test::rng()));
result.confirm("loaded RFC 5914 key", pkcs8.get());
result.test_eq("key is ECDSA", pkcs8->algo_name(), "ECDSA");