aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/unit_ecdsa.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/unit_ecdsa.cpp')
-rw-r--r--src/tests/unit_ecdsa.cpp28
1 files changed, 14 insertions, 14 deletions
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");