diff options
author | Jack Lloyd <[email protected]> | 2015-11-11 05:43:01 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-11-11 05:43:01 -0500 |
commit | cf05aea092fad448c2f4a8e8b66159237096ba8e (patch) | |
tree | 00631bcc84809a1eeac5dd32dd92c62143ef831b /src/tests/test_ecc_pointmul.cpp | |
parent | 6bb38ae2fa0e1be46b3a3256ac03f435b16a57ea (diff) |
Update and consolidate the test framework.
The tests previously had used 4 to 6 different schemes internally (the vec file
reader framework, Catch, the old InSiTo Boost.Test tests, the PK/BigInt tests
which escaped the rewrite in 1.11.7, plus a number of one-offs). Converge on a
design that works everywhere, and update all the things.
Fix also a few bugs found by the test changes: SHA-512-256 name incorrect,
OpenSSL RC4 name incorrect, signature of FFI function botan_pubkey_destroy
was wrong.
Diffstat (limited to 'src/tests/test_ecc_pointmul.cpp')
-rw-r--r-- | src/tests/test_ecc_pointmul.cpp | 90 |
1 files changed, 32 insertions, 58 deletions
diff --git a/src/tests/test_ecc_pointmul.cpp b/src/tests/test_ecc_pointmul.cpp index b8537ec64..818fc4460 100644 --- a/src/tests/test_ecc_pointmul.cpp +++ b/src/tests/test_ecc_pointmul.cpp @@ -6,78 +6,52 @@ #include "tests.h" -#if defined(BOTAN_HAS_ECC_GROUP) - #if defined(BOTAN_HAS_ECDSA) + #include "test_pubkey.h" + #include <botan/pubkey.h> + #include <botan/ecdsa.h> + #include <botan/oids.h> +#endif -#include "test_pubkey.h" - -#include <botan/pubkey.h> -#include <botan/ecdsa.h> -#include <botan/oids.h> -#include <botan/hex.h> -#include <iostream> -#include <fstream> - -using namespace Botan; +namespace Botan_Tests { namespace { -size_t ecc_point_mul(const std::string& group_id, - const std::string& m_s, - const std::string& X_s, - const std::string& Y_s) +#if defined(BOTAN_HAS_ECDSA) +class ECC_Pointmult_Tests : public Text_Based_Test { - EC_Group group(OIDS::lookup(group_id)); - - const BigInt m(m_s); - const BigInt X(X_s); - const BigInt Y(Y_s); - - PointGFp p = group.get_base_point() * m; - - size_t fails = 0; + public: + ECC_Pointmult_Tests() : Text_Based_Test( + Test::data_file("pubkey/ecc.vec"), + {"Group", "m", "X", "Y"}) + {} - if(p.get_affine_x() != X) - { - std::cout << p.get_affine_x() << " != " << X << std::endl; - ++fails; - } + bool clear_between_callbacks() const override { return false; } - if(p.get_affine_y() != Y) - { - std::cout << p.get_affine_y() << " != " << Y << std::endl; - ++fails; - } + Test::Result run_one_test(const std::string&, const VarMap& vars) override + { + const std::string group_id = get_req_str(vars, "Group"); - return fails; - } + const Botan::BigInt m = get_req_bn(vars, "m"); + const Botan::BigInt X = get_req_bn(vars, "X"); + const Botan::BigInt Y = get_req_bn(vars, "Y"); -} - -size_t test_ecc_pointmul() - { - size_t fails = 0; - - std::ifstream ecc_mul(TEST_DATA_DIR_PK "/ecc.vec"); + Botan::EC_Group group(Botan::OIDS::lookup(group_id)); - fails += run_tests_bb(ecc_mul, "ECC Point Mult", "Y", false, - [](std::map<std::string, std::string> m) -> size_t - { - return ecc_point_mul(m["Group"], m["m"], m["X"], m["Y"]); - }); + const Botan::PointGFp p = group.get_base_point() * m; - return fails; - } + Test::Result result("ECC Scalarmult"); + result.test_eq("affine X", p.get_affine_x(), X); + result.test_eq("affine Y", p.get_affine_y(), Y); -#else + return result; + } + }; -UNTESTED_WARNING(ecc_pointmul); +BOTAN_REGISTER_TEST("ecc_pointmul", ECC_Pointmult_Tests); -#endif // BOTAN_HAS_ECDSA +#endif -#else - -SKIP_TEST(ecc_pointmul); +} -#endif // BOTAN_HAS_ECC_GROUP +} |