diff options
author | Tobias | Never <[email protected]> | 2017-02-28 15:21:09 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2017-02-28 15:21:09 +0100 |
commit | 15d1e94b85890964f38fab8f8aca5f7109e0684e (patch) | |
tree | 6658331a15aa23da4b055dbd62ea5be462f5e06c /src/tests/unit_ecc.cpp | |
parent | 5cf9935fc040648ed767fbfcff46afdf28d39992 (diff) | |
parent | 96033661c46807b94b35419a8520d43445cabee2 (diff) |
Merge pull request #2 from Rohde-Schwarz-Cybersecurity/extended-ec-public-key-checks
Extended ec public key checks
Diffstat (limited to 'src/tests/unit_ecc.cpp')
-rw-r--r-- | src/tests/unit_ecc.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/tests/unit_ecc.cpp b/src/tests/unit_ecc.cpp index 3ab22e57e..aac1d3ddf 100644 --- a/src/tests/unit_ecc.cpp +++ b/src/tests/unit_ecc.cpp @@ -18,6 +18,8 @@ #include <botan/reducer.h> #include <botan/oids.h> #include <botan/hex.h> + #include <botan/data_src.h> + #include <botan/x509_key.h> #endif namespace Botan_Tests { @@ -833,6 +835,33 @@ class ECC_Unit_Tests : public Test BOTAN_REGISTER_TEST("ecc_unit", ECC_Unit_Tests); +class ECC_Invalid_Key_Tests : public Text_Based_Test + { + public: + ECC_Invalid_Key_Tests() : + Text_Based_Test("pubkey/ecc_invalid.vec", "SubjectPublicKey") {} + + bool clear_between_callbacks() const override { return false; } + + Test::Result run_one_test(const std::string&, const VarMap& vars) override + { + // TODO extract params from encoded key and move test vectors to ecdsa_invalid.vec + Test::Result result("ECC invalid keys"); + + const std::string encoded = get_req_str(vars, "SubjectPublicKey"); + Botan::DataSource_Memory key_data(Botan::hex_decode(encoded)); + + std::unique_ptr<Botan::Public_Key> key(Botan::X509::load_key(key_data)); + result.test_eq("public key fails check", key->check_key(Test::rng(), false), false); + + std::cout << key->algo_name() << std::endl; + + return result; + } + }; + +BOTAN_REGISTER_TEST("ecc_invalid", ECC_Invalid_Key_Tests); + #endif } |