diff options
Diffstat (limited to 'src/tests/unit_tls.cpp')
-rw-r--r-- | src/tests/unit_tls.cpp | 166 |
1 files changed, 0 insertions, 166 deletions
diff --git a/src/tests/unit_tls.cpp b/src/tests/unit_tls.cpp index f9132d60a..30c5ca779 100644 --- a/src/tests/unit_tls.cpp +++ b/src/tests/unit_tls.cpp @@ -10,8 +10,6 @@ #include "tests.h" #include <vector> #include <memory> -#include <thread> -#include <fstream> #if defined(BOTAN_HAS_TLS) @@ -293,170 +291,6 @@ create_creds(Botan::RandomNumberGenerator& rng, return cmt; } -class Test_TLS_Alert_Strings : public Test - { - public: - std::vector<Test::Result> run() override - { - Test::Result result("TLS::Alert::type_string"); - - const std::vector<Botan::TLS::Alert::Type> alert_types = - { - Botan::TLS::Alert::CLOSE_NOTIFY, - Botan::TLS::Alert::UNEXPECTED_MESSAGE, - Botan::TLS::Alert::BAD_RECORD_MAC, - Botan::TLS::Alert::DECRYPTION_FAILED, - Botan::TLS::Alert::RECORD_OVERFLOW, - Botan::TLS::Alert::DECOMPRESSION_FAILURE, - Botan::TLS::Alert::HANDSHAKE_FAILURE, - Botan::TLS::Alert::NO_CERTIFICATE, - Botan::TLS::Alert::BAD_CERTIFICATE, - Botan::TLS::Alert::UNSUPPORTED_CERTIFICATE, - Botan::TLS::Alert::CERTIFICATE_REVOKED, - Botan::TLS::Alert::CERTIFICATE_EXPIRED, - Botan::TLS::Alert::CERTIFICATE_UNKNOWN, - Botan::TLS::Alert::ILLEGAL_PARAMETER, - Botan::TLS::Alert::UNKNOWN_CA, - Botan::TLS::Alert::ACCESS_DENIED, - Botan::TLS::Alert::DECODE_ERROR, - Botan::TLS::Alert::DECRYPT_ERROR, - Botan::TLS::Alert::EXPORT_RESTRICTION, - Botan::TLS::Alert::PROTOCOL_VERSION, - Botan::TLS::Alert::INSUFFICIENT_SECURITY, - Botan::TLS::Alert::INTERNAL_ERROR, - Botan::TLS::Alert::INAPPROPRIATE_FALLBACK, - Botan::TLS::Alert::USER_CANCELED, - Botan::TLS::Alert::NO_RENEGOTIATION, - Botan::TLS::Alert::UNSUPPORTED_EXTENSION, - Botan::TLS::Alert::CERTIFICATE_UNOBTAINABLE, - Botan::TLS::Alert::UNRECOGNIZED_NAME, - Botan::TLS::Alert::BAD_CERTIFICATE_STATUS_RESPONSE, - Botan::TLS::Alert::BAD_CERTIFICATE_HASH_VALUE, - Botan::TLS::Alert::UNKNOWN_PSK_IDENTITY, - Botan::TLS::Alert:: NO_APPLICATION_PROTOCOL, - }; - - std::set<std::string> seen; - - for(auto alert : alert_types) - { - const std::string str = Botan::TLS::Alert(alert).type_string(); - result.test_eq("No duplicate strings", seen.count(str), 0); - seen.insert(str); - } - - Botan::TLS::Alert unknown_alert = Botan::TLS::Alert({01, 66}); - - result.test_eq("Unknown alert str", unknown_alert.type_string(), "unrecognized_alert_66"); - - return {result}; - } - }; - -BOTAN_REGISTER_TEST("tls_alert_strings", Test_TLS_Alert_Strings); - -class Test_TLS_Ciphersuites : public Test - { - public: - std::vector<Test::Result> run() override - { - Test::Result result("TLS::Ciphersuite"); - - for(size_t csuite_id = 0; csuite_id <= 0xFFFF; ++csuite_id) - { - Botan::TLS::Ciphersuite ciphersuite = Botan::TLS::Ciphersuite::by_id(csuite_id); - - if(ciphersuite.valid()) - { - result.test_eq("Valid Ciphersuite is not SCSV", Botan::TLS::Ciphersuite::is_scsv(csuite_id), false); - - if(ciphersuite.cbc_ciphersuite() == false) - { - result.test_eq("Expected MAC name for AEAD ciphersuites", ciphersuite.mac_algo(), "AEAD"); - } - else - { - result.test_eq("MAC algo and PRF algo same for CBC suites", ciphersuite.prf_algo(), ciphersuite.mac_algo()); - } - - // TODO more tests here - } - } - - return {result}; - } - }; - -BOTAN_REGISTER_TEST("tls_ciphersuites", Test_TLS_Ciphersuites); - -class Test_TLS_Policy_Test : public Test - { - public: - std::vector<Test::Result> run() override - { - Test::Result result("TLS Policy"); - - const std::vector<std::string> policies = { "default", "suiteb", "strict", "datagram", "bsi" }; - - for(std::string policy : policies) - { - result.test_eq("Values for TLS " + policy + " policy", - tls_policy_string(policy), - read_tls_policy(policy)); - } - - return {result}; - } - - private: - std::string read_tls_policy(const std::string& policy_str) - { - const std::string fspath = Test::data_file("tls-policy/" + policy_str + ".txt"); - - std::ifstream is(fspath.c_str()); - if(!is.good()) - { - throw Test_Error("Missing policy file " + fspath); - } - - Botan::TLS::Text_Policy policy(is); - return policy.to_string(); - } - - std::string tls_policy_string(const std::string& policy_str) - { - std::unique_ptr<Botan::TLS::Policy> policy; - if(policy_str == "default") - { - policy.reset(new Botan::TLS::Policy); - } - else if(policy_str == "suiteb") - { - policy.reset(new Botan::TLS::NSA_Suite_B_128); - } - else if(policy_str == "bsi") - { - policy.reset(new Botan::TLS::BSI_TR_02102_2); - } - else if(policy_str == "strict") - { - policy.reset(new Botan::TLS::Strict_Policy); - } - else if(policy_str == "datagram") - { - policy.reset(new Botan::TLS::Datagram_Policy); - } - else - { - throw Test_Error("Unknown TLS policy type '" + policy_str + "'"); - } - - return policy->to_string(); - } - }; - -BOTAN_REGISTER_TEST("tls_policy_test", Test_TLS_Policy_Test); - class TLS_Handshake_Test final { public: |