• 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_lmots.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/lm_ots.h>
14

15
namespace Botan_Tests {
16

17
namespace {
18

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

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

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

34
         const auto lmots_type_id = vars.get_req_u32("TypeId");
4✔
35
         const auto seed = Botan::LMS_Seed(vars.get_req_bin("Seed"));
8✔
36
         const auto identifier = Botan::LMS_Identifier(vars.get_req_bin("I"));
4✔
37
         const auto q = Botan::LMS_Tree_Node_Idx(vars.get_req_u32("q"));
4✔
38
         const auto msg = Botan::LMS_Message(vars.get_req_bin("Msg"));
4✔
39
         const auto pk_ref = Botan::LMOTS_K(vars.get_req_bin("PublicKey"));
4✔
40
         // To safe file space the signature is only stored in hashed form
41
         const auto sig_ref = vars.get_req_bin("HashSig");
4✔
42

43
         auto hash = Botan::HashFunction::create("SHA-256");
4✔
44

45
         auto type = static_cast<Botan::LMOTS_Algorithm_Type>(lmots_type_id);
4✔
46
         auto params = Botan::LMOTS_Params::create_or_throw(type);
4✔
47

48
         // Test private/public OTS key creation
49
         auto sk = Botan::LMOTS_Private_Key(params, identifier, q, seed);
4✔
50
         const auto pk = Botan::LMOTS_Public_Key(sk);
4✔
51
         result.test_is_eq("Public key generation", pk.K(), pk_ref);
4✔
52

53
         // Test signature creation
54
         Botan::LMOTS_Signature_Bytes sig(Botan::LMOTS_Signature::size(params));
4✔
55
         sk.sign(sig, msg);
4✔
56
         result.test_is_eq("Signature generation", hash->process<std::vector<uint8_t>>(sig), sig_ref);
8✔
57

58
         // Test create pubkey from signature
59
         auto sig_slicer = Botan::BufferSlicer(sig);
4✔
60
         auto sig_obj = Botan::LMOTS_Signature::from_bytes_or_throw(sig_slicer);
4✔
61
         const Botan::LMOTS_K pk_from_sig = Botan::lmots_compute_pubkey_from_sig(sig_obj, msg, identifier, q);
4✔
62
         result.test_is_eq("Public key from signature", pk_from_sig, pk_ref);
4✔
63

64
         return result;
4✔
65
      }
32✔
66
};
67

68
BOTAN_REGISTER_TEST("pubkey", "lmots", LMOTS_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