Botan 3.5.0
Crypto and TLS for C&
Botan::LMS_PrivateKey Class Reference

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 189 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 194 of file lms.h.

194 :
195 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:163
const LMOTS_Params & lmots_params() const
The LMOTS parameters used for OTS instances of this LMS instance.
Definition lms.h:168
LMS_Instance(LMS_Params lms_params, LMOTS_Params lmots_params, LMS_Identifier identifier)
Constructor storing the provided LMS data.
Definition lms.h:155
const LMS_Seed & seed() const
The secret seed used for LMOTS' WOTS chain input creation (RFC 8554 Appendix A)
Definition lms.h:200

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 173 of file lms.h.

173{ return m_identifier; }

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

◆ lmots_params()

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

The LMOTS parameters used for OTS instances of this LMS instance.

Definition at line 168 of file lms.h.

168{ return m_lmots_params; }

Referenced by Botan::LMS_PublicKey::from_bytes_or_throw(), sign_and_get_pk(), Botan::LMS_PublicKey::to_bytes(), Botan::HSS_LMS_PublicKeyInternal::verify_signature(), and Botan::LMS_PublicKey::verify_signature().

◆ lms_params()

const LMS_Params & Botan::LMS_Instance::lms_params ( ) const
inlineinherited

◆ 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 200 of file lms.h.

200{ return m_seed; }

Referenced by 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 241 of file lms.cpp.

243 {
244 // Pre-alloc space for the signature
245 BOTAN_ARG_CHECK(out_sig.size() == LMS_Signature::size(lms_params(), lmots_params()), "Invalid output buffer size");
246
247 BufferStuffer sig_stuffer(out_sig);
248 sig_stuffer.append(store_be(q));
249 const LMOTS_Private_Key lmots_sk(lmots_params(), identifier(), q, seed());
250 lmots_sk.sign(sig_stuffer.next<LMOTS_Signature_Bytes>(LMOTS_Signature::size(lmots_params())), msg);
251 sig_stuffer.append(store_be(lms_params().algorithm_type()));
252 const auto auth_path_buffer = sig_stuffer.next<LMS_AuthenticationPath>(lms_params().m() * lms_params().h());
253
254 BOTAN_ASSERT_NOMSG(sig_stuffer.full());
255
256 TreeAddress lms_tree_address(lms_params().h());
257 LMS_Tree_Node pk_buffer(lms_params().m());
258 lms_treehash(StrongSpan<LMS_Tree_Node>(pk_buffer.get()), auth_path_buffer, q, *this);
259
260 return LMS_PublicKey(lms_params(), lmots_params(), identifier(), std::move(pk_buffer));
261}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:59
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:29
static size_t size(const LMOTS_Params &params)
The expected size of the signature.
Definition lm_ots.h:207
const LMS_Identifier & identifier() const
The identifier of this LMS tree ('I' in RFC 8554)
Definition lms.h:173
size_t m() const
Returns the number of bytes associated with each node.
Definition lms.h:118
uint8_t h() const
Returns the height of the LMS tree.
Definition lms.h:113
static size_t size(const LMS_Params &lms_params, const LMOTS_Params &lmots_params)
Definition lms.cpp:418
Strong< std::vector< uint8_t >, struct LMS_Tree_Node_ > LMS_Tree_Node
A node with the LMS tree.
Definition lms.h:76
Strong< std::vector< uint8_t >, struct LMS_AuthenticationPath_ > LMS_AuthenticationPath
The authentication path of an LMS signature.
Definition lms.h:71
constexpr auto store_be(ParamTs &&... params)
Definition loadstor.h:707
Strong< std::vector< uint8_t >, struct LMOTS_Signature_Bytes_ > LMOTS_Signature_Bytes
Byte vector of an LM-OTS signature.
Definition lm_ots.h:40

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(), and Botan::store_be().


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