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

randombit / botan / 16705292888

03 Aug 2025 01:02PM UTC coverage: 90.679% (+0.002%) from 90.677%
16705292888

push

github

web-flow
Merge pull request #5035 from randombit/jack/clang-tidy-unchecked-optional-access

Fix some bugprone-unchecked-optional-access warnings from clang-tidy

99988 of 110266 relevant lines covered (90.68%)

12365238.73 hits per line

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

92.59
/src/tests/test_gost_3410.cpp
1
/*
2
* (C) 2014,2015 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_GOST_34_10_2001)
10
   #include "test_pubkey.h"
11
   #include <botan/gost_3410.h>
12
#endif
13

14
namespace Botan_Tests {
15

16
namespace {
17

18
#if defined(BOTAN_HAS_GOST_34_10_2001)
19

20
class GOST_3410_2001_Verification_Tests final : public PK_Signature_Verification_Test {
21
   public:
22
      GOST_3410_2001_Verification_Tests() :
1✔
23
            PK_Signature_Verification_Test(
24
               "GOST 34.10-2001", "pubkey/gost_3410_verify.vec", "P,A,B,Gx,Gy,Oid,Order,Px,Py,Hash,Msg,Signature") {}
2✔
25

26
      bool skip_this_test(const std::string& /*header*/, const VarMap& /*vars*/) override {
1✔
27
         return !Botan::EC_Group::supports_application_specific_group();
1✔
28
      }
29

30
      std::unique_ptr<Botan::Public_Key> load_public_key(const VarMap& vars) override {
1✔
31
         const BigInt p = vars.get_req_bn("P");
1✔
32
         const BigInt a = vars.get_req_bn("A");
1✔
33
         const BigInt b = vars.get_req_bn("B");
1✔
34
         const BigInt Gx = vars.get_req_bn("Gx");
1✔
35
         const BigInt Gy = vars.get_req_bn("Gy");
1✔
36
         const BigInt order = vars.get_req_bn("Order");
1✔
37
         const Botan::OID oid(vars.get_req_str("Oid"));
2✔
38

39
         Botan::EC_Group group(p, a, b, Gx, Gy, order, BigInt::one(), oid);
1✔
40

41
         const BigInt Px = vars.get_req_bn("Px");
1✔
42
         const BigInt Py = vars.get_req_bn("Py");
1✔
43

44
         if(const auto public_point = Botan::EC_AffinePoint::from_bigint_xy(group, Px, Py)) {
1✔
45
            return std::make_unique<Botan::GOST_3410_PublicKey>(group, *public_point);
3✔
46
         } else {
47
            throw Test_Error("Failed to load GOST 34.10 public key, invalid x/y coordinates");
×
48
         }
×
49
      }
1✔
50

51
      std::string default_padding(const VarMap& vars) const override { return vars.get_req_str("Hash"); }
2✔
52
};
53

54
class GOST_3410_2001_Signature_Tests final : public PK_Signature_Generation_Test {
55
   public:
56
      GOST_3410_2001_Signature_Tests() :
1✔
57
            PK_Signature_Generation_Test(
58
               "GOST 34.10-2001", "pubkey/gost_3410_sign.vec", "P,A,B,Gx,Gy,Oid,Order,X,Hash,Nonce,Msg,Signature") {}
2✔
59

60
      bool skip_this_test(const std::string& /*header*/, const VarMap& /*vars*/) override {
1✔
61
         return !Botan::EC_Group::supports_application_specific_group();
1✔
62
      }
63

64
      std::unique_ptr<Botan::Private_Key> load_private_key(const VarMap& vars) override {
1✔
65
         const BigInt p = vars.get_req_bn("P");
1✔
66
         const BigInt a = vars.get_req_bn("A");
1✔
67
         const BigInt b = vars.get_req_bn("B");
1✔
68
         const BigInt Gx = vars.get_req_bn("Gx");
1✔
69
         const BigInt Gy = vars.get_req_bn("Gy");
1✔
70
         const BigInt order = vars.get_req_bn("Order");
1✔
71
         const Botan::OID oid(vars.get_req_str("Oid"));
2✔
72

73
         Botan::EC_Group group(p, a, b, Gx, Gy, order, BigInt::one(), oid);
1✔
74

75
         const BigInt x = vars.get_req_bn("X");
1✔
76

77
         return std::make_unique<Botan::GOST_3410_PrivateKey>(this->rng(), group, x);
3✔
78
      }
1✔
79

80
      std::string default_padding(const VarMap& vars) const override { return vars.get_req_str("Hash"); }
2✔
81

82
      std::unique_ptr<Botan::RandomNumberGenerator> test_rng(const std::vector<uint8_t>& nonce) const override {
1✔
83
         return std::make_unique<Fixed_Output_Position_RNG>(nonce, 1, this->rng());
1✔
84
      }
85
};
86

87
class GOST_3410_2001_Keygen_Tests final : public PK_Key_Generation_Test {
×
88
   public:
89
      std::vector<std::string> keygen_params() const override {
1✔
90
         std::vector<std::string> params;
1✔
91
         for(const auto& curve : {"gost_256A", "secp256r1"}) {
3✔
92
            if(Botan::EC_Group::supports_named_group(curve)) {
2✔
93
               params.push_back(curve);
4✔
94
            }
95
         }
96
         return params;
1✔
97
      }
×
98

99
      std::string algo_name() const override { return "GOST-34.10"; }
2✔
100

101
      std::unique_ptr<Botan::Public_Key> public_key_from_raw(std::string_view keygen_params,
2✔
102
                                                             std::string_view /* provider */,
103
                                                             std::span<const uint8_t> raw_pk) const override {
104
         const auto group = Botan::EC_Group(keygen_params);
2✔
105
         const auto public_key = Botan::EC_AffinePoint(group, raw_pk);
2✔
106
         return std::make_unique<Botan::GOST_3410_PublicKey>(group, public_key);
6✔
107
      }
2✔
108
};
109

110
BOTAN_REGISTER_TEST("pubkey", "gost_3410_verify", GOST_3410_2001_Verification_Tests);
111
BOTAN_REGISTER_TEST("pubkey", "gost_3410_sign", GOST_3410_2001_Signature_Tests);
112
BOTAN_REGISTER_TEST("pubkey", "gost_3410_keygen", GOST_3410_2001_Keygen_Tests);
113

114
#endif
115

116
}  // namespace
117

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