Botan 3.5.0
Crypto and TLS for C&
Botan::HSS_LMS_Params Class Referencefinal

The HSS-LMS parameters. More...

#include <hss.h>

Classes

class  LMS_LMOTS_Params_Pair
 Represents a pair of LMS and LMOTS parameters associated with one LMS tree layer. More...
 

Public Member Functions

 HSS_LMS_Params (std::string_view algo_params)
 Construct the HSS-LMS parameters form an algorithm parameter string.
 
 HSS_LMS_Params (std::vector< LMS_LMOTS_Params_Pair > lm_lmots_params)
 Construct the HSS-LMS parameters from a vector LMS and LM-OTS parameters.
 
HSS_Level L () const
 Returns the number of layers the HSS tree has.
 
HSS_Sig_Idx max_sig_count () const
 The maximal number of signatures allowed for these HSS parameters.
 
const LMS_LMOTS_Params_Pairparams_at_level (HSS_Level level) const
 Returns the LMS an LM-OTS parameters at the specified level of the HSS tree.
 

Detailed Description

The HSS-LMS parameters.

See RFC 8554 Section 6.

Definition at line 40 of file hss.h.

Constructor & Destructor Documentation

◆ HSS_LMS_Params() [1/2]

Botan::HSS_LMS_Params::HSS_LMS_Params ( std::vector< LMS_LMOTS_Params_Pair > lm_lmots_params)
explicit

Construct the HSS-LMS parameters from a vector LMS and LM-OTS parameters.

Definition at line 77 of file hss.cpp.

77 :
78 m_lms_lmots_params(std::move(lm_lmots_params)), m_max_sig_count(calc_max_sig_count()) {
79 BOTAN_ARG_CHECK(!m_lms_lmots_params.empty() && m_lms_lmots_params.size() <= HSS_MAX_LEVELS,
80 "Invalid number of levels");
81}
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:29

References BOTAN_ARG_CHECK.

◆ HSS_LMS_Params() [2/2]

Botan::HSS_LMS_Params::HSS_LMS_Params ( std::string_view algo_params)
explicit

Construct the HSS-LMS parameters form an algorithm parameter string.

The HSS/LMS instance to use for creating new keys is defined using an algorithm parameter string, i.e. to define which hash function (hash), LMS tree hights (h) and OTS Winternitz coefficient widths (w) to use. The syntax is the following:

HSS-LMS(<hash>,HW(<h>,<w>),HW(<h>,<w>),...)

e.g. 'HSS-LMS(SHA-256,HW(5,1),HW(5,1))' to use SHA-256 in a two-layer HSS instance with a LMS tree height 5 and w=1. The following parameters are allowed (which are specified in RFC 8554 and draft-fluhrer-lms-more-parm-sets-11):

hash: 'SHA-256', 'Truncated(SHA-256,192)', 'SHAKE-256(256)', SHAKE-256(192) h: '5', '10', '15', '20', '25' w: '1', '2', '4', '8'

Note: The selected hash function is also used for seed derivation.

Definition at line 83 of file hss.cpp.

83 {
84 SCAN_Name scan(fmt("HSS-LMS({})", algo_params));
85
86 BOTAN_ARG_CHECK(scan.arg_count() >= 2 && scan.arg_count() <= HSS_MAX_LEVELS + 1, "Invalid number of arguments");
87 std::string hash = scan.arg(0);
88 BOTAN_ARG_CHECK(is_supported_hash_function(hash), "Supported HSS-LMS hash function");
89
90 for(size_t i = 1; i < scan.arg_count(); ++i) {
91 SCAN_Name scan_layer(scan.arg(i));
92 BOTAN_ARG_CHECK(scan_layer.algo_name() == "HW", "Invalid name for layer parameters");
93 BOTAN_ARG_CHECK(scan_layer.arg_count() == 2, "Invalid number of layer parameters");
94 const auto h =
95 checked_cast_to_or_throw<uint8_t, Invalid_Argument>(scan_layer.arg_as_integer(0), "Invalid tree height");
96 const auto w = checked_cast_to_or_throw<uint8_t, Invalid_Argument>(scan_layer.arg_as_integer(1),
97 "Invalid Winternitz parameter");
98 m_lms_lmots_params.push_back({LMS_Params::create_or_throw(hash, h), LMOTS_Params::create_or_throw(hash, w)});
99 }
100 m_max_sig_count = calc_max_sig_count();
101}
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
static LMS_Params create_or_throw(LMS_Algorithm_Type type)
Create the LMS parameters from a known algorithm type.
Definition lms.cpp:112
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53
constexpr RT checked_cast_to_or_throw(AT i, std::string_view error_msg_on_fail)
Definition int_utils.h:95

References Botan::SCAN_Name::algo_name(), Botan::SCAN_Name::arg(), Botan::SCAN_Name::arg_as_integer(), Botan::SCAN_Name::arg_count(), BOTAN_ARG_CHECK, Botan::checked_cast_to_or_throw(), Botan::LMOTS_Params::create_or_throw(), Botan::LMS_Params::create_or_throw(), and Botan::fmt().

Member Function Documentation

◆ L()

HSS_Level Botan::HSS_LMS_Params::L ( ) const
inline

Returns the number of layers the HSS tree has.

Definition at line 102 of file hss.h.

102{ return checked_cast_to<HSS_Level>(m_lms_lmots_params.size()); }
constexpr RT checked_cast_to(AT i)
Definition int_utils.h:109

Referenced by Botan::HSS_LMS_PrivateKeyInternal::sign(), Botan::HSS_Signature::size(), and Botan::HSS_LMS_PrivateKeyInternal::to_bytes().

◆ max_sig_count()

HSS_Sig_Idx Botan::HSS_LMS_Params::max_sig_count ( ) const
inline

The maximal number of signatures allowed for these HSS parameters.

Definition at line 107 of file hss.h.

107{ return m_max_sig_count; }

◆ params_at_level()

const LMS_LMOTS_Params_Pair & Botan::HSS_LMS_Params::params_at_level ( HSS_Level level) const
inline

Returns the LMS an LM-OTS parameters at the specified level of the HSS tree.

Definition at line 97 of file hss.h.

97{ return m_lms_lmots_params.at(level.get()); }

References Botan::detail::Strong_Base< T >::get().

Referenced by Botan::HSS_LMS_PrivateKeyInternal::hss_derive_root_lms_private_key(), Botan::HSS_LMS_PrivateKeyInternal::HSS_LMS_PrivateKeyInternal(), Botan::HSS_LMS_PrivateKeyInternal::sign(), Botan::HSS_Signature::size(), and Botan::HSS_LMS_PrivateKeyInternal::to_bytes().


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