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

randombit / botan / 22022566023

14 Feb 2026 06:55PM UTC coverage: 90.067%. Remained the same
22022566023

push

github

web-flow
Merge pull request #5334 from randombit/jack/test-h-remove-confirm

Remove confirm test helper, use test_is_true or test_is_false instead

102260 of 113538 relevant lines covered (90.07%)

11510296.11 hits per line

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

75.0
/src/tests/test_ecc_explicit_params.cpp
1
/*
2
* (C) 2026 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_ECDSA)
10
   #include <botan/ec_group.h>
11
   #include <botan/ecdsa.h>
12
   #include <botan/x509_key.h>
13
#endif
14

15
namespace Botan_Tests {
16

17
namespace {
18

19
#if defined(BOTAN_HAS_ECDSA)
20

21
class ECC_Explicit_Curve_Tests final : public Text_Based_Test {
×
22
   public:
23
      ECC_Explicit_Curve_Tests() : Text_Based_Test("pubkey/ecc_explicit_curve.vec", "Pubkey,Result") {}
2✔
24

25
      Test::Result run_one_test(const std::string& /*unused*/, const VarMap& vars) override {
17✔
26
         Test::Result result("ECC explicit curve validation");
17✔
27

28
         const auto pubkey = vars.get_req_bin("Pubkey");
17✔
29
         const auto expected_result = vars.get_req_str("Result");
17✔
30

31
         try {
17✔
32
            auto pk = Botan::X509::load_key(pubkey);
17✔
33

34
            const auto* ecdsa = dynamic_cast<const Botan::ECDSA_PublicKey*>(pk.get());
3✔
35
            if(ecdsa != nullptr) {
3✔
36
               result.test_success("Returned key was ECDSA");
3✔
37

38
               auto used_explicit = ecdsa->domain().used_explicit_encoding();
3✔
39

40
               result.test_is_true("Loaded ECC key marked as an explicit encoding", used_explicit);
3✔
41
            } else {
42
               result.test_failure("Returned key was some other type");
×
43
            }
44

45
            if(expected_result == "OK") {
3✔
46
               result.test_success("Accepted valid explicit curve parameters");
3✔
47
            } else {
48
               result.test_failure("Accepted invalid explicit curve parameters");
×
49
            }
50
         } catch(Botan::Not_Implemented& e) {
17✔
51
            // Can happen if pcurves_generic is not in the build
52
            const std::string err(e.what());
×
53
            result.test_is_true("Expected error",
×
54
                                err.find("is not supported in this build config") != std::string::npos);
×
55
         } catch(Botan::Exception& e) {
14✔
56
            const std::string err(e.what());
14✔
57
            if(expected_result == "OK") {
14✔
58
               result.test_failure("Rejected valid explicit curve parameters", err);
×
59
            } else {
60
               result.test_success("Rejected invalid explicit curve parameters");
14✔
61

62
               if(err.find(expected_result) != std::string::npos) {
14✔
63
                  result.test_success("Rejection error matches expected");
14✔
64
               } else {
65
                  result.test_failure("Rejection failure other than what was expected", err);
×
66
               }
67
            }
68
         }
14✔
69

70
         return result;
17✔
71
      }
34✔
72
};
73

74
BOTAN_REGISTER_TEST("pubkey", "ecc_explicit_curve", ECC_Explicit_Curve_Tests);
75

76
#endif
77

78
}  // namespace
79

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