Botan 3.6.1
Crypto and TLS for C&
Botan::LMS_Params Class Reference

The LMS parameters. More...

#include <lms.h>

Public Member Functions

LMS_Algorithm_Type algorithm_type () const
 Retuns 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 89 of file lms.h.

Member Function Documentation

◆ algorithm_type()

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

Retuns the LMS algorithm type.

Definition at line 109 of file lms.h.

109{ 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 112 of file lms.cpp.

112 {
113 auto [hash_name, height] = [](const LMS_Algorithm_Type& lms_type) -> std::pair<std::string_view, uint8_t> {
114 switch(lms_type) {
116 return {"SHA-256", 5};
118 return {"SHA-256", 10};
120 return {"SHA-256", 15};
122 return {"SHA-256", 20};
124 return {"SHA-256", 25};
126 return {"Truncated(SHA-256,192)", 5};
128 return {"Truncated(SHA-256,192)", 10};
130 return {"Truncated(SHA-256,192)", 15};
132 return {"Truncated(SHA-256,192)", 20};
134 return {"Truncated(SHA-256,192)", 25};
136 return {"SHAKE-256(256)", 5};
138 return {"SHAKE-256(256)", 10};
140 return {"SHAKE-256(256)", 15};
142 return {"SHAKE-256(256)", 20};
144 return {"SHAKE-256(256)", 25};
146 return {"SHAKE-256(192)", 5};
148 return {"SHAKE-256(192)", 10};
150 return {"SHAKE-256(192)", 15};
152 return {"SHAKE-256(192)", 20};
154 return {"SHAKE-256(192)", 25};
155 default:
156 throw Decoding_Error("Unsupported LMS algorithm type");
157 }
158 }(type);
159
160 return LMS_Params(type, hash_name, height);
161}
const std::string & hash_name() const
Returns the name of the hash function to use.
Definition lms.h:124
LMS_Algorithm_Type
Enum of available LMS algorithm types.
Definition lms.h:30

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 163 of file lms.cpp.

163 {
164 LMS_Algorithm_Type type = [](std::string_view hash, uint8_t h) -> LMS_Algorithm_Type {
165 if(hash == "SHA-256") {
166 switch(h) {
167 case 5:
169 case 10:
171 case 15:
173 case 20:
175 case 25:
177 default:
178 throw Decoding_Error("Unsupported height for hash function");
179 }
180 }
181 if(hash == "Truncated(SHA-256,192)") {
182 switch(h) {
183 case 5:
185 case 10:
187 case 15:
189 case 20:
191 case 25:
193 default:
194 throw Decoding_Error("Unsupported height for hash function");
195 }
196 }
197 if(hash == "SHAKE-256(256)") {
198 switch(h) {
199 case 5:
201 case 10:
203 case 15:
205 case 20:
207 case 25:
209 default:
210 throw Decoding_Error("Unsupported height for hash function");
211 }
212 }
213 if(hash == "SHAKE-256(192)") {
214 switch(h) {
215 case 5:
217 case 10:
219 case 15:
221 case 20:
223 case 25:
225 default:
226 throw Decoding_Error("Unsupported height for hash function");
227 }
228 }
229 throw Decoding_Error("Unsupported hash function");
230 }(hash_name, height);
231
232 return LMS_Params(type, hash_name, height);
233}
std::unique_ptr< HashFunction > hash() const
Construct a new hash instance for the LMS instance.
Definition lms.h:129
uint8_t h() const
Returns the height of the LMS tree.
Definition lms.h:114

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

114{ 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
inline

Construct a new hash instance for the LMS instance.

Definition at line 129 of file lms.h.

static std::unique_ptr< HashFunction > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition hash.cpp:298

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

124{ return m_hash_name; }

Referenced by create_or_throw(), create_or_throw(), Botan::LMS_PublicKey::from_bytes_or_throw(), 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 119 of file lms.h.

119{ return m_m; }

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


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