diff options
author | Jack Lloyd <[email protected]> | 2019-02-16 11:25:38 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-02-16 11:25:38 -0500 |
commit | b8199a7a4f8cff49a6c09ffc769494d48ae7f3fd (patch) | |
tree | 3fa352d2bdb512c1c64b7c4b194e23b2a8ba4603 /src/tests | |
parent | 60e00a8282cf509fb92005a8a5812ab90215899d (diff) |
Fixes for minimized builds
Various configurations would fail build or test, fix that.
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/test_c25519.cpp | 2 | ||||
-rw-r--r-- | src/tests/test_ecies.cpp | 2 | ||||
-rw-r--r-- | src/tests/test_ffi.cpp | 8 | ||||
-rw-r--r-- | src/tests/test_kdf.cpp | 9 | ||||
-rw-r--r-- | src/tests/test_pk_pad.cpp | 15 | ||||
-rw-r--r-- | src/tests/test_siv.cpp | 11 | ||||
-rw-r--r-- | src/tests/unit_tls.cpp | 6 |
7 files changed, 45 insertions, 8 deletions
diff --git a/src/tests/test_c25519.cpp b/src/tests/test_c25519.cpp index 88352f7ce..0b81b0aa5 100644 --- a/src/tests/test_c25519.cpp +++ b/src/tests/test_c25519.cpp @@ -83,7 +83,7 @@ class Curve25519_Roundtrip_Test final : public Test Botan::Curve25519_PrivateKey a_priv_gen(Test::rng()); Botan::Curve25519_PrivateKey b_priv_gen(Test::rng()); -#if defined(BOTAN_HAS_AES) && defined(BOTAN_HAS_AEAD_GCM) +#if defined(BOTAN_HAS_PKCS5_PBES2) && defined(BOTAN_HAS_AES) && defined(BOTAN_HAS_AEAD_GCM) // Then serialize to encrypted storage const std::string a_pass = "alice pass"; diff --git a/src/tests/test_ecies.cpp b/src/tests/test_ecies.cpp index 5c95e9a0c..5dd70afd7 100644 --- a/src/tests/test_ecies.cpp +++ b/src/tests/test_ecies.cpp @@ -237,7 +237,7 @@ class ECIES_Tests final : public Text_Based_Test BOTAN_REGISTER_TEST("ecies", ECIES_Tests); -#if defined(BOTAN_HAS_KDF1_18033) && defined(BOTAN_HAS_HMAC) && defined(BOTAN_HAS_AES) +#if defined(BOTAN_HAS_KDF1_18033) && defined(BOTAN_HAS_HMAC) && defined(BOTAN_HAS_AES) && defined(BOTAN_HAS_SHA2_64) Test::Result test_other_key_not_set() { diff --git a/src/tests/test_ffi.cpp b/src/tests/test_ffi.cpp index ce9dc94d5..2e59faec2 100644 --- a/src/tests/test_ffi.cpp +++ b/src/tests/test_ffi.cpp @@ -1511,9 +1511,15 @@ class FFI_Unit_Tests final : public Test const std::string pbe_hash = "SHA-512"; #endif +#if defined(BOTAN_HAS_GCM) + const std::string pbe_cipher = "AES-256/GCM"; +#else + const std::string pbe_cipher = "AES-256/CBC"; +#endif + TEST_FFI_OK(botan_privkey_export_encrypted_pbkdf_msec, (priv, privkey.data(), &privkey_len, rng, "password", - pbkdf_msec, &pbkdf_iters_out, "AES-256/GCM", pbe_hash.c_str(), 0)); + pbkdf_msec, &pbkdf_iters_out, pbe_cipher.c_str(), pbe_hash.c_str(), 0)); if(pbe_hash == "Scrypt") { diff --git a/src/tests/test_kdf.cpp b/src/tests/test_kdf.cpp index 24211a32d..865a713d0 100644 --- a/src/tests/test_kdf.cpp +++ b/src/tests/test_kdf.cpp @@ -12,6 +12,7 @@ #if defined(BOTAN_HAS_HKDF) #include <botan/hkdf.h> + #include <botan/hash.h> #endif namespace Botan_Tests { @@ -74,6 +75,14 @@ class HKDF_Expand_Label_Tests final : public Text_Based_Test const std::string label = vars.get_req_str("Label"); const std::vector<uint8_t> expected = vars.get_req_bin("Output"); + auto hash = Botan::HashFunction::create(hash_name); + + if(!hash) + { + result.test_note("Skipping test due to missing hash"); + return result; + } + Botan::secure_vector<uint8_t> output = Botan::hkdf_expand_label(hash_name, secret.data(), secret.size(), diff --git a/src/tests/test_pk_pad.cpp b/src/tests/test_pk_pad.cpp index 5d56acbc8..7c92cf876 100644 --- a/src/tests/test_pk_pad.cpp +++ b/src/tests/test_pk_pad.cpp @@ -115,12 +115,17 @@ class EMSA_unit_tests final : public Test { try { + const std::string hash_to_use = Botan::hash_for_emsa(pad); std::unique_ptr<Botan::EMSA> emsa_1( - Botan::get_emsa(pad + "(" + Botan::hash_for_emsa(pad) + ")")); + Botan::get_emsa(pad + "(" + hash_to_use + ")")); std::unique_ptr<Botan::EMSA> emsa_2(Botan::get_emsa(emsa_1->name())); name_tests.test_eq("EMSA_name_test for " + pad, emsa_1->name(), emsa_2->name()); } + catch(Botan::Lookup_Error&) + { + name_tests.test_note("Skipping test due to missing hash"); + } catch(const std::exception& e) { name_tests.test_failure("EMSA_name_test for " + pad + ": " + e.what()); @@ -137,6 +142,10 @@ class EMSA_unit_tests final : public Test name_tests.test_failure("EMSA_name_test for " + pad + ": " + "Could create EMSA with fantasy hash YYZ"); } + catch(Botan::Lookup_Error&) + { + name_tests.test_note("Skipping test due to missing hash"); + } catch(const std::exception& e) { name_tests.test_eq("EMSA_name_test for " + pad, @@ -154,6 +163,10 @@ class EMSA_unit_tests final : public Test name_tests.test_eq("EMSA_name_test for " + pad, emsa_1->name(), emsa_2->name()); } + catch(Botan::Lookup_Error&) + { + name_tests.test_note("Skipping test due to missing hash"); + } catch(const std::exception& e) { name_tests.test_failure("EMSA_name_test for " + pad + ": " + e.what()); diff --git a/src/tests/test_siv.cpp b/src/tests/test_siv.cpp index d7380a9ba..9810a68a5 100644 --- a/src/tests/test_siv.cpp +++ b/src/tests/test_siv.cpp @@ -34,8 +34,15 @@ class SIV_Tests final : public Text_Based_Test Test::Result result(algo + "/SIV"); - std::unique_ptr<Botan::SIV_Mode> siv( - new Botan::SIV_Encryption(Botan::BlockCipher::create(algo).release())); + auto cipher = Botan::BlockCipher::create(algo); + + if(!cipher) + { + result.test_note("Skipping test due to missing cipher"); + return result; + } + + std::unique_ptr<Botan::SIV_Mode> siv(new Botan::SIV_Encryption(cipher.release())); siv->set_key(key); diff --git a/src/tests/unit_tls.cpp b/src/tests/unit_tls.cpp index e50f21aba..28b09324f 100644 --- a/src/tests/unit_tls.cpp +++ b/src/tests/unit_tls.cpp @@ -847,7 +847,7 @@ class TLS_Unit_Tests final : public Test test_all_versions("AES-128 RSA", results, *client_ses, *server_ses, *creds, "RSA", "AES-128", "SHA-256 SHA-1", etm_setting); test_all_versions("AES-128 ECDH", results, *client_ses, *server_ses, *creds, "ECDH", "AES-128", "SHA-256 SHA-1", etm_setting); -#if defined(BOTAN_HAS_CAMELLIA) +#if defined(BOTAN_HAS_CAMELLIA) && defined(BOTAN_HAS_TLS_CBC) test_all_versions("Camellia-128 RSA", results, *client_ses, *server_ses, *creds, "RSA", "Camellia-128", "SHA-256 SHA-1", etm_setting); test_all_versions("Camellia-256 RSA SHA-2", results, *client_ses, *server_ses, @@ -903,8 +903,10 @@ class TLS_Unit_Tests final : public Test client_ses->remove_all(); -#if defined(BOTAN_HAS_CAMELLIA) +#if defined(BOTAN_HAS_CAMELLIA) && defined(BOTAN_HAS_TLS_CBC) test_modern_versions("Camellia-256 SHA-2", results, *client_ses, *server_ses, *creds, "RSA", "Camellia-256", "SHA-384 SHA-256"); +#endif +#if defined(BOTAN_HAS_CAMELLIA) && defined(BOTAN_HAS_GCM) test_modern_versions("Camellia-128/GCM ECDH", results, *client_ses, *server_ses, *creds, "ECDH", "Camellia-128/GCM", "AEAD"); #endif |