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

randombit / botan / 19012754211

02 Nov 2025 01:10PM UTC coverage: 90.677% (+0.006%) from 90.671%
19012754211

push

github

web-flow
Merge pull request #5137 from randombit/jack/clang-tidy-includes

Remove various unused includes flagged by clang-tidy misc-include-cleaner

100457 of 110786 relevant lines covered (90.68%)

12189873.8 hits per line

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

89.74
/src/tests/test_sphincsplus_fors.cpp
1
/*
2
* (C) 2023 Jack Lloyd
3
*     2023 Fabian Albert, René Meusel - Rohde & Schwarz Cybersecurity
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include "tests.h"
9

10
#if defined(BOTAN_HAS_SPHINCS_PLUS_COMMON)
11

12
   #include <botan/assert.h>
13
   #include <botan/hash.h>
14
   #include <botan/sp_parameters.h>
15
   #include <botan/internal/loadstor.h>
16
   #include <botan/internal/sp_address.h>
17
   #include <botan/internal/sp_fors.h>
18
   #include <botan/internal/sp_hash.h>
19

20
namespace Botan_Tests {
21

22
class SPHINCS_Plus_FORS_Test final : public Text_Based_Test {
×
23
   private:
24
      static Botan::Sphincs_Address read_address(std::span<const uint8_t> address_buffer) {
12✔
25
         BOTAN_ASSERT_NOMSG(address_buffer.size() == 32);
12✔
26

27
         std::array<uint32_t, 8> adrs{};
12✔
28
         for(size_t i = 0; i < 8; ++i) {
108✔
29
            adrs[i] = Botan::load_be<uint32_t>(address_buffer.data(), i);
96✔
30
         }
31

32
         return Botan::Sphincs_Address(adrs);
12✔
33
      }
34

35
   public:
36
      SPHINCS_Plus_FORS_Test() :
1✔
37
            Text_Based_Test("pubkey/sphincsplus_fors.vec",
38
                            "SphincsParameterSet,Address,SecretSeed,PublicSeed,PublicKey,Msg,HashSig") {}
2✔
39

40
      bool skip_this_test(const std::string& /*header*/, const VarMap& vars) override {
12✔
41
         auto params = Botan::Sphincs_Parameters::create(vars.get_req_str("SphincsParameterSet"));
24✔
42
         return !params.is_available();
12✔
43
      }
44

45
      Test::Result run_one_test(const std::string& /*header*/, const VarMap& vars) final {
12✔
46
         Test::Result result("SLH-DSA's FORS");
12✔
47

48
         auto params = Botan::Sphincs_Parameters::create(vars.get_req_str("SphincsParameterSet"));
24✔
49

50
         const auto secret_seed = Botan::SphincsSecretSeed(vars.get_req_bin("SecretSeed"));
24✔
51
         const auto public_seed = Botan::SphincsPublicSeed(vars.get_req_bin("PublicSeed"));
12✔
52

53
         const auto hashed_message = Botan::SphincsHashedMessage(vars.get_req_bin("Msg"));
12✔
54

55
         // Depending on the SLH-DSA's configuration the resulting signature is
56
         // hashed either with SHA-3 or SHA-256 to reduce the inner dependencies
57
         // on other hash function modules.
58
         auto hash_algo_spec = [&]() -> std::string {
×
59
            if(params.hash_type() == Botan::Sphincs_Hash_Type::Shake256) {
12✔
60
               return "SHA-3(256)";
6✔
61
            } else {
62
               return "SHA-256";
6✔
63
            }
64
         }();
12✔
65
         auto hash = Botan::HashFunction::create(hash_algo_spec);
12✔
66

67
         if(!hash) {
12✔
68
            result.test_note("Skipping due to missing hash function");
×
69
            return result;
×
70
         }
71

72
         auto hashes = Botan::Sphincs_Hash_Functions::create(params, public_seed);
12✔
73
         Botan::Sphincs_Address address = read_address(vars.get_req_bin("Address"));
24✔
74

75
         Botan::ForsSignature sig(params.fors_signature_bytes());
12✔
76

77
         auto pk = Botan::fors_sign_and_pkgen(sig, hashed_message, secret_seed, address, params, *hashes);
12✔
78

79
         const auto pk_ref = Botan::SphincsTreeNode(vars.get_req_bin("PublicKey"));
12✔
80
         result.test_is_eq("Derived public key", pk, pk_ref);
12✔
81

82
         const auto hashed_sig_ref = Botan::ForsSignature(vars.get_req_bin("HashSig"));
12✔
83
         result.test_is_eq("Signature result", unlock(hash->process(sig)), hashed_sig_ref.get());
48✔
84

85
         auto pk_from_sig = Botan::fors_public_key_from_signature(hashed_message, sig, address, params, *hashes);
12✔
86
         result.test_is_eq("Public key from signature", pk_from_sig, pk);
12✔
87

88
         return result;
12✔
89
      }
120✔
90
};
91

92
BOTAN_REGISTER_TEST("pubkey", "sphincsplus_fors", SPHINCS_Plus_FORS_Test);
93

94
}  // namespace Botan_Tests
95

96
#endif  // BOTAN_HAS_SPHINCS_PLUS_COMMON
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