diff options
-rw-r--r-- | src/tests/test_block.cpp | 7 | ||||
-rw-r--r-- | src/tests/test_hash.cpp | 7 | ||||
-rw-r--r-- | src/tests/test_mac.cpp | 7 | ||||
-rw-r--r-- | src/tests/test_pubkey.cpp | 28 | ||||
-rw-r--r-- | src/tests/test_pubkey.h | 3 | ||||
-rw-r--r-- | src/tests/test_stream.cpp | 3 | ||||
-rw-r--r-- | src/tests/tests.cpp | 13 | ||||
-rw-r--r-- | src/tests/tests.h | 2 |
8 files changed, 48 insertions, 22 deletions
diff --git a/src/tests/test_block.cpp b/src/tests/test_block.cpp index 20d887794..62f32c21c 100644 --- a/src/tests/test_block.cpp +++ b/src/tests/test_block.cpp @@ -14,6 +14,11 @@ class Block_Cipher_Tests : public Text_Based_Test public: Block_Cipher_Tests() : Text_Based_Test("block", "Key,In,Out") {} + std::vector<std::string> possible_providers(const std::string& algo) override + { + return provider_filter(Botan::BlockCipher::providers(algo)); + } + Test::Result run_one_test(const std::string& algo, const VarMap& vars) override { const std::vector<uint8_t> key = get_req_bin(vars, "Key"); @@ -22,7 +27,7 @@ class Block_Cipher_Tests : public Text_Based_Test Test::Result result(algo); - const std::vector<std::string> providers = Botan::BlockCipher::providers(algo); + const std::vector<std::string> providers = possible_providers(algo); if(providers.empty()) { diff --git a/src/tests/test_hash.cpp b/src/tests/test_hash.cpp index fd255131b..6584a20d1 100644 --- a/src/tests/test_hash.cpp +++ b/src/tests/test_hash.cpp @@ -17,6 +17,11 @@ class Hash_Function_Tests : public Text_Based_Test public: Hash_Function_Tests() : Text_Based_Test("hash", "In,Out") {} + std::vector<std::string> possible_providers(const std::string& algo) override + { + return provider_filter(Botan::HashFunction::providers(algo)); + } + Test::Result run_one_test(const std::string& algo, const VarMap& vars) override { const std::vector<uint8_t> input = get_req_bin(vars, "In"); @@ -24,7 +29,7 @@ class Hash_Function_Tests : public Text_Based_Test Test::Result result(algo); - const std::vector<std::string> providers = Botan::HashFunction::providers(algo); + const std::vector<std::string> providers = possible_providers(algo); if(providers.empty()) { diff --git a/src/tests/test_mac.cpp b/src/tests/test_mac.cpp index 8fb3b38c2..2e12ee6ed 100644 --- a/src/tests/test_mac.cpp +++ b/src/tests/test_mac.cpp @@ -22,6 +22,11 @@ class Message_Auth_Tests : public Text_Based_Test public: Message_Auth_Tests() : Text_Based_Test("mac", "Key,In,Out", "IV") {} + std::vector<std::string> possible_providers(const std::string& algo) override + { + return provider_filter(Botan::MessageAuthenticationCode::providers(algo)); + } + Test::Result run_one_test(const std::string& algo, const VarMap& vars) override { const std::vector<uint8_t> key = get_req_bin(vars, "Key"); @@ -31,7 +36,7 @@ class Message_Auth_Tests : public Text_Based_Test Test::Result result(algo); - const std::vector<std::string> providers = Botan::MessageAuthenticationCode::providers(algo); + const std::vector<std::string> providers = possible_providers(algo); if(providers.empty()) { diff --git a/src/tests/test_pubkey.cpp b/src/tests/test_pubkey.cpp index 9a8c5d2e7..d392437c9 100644 --- a/src/tests/test_pubkey.cpp +++ b/src/tests/test_pubkey.cpp @@ -19,15 +19,6 @@ namespace Botan_Tests { -namespace { - -std::vector<std::string> possible_pk_providers() - { - return { "base", "openssl", "tpm" }; - } - -} - void check_invalid_signatures(Test::Result& result, Botan::PK_Verifier& verifier, const std::vector<uint8_t>& message, @@ -91,6 +82,11 @@ void check_invalid_ciphertexts(Test::Result& result, " invalid ciphertexts, rejected " + std::to_string(ciphertext_rejected)); } +std::vector<std::string> PK_Test::possible_providers(const std::string&) + { + return Test::provider_filter({ "base", "openssl", "tpm" }); + } + Test::Result PK_Signature_Generation_Test::run_one_test(const std::string&, const VarMap& vars) { @@ -115,7 +111,7 @@ PK_Signature_Generation_Test::run_one_test(const std::string&, const VarMap& var std::vector<std::unique_ptr<Botan::PK_Verifier>> verifiers; - for(std::string verify_provider : possible_pk_providers()) + for(std::string verify_provider : possible_providers(algo_name())) { std::unique_ptr<Botan::PK_Verifier> verifier; @@ -135,7 +131,7 @@ PK_Signature_Generation_Test::run_one_test(const std::string&, const VarMap& var verifiers.push_back(std::move(verifier)); } - for(auto&& sign_provider : possible_pk_providers()) + for(auto&& sign_provider : possible_providers(algo_name())) { std::unique_ptr<Botan::RandomNumberGenerator> rng; if(vars.count("Nonce")) @@ -189,7 +185,7 @@ PK_Signature_Verification_Test::run_one_test(const std::string&, const VarMap& v Test::Result result(algo_name() + "/" + padding + " signature verification"); - for(auto&& verify_provider : possible_pk_providers()) + for(auto&& verify_provider : possible_providers(algo_name())) { std::unique_ptr<Botan::PK_Verifier> verifier; @@ -219,7 +215,7 @@ PK_Signature_NonVerification_Test::run_one_test(const std::string&, const VarMap Test::Result result(algo_name() + "/" + padding + " verify invalid signature"); - for(auto&& verify_provider : possible_pk_providers()) + for(auto&& verify_provider : possible_providers(algo_name())) { std::unique_ptr<Botan::PK_Verifier> verifier; @@ -255,7 +251,7 @@ PK_Encryption_Decryption_Test::run_one_test(const std::string&, const VarMap& va std::vector<std::unique_ptr<Botan::PK_Decryptor>> decryptors; - for(auto&& dec_provider : possible_pk_providers()) + for(auto&& dec_provider : possible_providers(algo_name())) { std::unique_ptr<Botan::PK_Decryptor> decryptor; @@ -273,7 +269,7 @@ PK_Encryption_Decryption_Test::run_one_test(const std::string&, const VarMap& va } - for(auto&& enc_provider : possible_pk_providers()) + for(auto&& enc_provider : possible_providers(algo_name())) { std::unique_ptr<Botan::PK_Encryptor> encryptor; @@ -388,7 +384,7 @@ Test::Result PK_Key_Agreement_Test::run_one_test(const std::string& header, cons const size_t key_len = get_opt_sz(vars, "OutLen", 0); - for(auto&& provider : possible_pk_providers()) + for(auto&& provider : possible_providers(algo_name())) { std::unique_ptr<Botan::PK_Key_Agreement> kas; diff --git a/src/tests/test_pubkey.h b/src/tests/test_pubkey.h index cbcc38f9d..7709f51c7 100644 --- a/src/tests/test_pubkey.h +++ b/src/tests/test_pubkey.h @@ -30,6 +30,9 @@ class PK_Test : public Text_Based_Test std::string algo_name() const { return m_algo; } + protected: + std::vector<std::string> possible_providers(const std::string&) override; + private: std::string m_algo; }; diff --git a/src/tests/test_stream.cpp b/src/tests/test_stream.cpp index 9250f4e2f..c2c7ce901 100644 --- a/src/tests/test_stream.cpp +++ b/src/tests/test_stream.cpp @@ -32,7 +32,8 @@ class Stream_Cipher_Tests : public Text_Based_Test Test::Result result(algo); - const std::vector<std::string> providers = Botan::StreamCipher::providers(algo); + const std::vector<std::string> providers = + provider_filter(Botan::StreamCipher::providers(algo)); if(providers.empty()) { diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp index a7de5c45e..fe97a2a7a 100644 --- a/src/tests/tests.cpp +++ b/src/tests/tests.cpp @@ -849,6 +849,11 @@ parse_cpuid_bits(const std::vector<std::string>& tok) } +std::vector<std::string> Text_Based_Test::possible_providers(const std::string&) + { + return Test::provider_filter({ "base" }); + } + bool Text_Based_Test::skip_this_test(const std::string& /*header*/, const VarMap& /*vars*/) { @@ -920,7 +925,8 @@ std::vector<Test::Result> Text_Based_Test::run() { try { - if(skip_this_test(header, vars)) + if(possible_providers(header).empty() || + skip_this_test(header, vars)) { continue; } @@ -963,6 +969,11 @@ std::vector<Test::Result> Text_Based_Test::run() } } + if(results.empty()) + { + return results; + } + try { std::vector<Test::Result> final_tests = run_final_tests(); diff --git a/src/tests/tests.h b/src/tests/tests.h index 484e5579e..406cff57a 100644 --- a/src/tests/tests.h +++ b/src/tests/tests.h @@ -441,8 +441,8 @@ class Text_Based_Test : public Test virtual Test::Result run_one_test(const std::string& header, const VarMap& vars) = 0; - // Called before run_one_test + virtual std::vector<std::string> possible_providers(const std::string&); virtual bool skip_this_test(const std::string& header, const VarMap& vars); |