• 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

94.29
/src/tests/test_ecc_h2c.cpp
1
/*
2
* (C) 2019,2020 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_EC_HASH_TO_CURVE)
10
   #include <botan/ec_group.h>
11
   #include <botan/internal/ec_h2c.h>
12
#endif
13

14
namespace Botan_Tests {
15

16
namespace {
17

18
#if defined(BOTAN_HAS_EC_HASH_TO_CURVE)
19

20
class ECC_H2C_XMD_Tests final : public Text_Based_Test {
×
21
   public:
22
      ECC_H2C_XMD_Tests() : Text_Based_Test("pubkey/ec_h2c_xmd.vec", "Domain,Input,Output") {}
3✔
23

24
      bool clear_between_callbacks() const override { return false; }
20✔
25

26
      Test::Result run_one_test(const std::string& hash, const VarMap& vars) override {
20✔
27
         Test::Result result("ECC hash to curve XMD " + hash);
20✔
28

29
         const std::string domain = vars.get_req_str("Domain");
20✔
30
         const std::string input = vars.get_req_str("Input");
20✔
31
         const std::vector<uint8_t> expected = vars.get_req_bin("Output");
20✔
32

33
         std::vector<uint8_t> output(expected.size());
20✔
34
         Botan::expand_message_xmd(hash,
20✔
35
                                   output.data(),
36
                                   output.size(),
37
                                   reinterpret_cast<const uint8_t*>(input.data()),
20✔
38
                                   input.size(),
39
                                   reinterpret_cast<const uint8_t*>(domain.data()),
20✔
40
                                   domain.size());
41

42
         result.test_eq("XMD output", output, expected);
20✔
43
         return result;
20✔
44
      }
72✔
45
};
46

47
BOTAN_REGISTER_TEST("ec_h2c", "ec_h2c_xmd", ECC_H2C_XMD_Tests);
48

49
class ECC_H2C_Tests final : public Text_Based_Test {
×
50
   public:
51
      ECC_H2C_Tests() : Text_Based_Test("pubkey/ec_h2c.vec", "Group,Hash,Domain,Input,PointX,PointY") {}
3✔
52

53
      bool clear_between_callbacks() const override { return false; }
30✔
54

55
      Test::Result run_one_test(const std::string& method, const VarMap& vars) override {
30✔
56
         const std::string group_id = vars.get_req_str("Group");
30✔
57

58
         Test::Result result("ECC hash to curve " + method + " " + group_id);
30✔
59

60
         const std::string hash = vars.get_req_str("Hash");
30✔
61
         const std::string domain = vars.get_req_str("Domain");
30✔
62
         const std::string input = vars.get_req_str("Input");
30✔
63
         const BigInt exp_point_x = vars.get_req_bn("PointX");
30✔
64
         const BigInt exp_point_y = vars.get_req_bn("PointY");
30✔
65
         const bool random_oracle = method.find("-RO") != std::string::npos;
30✔
66

67
         Botan::EC_Group group(group_id);
30✔
68

69
         const auto point = group.hash_to_curve(
30✔
70
            hash, reinterpret_cast<const uint8_t*>(input.data()), input.size(), domain, random_oracle);
30✔
71

72
         result.confirm("Generated point is on the curve", point.on_the_curve());
60✔
73

74
         result.test_eq("Affine X", point.get_affine_x(), exp_point_x);
60✔
75
         result.test_eq("Affine Y", point.get_affine_y(), exp_point_y);
60✔
76

77
         return result;
60✔
78
      }
138✔
79
};
80

81
BOTAN_REGISTER_TEST("ec_h2c", "ec_h2c_kat", ECC_H2C_Tests);
82

83
#endif
84

85
}
86

87
}
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