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

randombit / botan / 12256396908

10 Dec 2024 12:45PM UTC coverage: 91.251% (+0.2%) from 91.076%
12256396908

Pull #4309

github

web-flow
Merge 733a9052d into 4725c2d79
Pull Request #4309: Add Entropy Source and DRNG Manager (ESDM) RNG support

93431 of 102389 relevant lines covered (91.25%)

11600314.44 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,269✔
14
      m_group(std::move(group)), m_point(m_group, bytes), m_legacy_point(m_point.to_legacy_point()) {}
4,269✔
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,639✔
20
      m_group(std::move(group)), m_scalar(std::move(x)), m_legacy_x(m_scalar.to_bigint()) {}
6,639✔
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,642✔
26
                                                                  bool with_modular_inverse) const {
27
   auto public_point = [&] {
13,284✔
28
      std::vector<BigInt> ws;
6,642✔
29
      if(with_modular_inverse) {
6,642✔
30
         return EC_AffinePoint::g_mul(m_scalar.invert(), rng, ws);
86✔
31
      } else {
32
         return EC_AffinePoint::g_mul(m_scalar, rng, ws);
6,556✔
33
      }
34
   };
6,642✔
35

36
   return std::make_shared<EC_PublicKey_Data>(m_group, public_point());
6,642✔
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