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

randombit / botan / 11902390173

18 Nov 2024 10:36PM UTC coverage: 91.063% (-0.01%) from 91.073%
11902390173

push

github

web-flow
Merge pull request #4437 from Rohde-Schwarz/feature/ecc_constructor

90631 of 99526 relevant lines covered (91.06%)

9447600.83 hits per line

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

91.3
/src/lib/pubkey/ecc_key/ec_key_data.cpp
1
/*
2
* (C) 2024 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6

7
#include <botan/internal/ec_key_data.h>
8

9
#include <botan/rng.h>
10

11
namespace Botan {
12

13
EC_PublicKey_Data::EC_PublicKey_Data(EC_Group group, std::span<const uint8_t> bytes) :
4,277✔
14
      m_group(std::move(group)), m_point(m_group, bytes), m_legacy_point(m_point.to_legacy_point()) {}
4,277✔
15

16
EC_PrivateKey_Data::EC_PrivateKey_Data(EC_Group group, const BigInt& x) :
×
17
      m_group(std::move(group)), m_scalar(EC_Scalar::from_bigint(m_group, x)), m_legacy_x(m_scalar.to_bigint()) {}
×
18

19
EC_PrivateKey_Data::EC_PrivateKey_Data(EC_Group group, EC_Scalar x) :
6,640✔
20
      m_group(std::move(group)), m_scalar(std::move(x)), m_legacy_x(m_scalar.to_bigint()) {}
6,640✔
21

22
EC_PrivateKey_Data::EC_PrivateKey_Data(EC_Group group, std::span<const uint8_t> bytes) :
1,021✔
23
      m_group(std::move(group)), m_scalar(m_group, bytes), m_legacy_x(m_scalar.to_bigint()) {}
1,021✔
24

25
std::shared_ptr<EC_PublicKey_Data> EC_PrivateKey_Data::public_key(RandomNumberGenerator& rng,
6,643✔
26
                                                                  bool with_modular_inverse) const {
27
   auto public_point = [&] {
13,286✔
28
      std::vector<BigInt> ws;
6,643✔
29
      if(with_modular_inverse) {
6,643✔
30
         return EC_AffinePoint::g_mul(m_scalar.invert(), rng, ws);
87✔
31
      } else {
32
         return EC_AffinePoint::g_mul(m_scalar, rng, ws);
6,556✔
33
      }
34
   };
6,643✔
35

36
   return std::make_shared<EC_PublicKey_Data>(m_group, public_point());
6,643✔
37
}
38

39
std::shared_ptr<EC_PublicKey_Data> EC_PrivateKey_Data::public_key(bool with_modular_inverse) const {
3✔
40
   Null_RNG null_rng;
3✔
41
   return this->public_key(null_rng, with_modular_inverse);
3✔
42
}
3✔
43

44
void EC_PrivateKey_Data::serialize_to(std::span<uint8_t> output) const {
761✔
45
   m_scalar.serialize_to(output);
761✔
46
}
761✔
47

48
}  // namespace Botan
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