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

randombit / botan / 21753596263

06 Feb 2026 02:13PM UTC coverage: 90.063% (-0.01%) from 90.073%
21753596263

Pull #5289

github

web-flow
Merge 587099284 into 8ea0ca252
Pull Request #5289: Further misc header reductions, forward declarations, etc

102237 of 113517 relevant lines covered (90.06%)

11402137.11 hits per line

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

94.44
/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 "test_rng.h"
12
   #include <botan/ec_group.h>
13
   #include <botan/gost_3410.h>
14
#endif
15

16
namespace Botan_Tests {
17

18
namespace {
19

20
#if defined(BOTAN_HAS_GOST_34_10_2001)
21

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

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

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

41
         const Botan::EC_Group group(p, a, b, Gx, Gy, order, BigInt::one(), oid);
1✔
42

43
         const BigInt Px = vars.get_req_bn("Px");
1✔
44
         const BigInt Py = vars.get_req_bn("Py");
1✔
45

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

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

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

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

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

75
         const Botan::EC_Group group(p, a, b, Gx, Gy, order, BigInt::one(), oid);
1✔
76

77
         const BigInt x = vars.get_req_bn("X");
1✔
78

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

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

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

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

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

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

112
BOTAN_REGISTER_TEST("pubkey", "gost_3410_verify", GOST_3410_2001_Verification_Tests);
113
BOTAN_REGISTER_TEST("pubkey", "gost_3410_sign", GOST_3410_2001_Signature_Tests);
114
BOTAN_REGISTER_TEST("pubkey", "gost_3410_keygen", GOST_3410_2001_Keygen_Tests);
115

116
#endif
117

118
}  // namespace
119

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