• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 5079590438

25 May 2023 12:28PM UTC coverage: 92.228% (+0.5%) from 91.723%
5079590438

Pull #3502

github

Pull Request #3502: Apply clang-format to the codebase

75589 of 81959 relevant lines covered (92.23%)

12139530.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.35
/src/tests/test_ecc_pointmul.cpp
1
/*
2
* (C) 2014,2015,2019 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6

7
#include "tests.h"
8

9
#if defined(BOTAN_HAS_ECDSA)
10
   #include <botan/ecdsa.h>
11
#endif
12

13
#if defined(BOTAN_HAS_ECC_GROUP)
14
   #include <botan/ec_group.h>
15
#endif
16

17
namespace Botan_Tests {
18

19
namespace {
20

21
#if defined(BOTAN_HAS_ECC_GROUP)
22

23
class ECC_Basepoint_Mul_Tests final : public Text_Based_Test {
×
24
   public:
25
      ECC_Basepoint_Mul_Tests() : Text_Based_Test("pubkey/ecc_base_point_mul.vec", "m,X,Y") {}
2✔
26

27
      Test::Result run_one_test(const std::string& group_id, const VarMap& vars) override {
362✔
28
         Test::Result result("ECC base point multiply " + group_id);
362✔
29

30
         const Botan::BigInt m = vars.get_req_bn("m");
362✔
31
         const Botan::BigInt X = vars.get_req_bn("X");
362✔
32
         const Botan::BigInt Y = vars.get_req_bn("Y");
362✔
33

34
         Botan::EC_Group group(Botan::OID::from_string(group_id));
362✔
35

36
         const Botan::EC_Point& base_point = group.get_base_point();
362✔
37

38
         const Botan::EC_Point p1 = base_point * m;
362✔
39
         result.test_eq("p1 affine X", p1.get_affine_x(), X);
724✔
40
         result.test_eq("p1 affine Y", p1.get_affine_y(), Y);
724✔
41

42
         std::vector<Botan::BigInt> ws;
362✔
43
         const Botan::EC_Point p2 = group.blinded_base_point_multiply(m, Test::rng(), ws);
362✔
44
         result.test_eq("p2 affine X", p2.get_affine_x(), X);
724✔
45
         result.test_eq("p2 affine Y", p2.get_affine_y(), Y);
724✔
46

47
         const Botan::EC_Point p3 = group.blinded_var_point_multiply(base_point, m, Test::rng(), ws);
362✔
48
         result.test_eq("p3 affine X", p3.get_affine_x(), X);
724✔
49
         result.test_eq("p3 affine Y", p3.get_affine_y(), Y);
724✔
50

51
         return result;
724✔
52
      }
1,448✔
53
};
54

55
BOTAN_REGISTER_TEST("pubkey", "ecc_basemul", ECC_Basepoint_Mul_Tests);
56

57
class ECC_Varpoint_Mul_Tests final : public Text_Based_Test {
×
58
   public:
59
      ECC_Varpoint_Mul_Tests() : Text_Based_Test("pubkey/ecc_var_point_mul.vec", "X,Y,k,kX,kY") {}
2✔
60

61
      Test::Result run_one_test(const std::string& group_id, const VarMap& vars) override {
10✔
62
         Test::Result result("ECC var point multiply " + group_id);
10✔
63

64
         const Botan::BigInt X = vars.get_req_bn("X");
10✔
65
         const Botan::BigInt Y = vars.get_req_bn("Y");
10✔
66
         const Botan::BigInt k = vars.get_req_bn("k");
10✔
67
         const Botan::BigInt kX = vars.get_req_bn("kX");
10✔
68
         const Botan::BigInt kY = vars.get_req_bn("kY");
10✔
69

70
         Botan::EC_Group group(Botan::OID::from_string(group_id));
10✔
71

72
         const Botan::EC_Point pt = group.point(X, Y);
10✔
73

74
         result.confirm("Input point is on the curve", pt.on_the_curve());
20✔
75

76
         const Botan::EC_Point p1 = pt * k;
10✔
77
         result.test_eq("p1 affine X", p1.get_affine_x(), kX);
20✔
78
         result.test_eq("p1 affine Y", p1.get_affine_y(), kY);
20✔
79

80
         result.confirm("Output point is on the curve", p1.on_the_curve());
20✔
81

82
         std::vector<Botan::BigInt> ws;
10✔
83
         const Botan::EC_Point p2 = group.blinded_var_point_multiply(pt, k, Test::rng(), ws);
10✔
84
         result.test_eq("p2 affine X", p2.get_affine_x(), kX);
20✔
85
         result.test_eq("p2 affine Y", p2.get_affine_y(), kY);
20✔
86

87
         return result;
20✔
88
      }
60✔
89
};
90

91
BOTAN_REGISTER_TEST("pubkey", "ecc_varmul", ECC_Varpoint_Mul_Tests);
92

93
#endif
94

95
}
96

97
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc