Botan 3.10.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 89 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 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 111 of file lms.cpp.

111 {
112 auto [hash_name, height] = [](const LMS_Algorithm_Type& lms_type) -> std::pair<std::string_view, uint8_t> {
113 switch(lms_type) {
115 return {"SHA-256", static_cast<uint8_t>(5)};
117 return {"SHA-256", static_cast<uint8_t>(10)};
119 return {"SHA-256", static_cast<uint8_t>(15)};
121 return {"SHA-256", static_cast<uint8_t>(20)};
123 return {"SHA-256", static_cast<uint8_t>(25)};
125 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(5)};
127 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(10)};
129 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(15)};
131 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(20)};
133 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(25)};
135 return {"SHAKE-256(256)", static_cast<uint8_t>(5)};
137 return {"SHAKE-256(256)", static_cast<uint8_t>(10)};
139 return {"SHAKE-256(256)", static_cast<uint8_t>(15)};
141 return {"SHAKE-256(256)", static_cast<uint8_t>(20)};
143 return {"SHAKE-256(256)", static_cast<uint8_t>(25)};
145 return {"SHAKE-256(192)", static_cast<uint8_t>(5)};
147 return {"SHAKE-256(192)", static_cast<uint8_t>(10)};
149 return {"SHAKE-256(192)", static_cast<uint8_t>(15)};
151 return {"SHAKE-256(192)", static_cast<uint8_t>(20)};
153 return {"SHAKE-256(192)", static_cast<uint8_t>(25)};
154 default:
155 throw Decoding_Error("Unsupported LMS algorithm type");
156 }
157 }(type);
158
159 return LMS_Params(type, hash_name, height);
160}
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 162 of file lms.cpp.

162 {
163 LMS_Algorithm_Type type = [](std::string_view hash, uint8_t h) -> LMS_Algorithm_Type {
164 if(hash == "SHA-256") {
165 switch(h) {
166 case 5:
168 case 10:
170 case 15:
172 case 20:
174 case 25:
176 default:
177 throw Decoding_Error("Unsupported height for hash function");
178 }
179 }
180 if(hash == "Truncated(SHA-256,192)") {
181 switch(h) {
182 case 5:
184 case 10:
186 case 15:
188 case 20:
190 case 25:
192 default:
193 throw Decoding_Error("Unsupported height for hash function");
194 }
195 }
196 if(hash == "SHAKE-256(256)") {
197 switch(h) {
198 case 5:
200 case 10:
202 case 15:
204 case 20:
206 case 25:
208 default:
209 throw Decoding_Error("Unsupported height for hash function");
210 }
211 }
212 if(hash == "SHAKE-256(192)") {
213 switch(h) {
214 case 5:
216 case 10:
218 case 15:
220 case 20:
222 case 25:
224 default:
225 throw Decoding_Error("Unsupported height for hash function");
226 }
227 }
228 throw Decoding_Error("Unsupported hash function");
229 }(hash_name, height);
230
231 return LMS_Params(type, hash_name, height);
232}
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: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 124 of file lms.h.

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

119{ 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: