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

randombit / botan / 13021208024

28 Jan 2025 11:07PM UTC coverage: 91.241% (-0.02%) from 91.258%
13021208024

push

github

web-flow
Merge pull request #4604 from randombit/jack/support-minimal-curves

Avoid requiring legacy_ec_group in order to run the tests

94137 of 103174 relevant lines covered (91.24%)

11291073.45 hits per line

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

95.45
/src/tests/test_ecgdsa.cpp
1
/*
2
* (C) 2016 René Korthaus, Sirrix AG
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6

7
#include "tests.h"
8

9
#include "test_rng.h"
10

11
#if defined(BOTAN_HAS_ECGDSA)
12
   #include "test_pubkey.h"
13
   #include <botan/ecgdsa.h>
14
#endif
15

16
namespace Botan_Tests {
17

18
namespace {
19

20
#if defined(BOTAN_HAS_ECGDSA)
21

22
class ECGDSA_Signature_KAT_Tests final : public PK_Signature_Generation_Test {
23
   public:
24
      ECGDSA_Signature_KAT_Tests() :
1✔
25
            PK_Signature_Generation_Test("ECGDSA", "pubkey/ecgdsa.vec", "Group,X,Hash,Msg,Nonce,Signature") {}
2✔
26

27
      bool clear_between_callbacks() const override { return false; }
12✔
28

29
      bool skip_this_test(const std::string&, const VarMap& vars) override {
12✔
30
         return !Botan::EC_Group::supports_named_group(vars.get_req_str("Group"));
12✔
31
      }
32

33
      std::unique_ptr<Botan::Private_Key> load_private_key(const VarMap& vars) override {
12✔
34
         const std::string group_id = vars.get_req_str("Group");
12✔
35
         const BigInt x = vars.get_req_bn("X");
12✔
36
         const auto group = Botan::EC_Group::from_name(group_id);
12✔
37

38
         return std::make_unique<Botan::ECGDSA_PrivateKey>(this->rng(), group, x);
24✔
39
      }
24✔
40

41
      std::string default_padding(const VarMap& vars) const override { return vars.get_req_str("Hash"); }
24✔
42

43
      std::unique_ptr<Botan::RandomNumberGenerator> test_rng(const std::vector<uint8_t>& nonce) const override {
12✔
44
         // ecgdsa signature generation extracts more random than just the nonce,
45
         // but the nonce is extracted first
46
         return std::make_unique<Fixed_Output_Position_RNG>(nonce, 1, this->rng());
12✔
47
      }
48
};
49

50
class ECGDSA_Keygen_Tests final : public PK_Key_Generation_Test {
×
51
   public:
52
      std::vector<std::string> keygen_params() const override { return {"secp256r1", "secp384r1", "secp521r1"}; }
1✔
53

54
      std::string algo_name() const override { return "ECGDSA"; }
3✔
55

56
      std::unique_ptr<Botan::Public_Key> public_key_from_raw(std::string_view keygen_params,
3✔
57
                                                             std::string_view /* provider */,
58
                                                             std::span<const uint8_t> raw_pk) const override {
59
         const auto group = Botan::EC_Group(keygen_params);
3✔
60
         const auto public_key = Botan::EC_AffinePoint(group, raw_pk);
3✔
61
         return std::make_unique<Botan::ECGDSA_PublicKey>(group, public_key);
9✔
62
      }
3✔
63
};
64

65
BOTAN_REGISTER_TEST("pubkey", "ecgdsa_sign", ECGDSA_Signature_KAT_Tests);
66
BOTAN_REGISTER_TEST("pubkey", "ecgdsa_keygen", ECGDSA_Keygen_Tests);
67

68
#endif
69

70
}  // namespace
71

72
}  // namespace Botan_Tests
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

© 2026 Coveralls, Inc