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

randombit / botan / 21712952425

05 Feb 2026 01:16PM UTC coverage: 90.076% (+0.005%) from 90.071%
21712952425

Pull #5287

github

web-flow
Merge 1b320c06e into 8c9623340
Pull Request #5287: Split out BufferSlicer and BufferStuffer to their own headers

102242 of 113507 relevant lines covered (90.08%)

11534589.25 hits per line

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

96.55
/src/tests/test_lms.cpp
1
/*
2
* (C) 2023 Jack Lloyd
3
*     2023 Fabian Albert, Philippe Lieser - Rohde & Schwarz Cybersecurity
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
#include "tests.h"
8

9
#if defined(BOTAN_HAS_HSS_LMS)
10

11
   #include <botan/hash.h>
12
   #include <botan/internal/buffer_slicer.h>
13
   #include <botan/internal/lms.h>
14

15
namespace Botan_Tests {
16

17
namespace {
18

19
/**
20
 * @brief Test the LMS logic of HSS-LMS
21
 */
22
class LMS_Test final : public Text_Based_Test {
×
23
   public:
24
      LMS_Test() : Text_Based_Test("pubkey/lms.vec", "Seed,Msg,q,PublicKey,HashSig") {}
2✔
25

26
      bool skip_this_test(const std::string& /*header*/, const VarMap& vars) override {
3✔
27
         BOTAN_UNUSED(vars);
3✔
28
         return false;
3✔
29
      }
30

31
      Test::Result run_one_test(const std::string& /*header*/, const VarMap& vars) final {
3✔
32
         Test::Result result("LMS");
3✔
33

34
         const auto seed = Botan::LMS_Seed(vars.get_req_bin("Seed"));
6✔
35
         const auto msg = Botan::LMS_Message(vars.get_req_bin("Msg"));
3✔
36
         const auto q = Botan::LMS_Tree_Node_Idx(vars.get_req_u32("q"));
3✔
37
         const auto pk_ref = vars.get_req_bin("PublicKey");
3✔
38
         // To safe file space the signature is only stored in hashed form
39
         const auto hashed_sig_ref = vars.get_req_bin("HashSig");
3✔
40

41
         auto hash = Botan::HashFunction::create("SHA-256");
3✔
42

43
         auto lms_pk_ref_slicer = Botan::BufferSlicer(pk_ref);
3✔
44
         const Botan::LMS_PublicKey lms_pk_ref = Botan::LMS_PublicKey::from_bytes_or_throw(lms_pk_ref_slicer);
3✔
45

46
         // Test public key creation
47
         auto lms_sk =
3✔
48
            Botan::LMS_PrivateKey(lms_pk_ref.lms_params(), lms_pk_ref.lmots_params(), lms_pk_ref.identifier(), seed);
6✔
49
         auto pub_key = Botan::LMS_PublicKey(lms_sk);
3✔
50

51
         result.test_is_eq("Public key generation", pub_key.to_bytes(), pk_ref);
6✔
52

53
         // Test signature creation and verification
54
         auto sk =
3✔
55
            Botan::LMS_PrivateKey(lms_pk_ref.lms_params(), lms_pk_ref.lmots_params(), lms_pk_ref.identifier(), seed);
6✔
56
         Botan::LMS_Signature_Bytes sig(Botan::LMS_Signature::size(lms_pk_ref.lms_params(), lms_pk_ref.lmots_params()));
3✔
57
         auto pk_from_sig = sk.sign_and_get_pk(sig, q, msg);
3✔
58
         result.test_is_eq("Signature creation", hash->process<std::vector<uint8_t>>(sig), hashed_sig_ref);
6✔
59

60
         auto sig_slicer = Botan::BufferSlicer(sig);
3✔
61
         auto sig_obj = Botan::LMS_Signature::from_bytes_or_throw(sig_slicer);
3✔
62
         result.confirm("Signature verification", pub_key.verify_signature(msg, sig_obj));
6✔
63

64
         return result;
6✔
65
      }
21✔
66
};
67

68
BOTAN_REGISTER_TEST("pubkey", "lms", LMS_Test);
69

70
}  // namespace
71
}  // namespace Botan_Tests
72

73
#endif  // BOTAN_HAS_HSS_LMS
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