diff options
author | lloyd <[email protected]> | 2014-10-10 22:46:08 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-10-10 22:46:08 +0000 |
commit | b5e4c9f963399b4dcb90ffa523cf5185334dd03f (patch) | |
tree | 7698d55ad8a51f341bae9572bf6b35f34774062f /src/tests/test_ecdsa.cpp | |
parent | 5e54dfe49ceb6ce5a9891477d190833399a0bda0 (diff) |
Add some secp256k1 KATs and a randomized ECC test suggested in
http://crypto.stackexchange.com/questions/784
Diffstat (limited to 'src/tests/test_ecdsa.cpp')
-rw-r--r-- | src/tests/test_ecdsa.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/tests/test_ecdsa.cpp b/src/tests/test_ecdsa.cpp index f9e83f117..9b256bf9c 100644 --- a/src/tests/test_ecdsa.cpp +++ b/src/tests/test_ecdsa.cpp @@ -34,9 +34,57 @@ size_t ecdsa_sig_kat(const std::string& group_id, return validate_signature(verify, sign, "DSA/" + hash, msg, rng, nonce, signature); } +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) + { + 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; + + if(p.get_affine_x() != X) + { + std::cout << p.get_affine_x() << " != " << X << "\n"; + ++fails; + } + + if(p.get_affine_y() != Y) + { + std::cout << p.get_affine_y() << " != " << Y << "\n"; + ++fails; + } + + return fails; + } + } + #endif +size_t test_ecc_pointmul() + { + size_t fails = 0; + +#if defined(BOTAN_HAS_ECC_GROUP) + std::ifstream ecc_mul(PK_TEST_DATA_DIR "/ecc.vec"); + + 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"]); + }); +#endif + + return fails; + } + size_t test_ecdsa() { size_t fails = 0; |