Botan 3.6.1
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 293 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 325 of file lms.h.

325{ 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 317 of file lms.cpp.

317 {
318 size_t total_remaining_bytes = slicer.remaining();
319 // Alg. 6a 1. (next 4 bytes are checked in LMOTS_Signature::from_bytes_or_throw)
320 if(total_remaining_bytes < sizeof(LMS_Tree_Node_Idx)) {
321 throw Decoding_Error("Too few signature bytes while parsing LMS signature.");
322 }
323 // Alg. 6a 2.a.
324 auto q = load_be<LMS_Tree_Node_Idx>(slicer.take<sizeof(LMS_Tree_Node_Idx)>());
325
326 // Alg. 6a 2.b.-e.
328 LMOTS_Params lmots_params = LMOTS_Params::create_or_throw(lmots_sig.algorithm_type());
329
330 if(slicer.remaining() < sizeof(LMS_Algorithm_Type)) {
331 throw Decoding_Error("Too few signature bytes while parsing LMS signature.");
332 }
333 // Alg. 6a 2.f.
334 auto lms_type = load_be<LMS_Algorithm_Type>(slicer.take<sizeof(LMS_Algorithm_Type)>());
335 // Alg. 6a 2.h.
336 LMS_Params lms_params = LMS_Params::create_or_throw(lms_type);
337 // Alg. 6a 2.i. (signature is not exactly [...] bytes long)
338 if(total_remaining_bytes < size(lms_params, lmots_params)) {
339 throw Decoding_Error("Too few signature bytes while parsing LMS signature.");
340 }
341
342 // Alg. 6a 2.j.
343 auto auth_path = slicer.copy<LMS_AuthenticationPath>(lms_params.m() * lms_params.h());
344
345 return LMS_Signature(q, std::move(lmots_sig), lms_type, std::move(auth_path));
346}
static LMOTS_Params create_or_throw(LMOTS_Algorithm_Type type)
Create the LM-OTS parameters from a known algorithm type.
Definition lm_ots.cpp:100
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:235
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:313
LMS_Tree_Node_Idx q() const
The index of the signing leaf given by the signature.
Definition lms.h:307
LMS_Algorithm_Type lms_type() const
The LMS algorithm type given by the signature.
Definition lms.h:318
StrongSpan< const LMS_AuthenticationPath > auth_path() const
The authentication path bytes given by the signature.
Definition lms.h:325
static size_t size(const LMS_Params &lms_params, const LMOTS_Params &lmots_params)
Definition lms.cpp:419
LMS_Algorithm_Type
Enum of available LMS algorithm types.
Definition lms.h:30
Strong< std::vector< uint8_t >, struct LMS_AuthenticationPath_ > LMS_AuthenticationPath
The authentication path of an LMS signature.
Definition lms.h:72
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:530

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

313{ 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 318 of file lms.h.

318{ 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 307 of file lms.h.

307{ 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 419 of file lms.cpp.

419 {
420 return sizeof(uint32_t) + LMOTS_Signature::size(lmots_params) + sizeof(uint32_t) + lms_params.h() * lms_params.m();
421}
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: