/* * (C) 2015,2016 Jack Lloyd * * Botan is released under the Simplified BSD License (see license.txt) */ #include "tests.h" #if defined(BOTAN_HAS_ECDH) #include "test_pubkey.h" #include #include #endif namespace Botan_Tests { namespace { #if defined(BOTAN_HAS_ECDH) class ECDH_KAT_Tests : public PK_Key_Agreement_Test { public: ECDH_KAT_Tests() : PK_Key_Agreement_Test( "ECDH", "pubkey/ecdh.vec", "Group,Secret,CounterKey,K", "KDF") {} std::string default_kdf(const VarMap&) const override { return "Raw"; } std::unique_ptr load_our_key(const std::string& group_id, const VarMap& vars) override { Botan::EC_Group group(group_id); const Botan::BigInt secret = get_req_bn(vars, "Secret"); std::unique_ptr key(new Botan::ECDH_PrivateKey(Test::rng(), group, secret)); return key; } std::vector load_their_key(const std::string&, const VarMap& vars) override { return get_req_bin(vars, "CounterKey"); } }; class ECDH_Keygen_Tests : public PK_Key_Generation_Test { public: std::vector keygen_params() const override { return { "secp256r1", "secp384r1", "secp521r1", "brainpool256r1", "brainpool384r1", "brainpool512r1", "frp256v1" }; } std::string algo_name() const override { return "ECDH"; } }; BOTAN_REGISTER_TEST("ecdh_kat", ECDH_KAT_Tests); BOTAN_REGISTER_TEST("ecdh_keygen", ECDH_Keygen_Tests); #endif } }