Botan 3.11.0
Crypto and TLS for C&
Botan::LMS_PrivateKey Class Referencefinal

Representation of an LMS Private key. More...

#include <lms.h>

Inheritance diagram for Botan::LMS_PrivateKey:
Botan::LMS_Instance

Public Member Functions

const LMS_Identifieridentifier () const
 The identifier of this LMS tree ('I' in RFC 8554).
const LMOTS_Paramslmots_params () const
 The LMOTS parameters used for OTS instances of this LMS instance.
const LMS_Paramslms_params () const
 The LMS parameters for this LMS instance.
 LMS_PrivateKey (LMS_Params lms_params, LMOTS_Params lmots_params, LMS_Identifier I, LMS_Seed seed)
 Construct storing the LMS instance data and the secret seed.
const LMS_Seedseed () const
 The secret seed used for LMOTS' WOTS chain input creation (RFC 8554 Appendix A).
LMS_PublicKey sign_and_get_pk (StrongSpan< LMS_Signature_Bytes > out_sig, LMS_Tree_Node_Idx q, const LMS_Message &msg) const
 Sign a message using an LMS_PrivateKey and the used leaf index (RFC 8554 5.4.1).

Detailed Description

Representation of an LMS Private key.

Contains the secret seed used for OTS key derivation as described in RFC 8554 Appendix A.

Definition at line 192 of file lms.h.

Constructor & Destructor Documentation

◆ LMS_PrivateKey()

Botan::LMS_PrivateKey::LMS_PrivateKey ( LMS_Params lms_params,
LMOTS_Params lmots_params,
LMS_Identifier I,
LMS_Seed seed )
inline

Construct storing the LMS instance data and the secret seed.

Definition at line 197 of file lms.h.

197 :
198 LMS_Instance(std::move(lms_params), std::move(lmots_params), std::move(I)), m_seed(std::move(seed)) {}
const LMS_Params & lms_params() const
The LMS parameters for this LMS instance.
Definition lms.h:166
const LMOTS_Params & lmots_params() const
The LMOTS parameters used for OTS instances of this LMS instance.
Definition lms.h:171
LMS_Instance(LMS_Params lms_params, LMOTS_Params lmots_params, LMS_Identifier identifier)
Constructor storing the provided LMS data.
Definition lms.h:158
const LMS_Seed & seed() const
The secret seed used for LMOTS' WOTS chain input creation (RFC 8554 Appendix A).
Definition lms.h:203

References Botan::LMS_Instance::lmots_params(), Botan::LMS_Instance::LMS_Instance(), Botan::LMS_Instance::lms_params(), and seed().

Member Function Documentation

◆ identifier()

const LMS_Identifier & Botan::LMS_Instance::identifier ( ) const
inlineinherited

The identifier of this LMS tree ('I' in RFC 8554).

Definition at line 176 of file lms.h.

176{ return m_identifier; }

Referenced by LMS_Instance(), Botan::LMS_PublicKey::LMS_PublicKey(), Botan::LMS_PrivateKey::sign_and_get_pk(), and Botan::LMS_PublicKey::to_bytes().

◆ lmots_params()

const LMOTS_Params & Botan::LMS_Instance::lmots_params ( ) const
inlineinherited

◆ lms_params()

◆ seed()

const LMS_Seed & Botan::LMS_PrivateKey::seed ( ) const
inline

The secret seed used for LMOTS' WOTS chain input creation (RFC 8554 Appendix A).

Definition at line 203 of file lms.h.

203{ return m_seed; }

Referenced by LMS_PrivateKey(), and sign_and_get_pk().

◆ sign_and_get_pk()

LMS_PublicKey Botan::LMS_PrivateKey::sign_and_get_pk ( StrongSpan< LMS_Signature_Bytes > out_sig,
LMS_Tree_Node_Idx q,
const LMS_Message & msg ) const

Sign a message using an LMS_PrivateKey and the used leaf index (RFC 8554 5.4.1).

The signature is written in the provided buffer. The LMS_PublicKey associated with the given private key is returned.

Definition at line 249 of file lms.cpp.

251 {
252 // Pre-alloc space for the signature
253 BOTAN_ARG_CHECK(out_sig.size() == LMS_Signature::size(lms_params(), lmots_params()), "Invalid output buffer size");
254
255 BufferStuffer sig_stuffer(out_sig);
256 sig_stuffer.append(store_be(q));
257 const LMOTS_Private_Key lmots_sk(lmots_params(), identifier(), q, seed());
258 lmots_sk.sign(sig_stuffer.next<LMOTS_Signature_Bytes>(LMOTS_Signature::size(lmots_params())), msg);
259 sig_stuffer.append(store_be(lms_params().algorithm_type()));
260 const auto auth_path_buffer = sig_stuffer.next<LMS_AuthenticationPath>(lms_params().m() * lms_params().h());
261
262 BOTAN_ASSERT_NOMSG(sig_stuffer.full());
263
264 const TreeAddress lms_tree_address(lms_params().h());
265 LMS_Tree_Node pk_buffer(lms_params().m());
266 lms_treehash(StrongSpan<LMS_Tree_Node>(pk_buffer.get()), auth_path_buffer, q, *this);
267
268 CT::unpoison(pk_buffer);
269 return LMS_PublicKey(lms_params(), lmots_params(), identifier(), std::move(pk_buffer));
270}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:75
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
static size_t size(const LMOTS_Params &params)
The expected size of the signature.
Definition lm_ots.h:210
const LMS_Identifier & identifier() const
The identifier of this LMS tree ('I' in RFC 8554).
Definition lms.h:176
size_t m() const
Returns the number of bytes associated with each node.
Definition lms.h:121
uint8_t h() const
Returns the height of the LMS tree.
Definition lms.h:116
static size_t size(const LMS_Params &lms_params, const LMOTS_Params &lmots_params)
Definition lms.cpp:428
constexpr void unpoison(const T *p, size_t n)
Definition ct_utils.h:67
Strong< std::vector< uint8_t >, struct LMS_Tree_Node_ > LMS_Tree_Node
A node with the LMS tree.
Definition lms.h:79
Strong< std::vector< uint8_t >, struct LMS_AuthenticationPath_ > LMS_AuthenticationPath
The authentication path of an LMS signature.
Definition lms.h:74
constexpr auto store_be(ParamTs &&... params)
Definition loadstor.h:745
Strong< std::vector< uint8_t >, struct LMOTS_Signature_Bytes_ > LMOTS_Signature_Bytes
Byte vector of an LM-OTS signature.
Definition lm_ots.h:43

References Botan::BufferStuffer::append(), BOTAN_ARG_CHECK, BOTAN_ASSERT_NOMSG, Botan::BufferStuffer::full(), Botan::detail::Strong_Base< T >::get(), Botan::LMS_Params::h(), Botan::LMS_Instance::identifier(), Botan::LMS_Instance::lmots_params(), Botan::LMS_Instance::lms_params(), Botan::LMS_Params::m(), Botan::BufferStuffer::next(), seed(), Botan::LMOTS_Private_Key::sign(), Botan::LMOTS_Signature::size(), Botan::LMS_Signature::size(), Botan::StrongSpan< T >::size(), Botan::store_be(), and Botan::CT::unpoison().


The documentation for this class was generated from the following files: