Botan 3.14.1
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_Pair & params_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 42 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 99 of file hss.cpp.

99 :
100 m_lms_lmots_params(std::move(lm_lmots_params)), m_max_sig_count(calc_max_sig_count()) {
101 BOTAN_ARG_CHECK(!m_lms_lmots_params.empty() && m_lms_lmots_params.size() <= HSS_MAX_LEVELS,
102 "Invalid number of levels");
103
104 const auto& hash_name = m_lms_lmots_params.front().lms_params().hash_name();
105 for(const auto& param : m_lms_lmots_params) {
106 BOTAN_ARG_CHECK(param.lms_params().hash_name() == hash_name && param.lmots_params().hash_name() == hash_name,
107 "Inconsistent hash functions are not allowed");
108 }
109}
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33

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 height (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 111 of file hss.cpp.

111 : m_max_sig_count(0) {
112 const auto wrap_in_hss_lms = [&]() {
113 if(algo_params.starts_with("HSS-LMS(")) {
114 return std::string(algo_params);
115 } else {
116 return fmt("HSS-LMS({})", algo_params);
117 }
118 }();
119 const AlgorithmSpec spec(wrap_in_hss_lms);
120
121 const auto m = spec.match("HSS-LMS({hash},{layer}...)");
122 BOTAN_ARG_CHECK(m.has_value(), "Invalid HSS-LMS parameters");
123 const auto layers = m->rest("layer");
124 BOTAN_ARG_CHECK(layers.size() <= HSS_MAX_LEVELS, "Invalid number of layer arguments");
125 const std::string hash(m->str("hash"));
126 BOTAN_ARG_CHECK(is_supported_hash_function(hash), "Supported HSS-LMS hash function");
127
128 for(const auto& layer : layers) {
129 const auto lm = layer.match("HW({h:int},{w:int})");
130 BOTAN_ARG_CHECK(lm.has_value(), "Invalid layer parameters");
131 const auto h = checked_cast_to_or_throw<uint8_t, Invalid_Argument>(lm->integer("h"), "Invalid tree height");
132 const auto w =
133 checked_cast_to_or_throw<uint8_t, Invalid_Argument>(lm->integer("w"), "Invalid Winternitz parameter");
134 m_lms_lmots_params.push_back({LMS_Params::create_or_throw(hash, h), LMOTS_Params::create_or_throw(hash, w)});
135 }
136 m_max_sig_count = calc_max_sig_count();
137}
static LMOTS_Params create_or_throw(LMOTS_Algorithm_Type type)
Create the LM-OTS parameters from a known algorithm type.
Definition lm_ots.cpp:131
static LMS_Params create_or_throw(LMS_Algorithm_Type type)
Create the LMS parameters from a known algorithm type.
Definition lms.cpp:145
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:91

References BOTAN_ARG_CHECK, Botan::checked_cast_to_or_throw(), Botan::LMOTS_Params::create_or_throw(), Botan::LMS_Params::create_or_throw(), Botan::fmt(), and Botan::AlgorithmSpec::match().

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 104 of file hss.h.

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

References Botan::checked_cast_to().

Referenced by Botan::HSS_LMS_PublicKeyInternal::create(), 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 109 of file hss.h.

109{ 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 99 of file hss.h.

99{ 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::sign(), Botan::HSS_Signature::size(), and Botan::HSS_LMS_PrivateKeyInternal::to_bytes().


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