Skip to content

Commit

Permalink
Add a test for pcurves base point multiplication
Browse files Browse the repository at this point in the history
  • Loading branch information
randombit committed Apr 12, 2024
1 parent 62f8019 commit d2f7ca2
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/tests/test_ecc_pointmul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,47 @@

#include "tests.h"

#if defined(BOTAN_HAS_ECDSA)
#include <botan/ecdsa.h>
#if defined(BOTAN_HAS_BIGINT)
#include <botan/bigint.h>
#endif

#if defined(BOTAN_HAS_ECC_GROUP)
#include <botan/ec_group.h>
#endif

#if defined(BOTAN_HAS_PCURVES)
#include <botan/internal/pcurves.h>
#endif

namespace Botan_Tests {

namespace {

#if defined(BOTAN_HAS_PCURVES)

class ECC_Basepoint_Pcurve_Mul_Tests final : public Text_Based_Test {
public:
ECC_Basepoint_Pcurve_Mul_Tests() : Text_Based_Test("pubkey/ecc_base_point_mul.vec", "k,P") {}

Test::Result run_one_test(const std::string& group_id, const VarMap& vars) override {
Test::Result result("ECC base point multiply with pcurve " + group_id);

const auto k_bytes = vars.get_req_bin("k");
const auto P_bytes = vars.get_req_bin("P");

if(auto id = Botan::PCurve::PrimeOrderCurveId::from_string(group_id)) {
const auto pt = Botan::PCurve::mul_by_g(id.value(), k_bytes);
result.test_eq("pcurves point", pt, P_bytes);
}

return result;
}
};

BOTAN_REGISTER_TEST("pubkey", "ecc_basemul_pcurve", ECC_Basepoint_Pcurve_Mul_Tests);

#endif

#if defined(BOTAN_HAS_ECC_GROUP)

class ECC_Basepoint_Mul_Tests final : public Text_Based_Test {
Expand Down

0 comments on commit d2f7ca2

Please sign in to comment.