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

Container for LMS Signature data. More...

#include <lms.h>

Public Member Functions

StrongSpan< const LMS_AuthenticationPathauth_path () const
 The authentication path bytes given by the signature.
 
const LMOTS_Signaturelmots_sig () const
 The LMOTS signature object containing the parsed LMOTS signature bytes contained in the LMS signature.
 
LMS_Algorithm_Type lms_type () const
 The LMS algorithm type given by the signature.
 
LMS_Tree_Node_Idx q () const
 The index of the signing leaf given by the signature.
 

Static Public Member Functions

static LMS_Signature from_bytes_or_throw (BufferSlicer &slicer)
 Parse the bytes of a lms signature into a LMS Signature object.
 
static size_t size (const LMS_Params &lms_params, const LMOTS_Params &lmots_params)
 

Detailed Description

Container for LMS Signature data.

Contains a method for secure signature parsing.

Definition at line 290 of file lms.h.

Member Function Documentation

◆ auth_path()

StrongSpan< const LMS_AuthenticationPath > Botan::LMS_Signature::auth_path ( ) const
inline

The authentication path bytes given by the signature.

('path[0] || ... || path[h-1]' in RFC 8554 5.4)

Definition at line 322 of file lms.h.

322{ return m_auth_path; }

Referenced by from_bytes_or_throw().

◆ from_bytes_or_throw()

LMS_Signature Botan::LMS_Signature::from_bytes_or_throw ( BufferSlicer & slicer)
static

Parse the bytes of a lms signature into a LMS Signature object.

Parameters
slicerA BufferSlicer object at the position of the LMS_Signature to parse
Returns
LMS_Signature object
Exceptions
Decoding_ErrorIf parsing the signature fails.

Definition at line 316 of file lms.cpp.

316 {
317 size_t total_remaining_bytes = slicer.remaining();
318 // Alg. 6a 1. (next 4 bytes are checked in LMOTS_Signature::from_bytes_or_throw)
319 if(total_remaining_bytes < sizeof(LMS_Tree_Node_Idx)) {
320 throw Decoding_Error("Too few signature bytes while parsing LMS signature.");
321 }
322 // Alg. 6a 2.a.
323 auto q = load_be<LMS_Tree_Node_Idx>(slicer.take<sizeof(LMS_Tree_Node_Idx)>());
324
325 // Alg. 6a 2.b.-e.
327 LMOTS_Params lmots_params = LMOTS_Params::create_or_throw(lmots_sig.algorithm_type());
328
329 if(slicer.remaining() < sizeof(LMS_Algorithm_Type)) {
330 throw Decoding_Error("Too few signature bytes while parsing LMS signature.");
331 }
332 // Alg. 6a 2.f.
333 auto lms_type = load_be<LMS_Algorithm_Type>(slicer.take<sizeof(LMS_Algorithm_Type)>());
334 // Alg. 6a 2.h.
335 LMS_Params lms_params = LMS_Params::create_or_throw(lms_type);
336 // Alg. 6a 2.i. (signature is not exactly [...] bytes long)
337 if(total_remaining_bytes < size(lms_params, lmots_params)) {
338 throw Decoding_Error("Too few signature bytes while parsing LMS signature.");
339 }
340
341 // Alg. 6a 2.j.
342 auto auth_path = slicer.copy<LMS_AuthenticationPath>(lms_params.m() * lms_params.h());
343
344 return LMS_Signature(q, std::move(lmots_sig), lms_type, std::move(auth_path));
345}
static LMOTS_Params create_or_throw(LMOTS_Algorithm_Type type)
Create the LM-OTS parameters from a known algorithm type.
Definition lm_ots.cpp:99
LMOTS_Algorithm_Type algorithm_type() const
Returns the LM-OTS algorithm type.
Definition lm_ots.h:192
static LMOTS_Signature from_bytes_or_throw(BufferSlicer &slicer)
Parse a LM-OTS signature.
Definition lm_ots.cpp:234
static LMS_Params create_or_throw(LMS_Algorithm_Type type)
Create the LMS parameters from a known algorithm type.
Definition lms.cpp:112
const LMOTS_Signature & lmots_sig() const
The LMOTS signature object containing the parsed LMOTS signature bytes contained in the LMS signature...
Definition lms.h:310
LMS_Tree_Node_Idx q() const
The index of the signing leaf given by the signature.
Definition lms.h:304
LMS_Algorithm_Type lms_type() const
The LMS algorithm type given by the signature.
Definition lms.h:315
StrongSpan< const LMS_AuthenticationPath > auth_path() const
The authentication path bytes given by the signature.
Definition lms.h:322
static size_t size(const LMS_Params &lms_params, const LMOTS_Params &lmots_params)
Definition lms.cpp:418
LMS_Algorithm_Type
Enum of available LMS algorithm types.
Definition lms.h:29
Strong< std::vector< uint8_t >, struct LMS_AuthenticationPath_ > LMS_AuthenticationPath
The authentication path of an LMS signature.
Definition lms.h:71
Strong< uint32_t, struct LMS_Tree_Node_Idx_, EnableArithmeticWithPlainNumber > LMS_Tree_Node_Idx
The index of a node within a specific LMS tree layer.
Definition lm_ots.h:45
constexpr auto load_be(ParamTs &&... params)
Definition loadstor.h:467

References Botan::LMOTS_Signature::algorithm_type(), auth_path(), Botan::BufferSlicer::copy(), Botan::LMOTS_Params::create_or_throw(), Botan::LMS_Params::create_or_throw(), Botan::LMOTS_Signature::from_bytes_or_throw(), Botan::LMS_Params::h(), lmots_sig(), lms_type(), Botan::load_be(), Botan::LMS_Params::m(), q(), Botan::BufferSlicer::remaining(), size(), and Botan::BufferSlicer::take().

Referenced by Botan::HSS_Signature::from_bytes_or_throw().

◆ lmots_sig()

const LMOTS_Signature & Botan::LMS_Signature::lmots_sig ( ) const
inline

The LMOTS signature object containing the parsed LMOTS signature bytes contained in the LMS signature.

Definition at line 310 of file lms.h.

310{ return m_lmots_sig; }

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

◆ lms_type()

LMS_Algorithm_Type Botan::LMS_Signature::lms_type ( ) const
inline

The LMS algorithm type given by the signature.

Definition at line 315 of file lms.h.

315{ return m_lms_type; }

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

◆ q()

LMS_Tree_Node_Idx Botan::LMS_Signature::q ( ) const
inline

The index of the signing leaf given by the signature.

Definition at line 304 of file lms.h.

304{ return m_q; }

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

◆ size()

size_t Botan::LMS_Signature::size ( const LMS_Params & lms_params,
const LMOTS_Params & lmots_params )
static
Returns
size_t The expected size of the signature.

Definition at line 418 of file lms.cpp.

418 {
419 return sizeof(uint32_t) + LMOTS_Signature::size(lmots_params) + sizeof(uint32_t) + lms_params.h() * lms_params.m();
420}
static size_t size(const LMOTS_Params &params)
The expected size of the signature.
Definition lm_ots.h:207

References Botan::LMS_Params::h(), Botan::LMS_Params::m(), and Botan::LMOTS_Signature::size().

Referenced by from_bytes_or_throw(), Botan::HSS_LMS_PrivateKeyInternal::sign(), Botan::LMS_PrivateKey::sign_and_get_pk(), and Botan::HSS_Signature::size().


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