Botan 3.11.0
Crypto and TLS for C&
Botan::LMS_Params Class Referencefinal

The LMS parameters. More...

#include <lms.h>

Public Member Functions

LMS_Algorithm_Type algorithm_type () const
 Returns the LMS algorithm type.
uint8_t h () const
 Returns the height of the LMS tree.
std::unique_ptr< HashFunctionhash () const
 Construct a new hash instance for the LMS instance.
const std::string & hash_name () const
 Returns the name of the hash function to use.
size_t m () const
 Returns the number of bytes associated with each node.

Static Public Member Functions

static LMS_Params create_or_throw (LMS_Algorithm_Type type)
 Create the LMS parameters from a known algorithm type.
static LMS_Params create_or_throw (std::string_view hash_name, uint8_t h)
 Create the LMS parameters from a hash function and tree height.

Detailed Description

The LMS parameters.

See RFC 8554 Section 5.1.

Definition at line 91 of file lms.h.

Member Function Documentation

◆ algorithm_type()

LMS_Algorithm_Type Botan::LMS_Params::algorithm_type ( ) const
inline

Returns the LMS algorithm type.

Definition at line 111 of file lms.h.

111{ return m_algorithm_type; }

◆ create_or_throw() [1/2]

LMS_Params Botan::LMS_Params::create_or_throw ( LMS_Algorithm_Type type)
static

Create the LMS parameters from a known algorithm type.

Exceptions
Decoding_ErrorIf the algorithm type is unknown

Definition at line 120 of file lms.cpp.

120 {
121 auto [hash_name, height] = [](const LMS_Algorithm_Type& lms_type) -> std::pair<std::string_view, uint8_t> {
122 switch(lms_type) {
124 return {"SHA-256", static_cast<uint8_t>(5)};
126 return {"SHA-256", static_cast<uint8_t>(10)};
128 return {"SHA-256", static_cast<uint8_t>(15)};
130 return {"SHA-256", static_cast<uint8_t>(20)};
132 return {"SHA-256", static_cast<uint8_t>(25)};
134 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(5)};
136 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(10)};
138 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(15)};
140 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(20)};
142 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(25)};
144 return {"SHAKE-256(256)", static_cast<uint8_t>(5)};
146 return {"SHAKE-256(256)", static_cast<uint8_t>(10)};
148 return {"SHAKE-256(256)", static_cast<uint8_t>(15)};
150 return {"SHAKE-256(256)", static_cast<uint8_t>(20)};
152 return {"SHAKE-256(256)", static_cast<uint8_t>(25)};
154 return {"SHAKE-256(192)", static_cast<uint8_t>(5)};
156 return {"SHAKE-256(192)", static_cast<uint8_t>(10)};
158 return {"SHAKE-256(192)", static_cast<uint8_t>(15)};
160 return {"SHAKE-256(192)", static_cast<uint8_t>(20)};
162 return {"SHAKE-256(192)", static_cast<uint8_t>(25)};
163 default:
164 throw Decoding_Error("Unsupported LMS algorithm type");
165 }
166 }(type);
167
168 return LMS_Params(type, hash_name, height);
169}
const std::string & hash_name() const
Returns the name of the hash function to use.
Definition lms.h:126
LMS_Algorithm_Type
Enum of available LMS algorithm types.
Definition lms.h:32

References hash_name(), Botan::SHA256_M24_H10, Botan::SHA256_M24_H15, Botan::SHA256_M24_H20, Botan::SHA256_M24_H25, Botan::SHA256_M24_H5, Botan::SHA256_M32_H10, Botan::SHA256_M32_H15, Botan::SHA256_M32_H20, Botan::SHA256_M32_H25, Botan::SHA256_M32_H5, Botan::SHAKE_M24_H10, Botan::SHAKE_M24_H15, Botan::SHAKE_M24_H20, Botan::SHAKE_M24_H25, Botan::SHAKE_M24_H5, Botan::SHAKE_M32_H10, Botan::SHAKE_M32_H15, Botan::SHAKE_M32_H20, Botan::SHAKE_M32_H25, and Botan::SHAKE_M32_H5.

Referenced by Botan::HSS_LMS_PrivateKeyInternal::from_bytes_or_throw(), Botan::LMS_PublicKey::from_bytes_or_throw(), Botan::LMS_Signature::from_bytes_or_throw(), and Botan::HSS_LMS_Params::HSS_LMS_Params().

◆ create_or_throw() [2/2]

LMS_Params Botan::LMS_Params::create_or_throw ( std::string_view hash_name,
uint8_t h )
static

Create the LMS parameters from a hash function and tree height.

Parameters
hash_nameThe name of the hash function to use.
hThe height of the tree.
Exceptions
Decoding_ErrorIf the algorithm type is unknown

Definition at line 171 of file lms.cpp.

171 {
172 const LMS_Algorithm_Type type = [](std::string_view hash, uint8_t h) -> LMS_Algorithm_Type {
173 if(hash == "SHA-256") {
174 switch(h) {
175 case 5:
177 case 10:
179 case 15:
181 case 20:
183 case 25:
185 default:
186 throw Decoding_Error("Unsupported height for hash function");
187 }
188 }
189 if(hash == "Truncated(SHA-256,192)") {
190 switch(h) {
191 case 5:
193 case 10:
195 case 15:
197 case 20:
199 case 25:
201 default:
202 throw Decoding_Error("Unsupported height for hash function");
203 }
204 }
205 if(hash == "SHAKE-256(256)") {
206 switch(h) {
207 case 5:
209 case 10:
211 case 15:
213 case 20:
215 case 25:
217 default:
218 throw Decoding_Error("Unsupported height for hash function");
219 }
220 }
221 if(hash == "SHAKE-256(192)") {
222 switch(h) {
223 case 5:
225 case 10:
227 case 15:
229 case 20:
231 case 25:
233 default:
234 throw Decoding_Error("Unsupported height for hash function");
235 }
236 }
237 throw Decoding_Error("Unsupported hash function");
238 }(hash_name, height);
239
240 return LMS_Params(type, hash_name, height);
241}
std::unique_ptr< HashFunction > hash() const
Construct a new hash instance for the LMS instance.
Definition lms.cpp:116
uint8_t h() const
Returns the height of the LMS tree.
Definition lms.h:116

References h(), hash(), hash_name(), Botan::SHA256_M24_H10, Botan::SHA256_M24_H15, Botan::SHA256_M24_H20, Botan::SHA256_M24_H25, Botan::SHA256_M24_H5, Botan::SHA256_M32_H10, Botan::SHA256_M32_H15, Botan::SHA256_M32_H20, Botan::SHA256_M32_H25, Botan::SHA256_M32_H5, Botan::SHAKE_M24_H10, Botan::SHAKE_M24_H15, Botan::SHAKE_M24_H20, Botan::SHAKE_M24_H25, Botan::SHAKE_M24_H5, Botan::SHAKE_M32_H10, Botan::SHAKE_M32_H15, Botan::SHAKE_M32_H20, Botan::SHAKE_M32_H25, and Botan::SHAKE_M32_H5.

◆ h()

uint8_t Botan::LMS_Params::h ( ) const
inline

Returns the height of the LMS tree.

Definition at line 116 of file lms.h.

116{ return m_h; }

Referenced by create_or_throw(), Botan::LMS_Signature::from_bytes_or_throw(), Botan::LMS_PrivateKey::sign_and_get_pk(), and Botan::LMS_Signature::size().

◆ hash()

std::unique_ptr< HashFunction > Botan::LMS_Params::hash ( ) const

Construct a new hash instance for the LMS instance.

Definition at line 116 of file lms.cpp.

116 {
118}
static std::unique_ptr< HashFunction > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition hash.cpp:308

References Botan::HashFunction::create_or_throw(), and hash_name().

Referenced by create_or_throw().

◆ hash_name()

const std::string & Botan::LMS_Params::hash_name ( ) const
inline

Returns the name of the hash function to use.

Definition at line 126 of file lms.h.

126{ return m_hash_name; }

Referenced by create_or_throw(), create_or_throw(), hash(), and Botan::HSS_LMS_PublicKeyInternal::verify_signature().

◆ m()

size_t Botan::LMS_Params::m ( ) const
inline

Returns the number of bytes associated with each node.

Definition at line 121 of file lms.h.

121{ return m_m; }

Referenced by Botan::LMS_Signature::from_bytes_or_throw(), Botan::LMS_PrivateKey::sign_and_get_pk(), and Botan::LMS_Signature::size().


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