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

The LM-OTS parameters. More...

#include <lm_ots.h>

Public Member Functions

LMOTS_Algorithm_Type algorithm_type () const
 Returns the LM-OTS algorithm type.
uint8_t coef_max () const
 The maximum the winternitz coefficients can have.
std::unique_ptr< HashFunctionhash () const
 Construct a new hash instance for the OTS instance.
const std::string & hash_name () const
 Name of the hash function to use.
uint8_t ls () const
 The number of left-shift bits used in the checksum function Cksm.
size_t n () const
 The number of bytes of the output of the hash function.
uint16_t p () const
 The number of n-byte string elements that make up the LM-OTS signature.
uint8_t w () const
 The width (in bits) of the Winternitz coefficients.

Static Public Member Functions

static LMOTS_Params create_or_throw (LMOTS_Algorithm_Type type)
 Create the LM-OTS parameters from a known algorithm type.
static LMOTS_Params create_or_throw (std::string_view hash_name, uint8_t w)
 Create the LM-OTS parameters from a hash function and width.

Detailed Description

The LM-OTS parameters.

See RFC 8554 Section 4.1.

Definition at line 103 of file lm_ots.h.

Member Function Documentation

◆ algorithm_type()

LMOTS_Algorithm_Type Botan::LMOTS_Params::algorithm_type ( ) const
inline

Returns the LM-OTS algorithm type.

Definition at line 123 of file lm_ots.h.

123{ return m_algorithm_type; }

◆ coef_max()

uint8_t Botan::LMOTS_Params::coef_max ( ) const
inline

The maximum the winternitz coefficients can have.

Definition at line 138 of file lm_ots.h.

138{ return (1 << m_w) - 1; }

Referenced by Botan::LMOTS_Public_Key::LMOTS_Public_Key().

◆ create_or_throw() [1/2]

LMOTS_Params Botan::LMOTS_Params::create_or_throw ( LMOTS_Algorithm_Type type)
static

Create the LM-OTS parameters from a known algorithm type.

Exceptions
Decoding_ErrorIf the algorithm type is unknown

Definition at line 106 of file lm_ots.cpp.

106 {
107 auto [hash_name, w] = [](const LMOTS_Algorithm_Type& lmots_type) -> std::pair<std::string_view, uint8_t> {
108 switch(lmots_type) {
110 return {"SHA-256", static_cast<uint8_t>(1)};
112 return {"SHA-256", static_cast<uint8_t>(2)};
114 return {"SHA-256", static_cast<uint8_t>(4)};
116 return {"SHA-256", static_cast<uint8_t>(8)};
118 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(1)};
120 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(2)};
122 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(4)};
124 return {"Truncated(SHA-256,192)", static_cast<uint8_t>(8)};
126 return {"SHAKE-256(256)", static_cast<uint8_t>(1)};
128 return {"SHAKE-256(256)", static_cast<uint8_t>(2)};
130 return {"SHAKE-256(256)", static_cast<uint8_t>(4)};
132 return {"SHAKE-256(256)", static_cast<uint8_t>(8)};
134 return {"SHAKE-256(192)", static_cast<uint8_t>(1)};
136 return {"SHAKE-256(192)", static_cast<uint8_t>(2)};
138 return {"SHAKE-256(192)", static_cast<uint8_t>(4)};
140 return {"SHAKE-256(192)", static_cast<uint8_t>(8)};
142 throw Decoding_Error("Unsupported LMS algorithm type");
143 }
144 throw Decoding_Error("Unsupported LMS algorithm type");
145 }(type);
146
147 return LMOTS_Params(type, hash_name, w);
148}
uint8_t w() const
The width (in bits) of the Winternitz coefficients.
Definition lm_ots.h:133
const std::string & hash_name() const
Name of the hash function to use.
Definition lm_ots.h:153
LMOTS_Algorithm_Type
Enum of available LM-OTS algorithm types.
Definition lm_ots.h:68

References hash_name(), Botan::RESERVED, Botan::SHA256_N24_W1, Botan::SHA256_N24_W2, Botan::SHA256_N24_W4, Botan::SHA256_N24_W8, Botan::SHA256_N32_W1, Botan::SHA256_N32_W2, Botan::SHA256_N32_W4, Botan::SHA256_N32_W8, Botan::SHAKE_N24_W1, Botan::SHAKE_N24_W2, Botan::SHAKE_N24_W4, Botan::SHAKE_N24_W8, Botan::SHAKE_N32_W1, Botan::SHAKE_N32_W2, Botan::SHAKE_N32_W4, Botan::SHAKE_N32_W8, and w().

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

◆ create_or_throw() [2/2]

LMOTS_Params Botan::LMOTS_Params::create_or_throw ( std::string_view hash_name,
uint8_t w )
static

Create the LM-OTS parameters from a hash function and width.

Parameters
hash_namethe name of the hash function to use.
wthe width (in bits) of the Winternitz coefficients.
Exceptions
Decoding_ErrorIf the algorithm type is unknown

Definition at line 150 of file lm_ots.cpp.

150 {
151 if(w != 1 && w != 2 && w != 4 && w != 8) {
152 throw Decoding_Error("Invalid Winternitz parameter");
153 }
154 const LMOTS_Algorithm_Type type = [](std::string_view hash, uint8_t w_p) -> LMOTS_Algorithm_Type {
155 if(hash == "SHA-256") {
156 switch(w_p) {
157 case 1:
159 case 2:
161 case 4:
163 case 8:
165 default:
166 throw Decoding_Error("Unsupported Winternitz parameter");
167 }
168 }
169 if(hash == "Truncated(SHA-256,192)") {
170 switch(w_p) {
171 case 1:
173 case 2:
175 case 4:
177 case 8:
179 default:
180 throw Decoding_Error("Unsupported Winternitz parameter");
181 }
182 }
183 if(hash == "SHAKE-256(256)") {
184 switch(w_p) {
185 case 1:
187 case 2:
189 case 4:
191 case 8:
193 default:
194 throw Decoding_Error("Unsupported Winternitz parameter");
195 }
196 }
197 if(hash == "SHAKE-256(192)") {
198 switch(w_p) {
199 case 1:
201 case 2:
203 case 4:
205 case 8:
207 default:
208 throw Decoding_Error("Unsupported Winternitz parameter");
209 }
210 }
211 throw Decoding_Error("Unsupported hash function");
212 }(hash_name, w);
213
214 return LMOTS_Params(type, hash_name, w);
215}
std::unique_ptr< HashFunction > hash() const
Construct a new hash instance for the OTS instance.
Definition lm_ots.cpp:102

References hash(), hash_name(), Botan::SHA256_N24_W1, Botan::SHA256_N24_W2, Botan::SHA256_N24_W4, Botan::SHA256_N24_W8, Botan::SHA256_N32_W1, Botan::SHA256_N32_W2, Botan::SHA256_N32_W4, Botan::SHA256_N32_W8, Botan::SHAKE_N24_W1, Botan::SHAKE_N24_W2, Botan::SHAKE_N24_W4, Botan::SHAKE_N24_W8, Botan::SHAKE_N32_W1, Botan::SHAKE_N32_W2, Botan::SHAKE_N32_W4, Botan::SHAKE_N32_W8, and w().

◆ hash()

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

Construct a new hash instance for the OTS instance.

Definition at line 102 of file lm_ots.cpp.

102 {
104}
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(), Botan::LMOTS_Public_Key::LMOTS_Public_Key(), and Botan::LMOTS_Private_Key::sign().

◆ hash_name()

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

Name of the hash function to use.

Definition at line 153 of file lm_ots.h.

153{ return m_hash_name; }

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

◆ ls()

uint8_t Botan::LMOTS_Params::ls ( ) const
inline

The number of left-shift bits used in the checksum function Cksm.

Definition at line 148 of file lm_ots.h.

148{ return m_ls; }

◆ n()

size_t Botan::LMOTS_Params::n ( ) const
inline

The number of bytes of the output of the hash function.

Definition at line 128 of file lm_ots.h.

128{ return m_n; }

Referenced by Botan::LMOTS_Signature::from_bytes_or_throw(), Botan::LMOTS_Public_Key::LMOTS_Public_Key(), and Botan::LMOTS_Signature::size().

◆ p()

uint16_t Botan::LMOTS_Params::p ( ) const
inline

The number of n-byte string elements that make up the LM-OTS signature.

Definition at line 143 of file lm_ots.h.

143{ return m_p; }

Referenced by Botan::LMOTS_Signature::from_bytes_or_throw(), Botan::LMOTS_Private_Key::sign(), and Botan::LMOTS_Signature::size().

◆ w()

uint8_t Botan::LMOTS_Params::w ( ) const
inline

The width (in bits) of the Winternitz coefficients.

Definition at line 133 of file lm_ots.h.

133{ return m_w; }

Referenced by create_or_throw(), and create_or_throw().


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