Botan 3.14.1
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< HashFunction > hash () 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 145 of file lms.cpp.

145 {
146 auto [hash_name, height] = [](const LMS_Algorithm_Type& lms_type) -> std::pair<std::string_view, uint8_t> {
147 switch(lms_type) {
149 return {"SHA-256", static_cast<uint8_t>(5)};
151 return {"SHA-256", static_cast<uint8_t>(10)};
153 return {"SHA-256", static_cast<uint8_t>(15)};
155 return {"SHA-256", static_cast<uint8_t>(20)};
157 return {"SHA-256", static_cast<uint8_t>(25)};
159 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(5)};
161 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(10)};
163 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(15)};
165 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(20)};
167 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(25)};
169 return {"SHAKE-256(256)", static_cast<uint8_t>(5)};
171 return {"SHAKE-256(256)", static_cast<uint8_t>(10)};
173 return {"SHAKE-256(256)", static_cast<uint8_t>(15)};
175 return {"SHAKE-256(256)", static_cast<uint8_t>(20)};
177 return {"SHAKE-256(256)", static_cast<uint8_t>(25)};
179 return {"SHAKE-256(192)", static_cast<uint8_t>(5)};
181 return {"SHAKE-256(192)", static_cast<uint8_t>(10)};
183 return {"SHAKE-256(192)", static_cast<uint8_t>(15)};
185 return {"SHAKE-256(192)", static_cast<uint8_t>(20)};
187 return {"SHAKE-256(192)", static_cast<uint8_t>(25)};
188 default:
189 throw Decoding_Error("Unsupported LMS algorithm type");
190 }
191 }(type);
192
193 return LMS_Params(type, hash_name, height);
194}
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 196 of file lms.cpp.

196 {
197 const LMS_Algorithm_Type type = [](std::string_view hash, uint8_t h) -> LMS_Algorithm_Type {
198 if(hash == "SHA-256") {
199 switch(h) {
200 case 5:
202 case 10:
204 case 15:
206 case 20:
208 case 25:
210 default:
211 throw Decoding_Error("Unsupported height for hash function");
212 }
213 }
214 if(hash == "Truncated(SHA-256,192)") {
215 switch(h) {
216 case 5:
218 case 10:
220 case 15:
222 case 20:
224 case 25:
226 default:
227 throw Decoding_Error("Unsupported height for hash function");
228 }
229 }
230 if(hash == "SHAKE-256(256)") {
231 switch(h) {
232 case 5:
234 case 10:
236 case 15:
238 case 20:
240 case 25:
242 default:
243 throw Decoding_Error("Unsupported height for hash function");
244 }
245 }
246 if(hash == "SHAKE-256(192)") {
247 switch(h) {
248 case 5:
250 case 10:
252 case 15:
254 case 20:
256 case 25:
258 default:
259 throw Decoding_Error("Unsupported height for hash function");
260 }
261 }
262 throw Decoding_Error("Unsupported hash function");
263 }(hash_name, height);
264
265 return LMS_Params(type, hash_name, height);
266}
std::unique_ptr< HashFunction > hash() const
Construct a new hash instance for the LMS instance.
Definition lms.cpp:141
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 141 of file lms.cpp.

141 {
143}
static std::unique_ptr< HashFunction > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition hash.cpp:311

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: