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

randombit / botan / 12661312886

07 Jan 2025 11:55PM UTC coverage: 91.251% (-0.02%) from 91.267%
12661312886

push

github

web-flow
Merge pull request #4518 from randombit/jack/ec-point-cleanups

Move EC_Point and related code to deprecated submodule

93407 of 102363 relevant lines covered (91.25%)

11518305.49 hits per line

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

92.0
/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,273✔
14
      m_group(std::move(group)), m_point(m_group, bytes) {
4,273✔
15
#if defined(BOTAN_HAS_LEGACY_EC_POINT)
16
   m_legacy_point = m_point.to_legacy_point();
7,996✔
17
#endif
18
}
4,273✔
19

20
EC_PrivateKey_Data::EC_PrivateKey_Data(EC_Group group, const BigInt& x) :
×
21
      m_group(std::move(group)), m_scalar(EC_Scalar::from_bigint(m_group, x)), m_legacy_x(m_scalar.to_bigint()) {}
×
22

23
EC_PrivateKey_Data::EC_PrivateKey_Data(EC_Group group, EC_Scalar x) :
6,635✔
24
      m_group(std::move(group)), m_scalar(std::move(x)), m_legacy_x(m_scalar.to_bigint()) {}
6,635✔
25

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

29
std::shared_ptr<EC_PublicKey_Data> EC_PrivateKey_Data::public_key(RandomNumberGenerator& rng,
6,638✔
30
                                                                  bool with_modular_inverse) const {
31
   auto public_point = [&] {
13,276✔
32
      std::vector<BigInt> ws;
6,638✔
33
      if(with_modular_inverse) {
6,638✔
34
         return EC_AffinePoint::g_mul(m_scalar.invert(), rng, ws);
88✔
35
      } else {
36
         return EC_AffinePoint::g_mul(m_scalar, rng, ws);
6,550✔
37
      }
38
   };
6,638✔
39

40
   return std::make_shared<EC_PublicKey_Data>(m_group, public_point());
6,638✔
41
}
42

43
std::shared_ptr<EC_PublicKey_Data> EC_PrivateKey_Data::public_key(bool with_modular_inverse) const {
3✔
44
   Null_RNG null_rng;
3✔
45
   return this->public_key(null_rng, with_modular_inverse);
3✔
46
}
3✔
47

48
void EC_PrivateKey_Data::serialize_to(std::span<uint8_t> output) const {
761✔
49
   m_scalar.serialize_to(output);
761✔
50
}
761✔
51

52
}  // 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