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

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 100 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 120 of file lm_ots.h.

120{ 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 135 of file lm_ots.h.

135{ 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 100 of file lm_ots.cpp.

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

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_nametha 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 144 of file lm_ots.cpp.

144 {
145 if(w != 1 && w != 2 && w != 4 && w != 8) {
146 throw Decoding_Error("Invalid Winternitz parameter");
147 }
148 LMOTS_Algorithm_Type type = [](std::string_view hash, uint8_t w_p) -> LMOTS_Algorithm_Type {
149 if(hash == "SHA-256") {
150 switch(w_p) {
151 case 1:
153 case 2:
155 case 4:
157 case 8:
159 default:
160 throw Decoding_Error("Unsupported Winternitz parameter");
161 }
162 }
163 if(hash == "Truncated(SHA-256,192)") {
164 switch(w_p) {
165 case 1:
167 case 2:
169 case 4:
171 case 8:
173 default:
174 throw Decoding_Error("Unsupported Winternitz parameter");
175 }
176 }
177 if(hash == "SHAKE-256(256)") {
178 switch(w_p) {
179 case 1:
181 case 2:
183 case 4:
185 case 8:
187 default:
188 throw Decoding_Error("Unsupported Winternitz parameter");
189 }
190 }
191 if(hash == "SHAKE-256(192)") {
192 switch(w_p) {
193 case 1:
195 case 2:
197 case 4:
199 case 8:
201 default:
202 throw Decoding_Error("Unsupported Winternitz parameter");
203 }
204 }
205 throw Decoding_Error("Unsupported hash function");
206 }(hash_name, w);
207
208 return LMOTS_Params(type, hash_name, w);
209}
std::unique_ptr< HashFunction > hash() const
Construct a new hash instance for the OTS instance.
Definition lm_ots.h:155

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
inline

Construct a new hash instance for the OTS instance.

Definition at line 155 of file lm_ots.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(), Botan::LMOTS_Private_Key::LMOTS_Private_Key(), 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 150 of file lm_ots.h.

150{ 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().

◆ ls()

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

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

Definition at line 145 of file lm_ots.h.

145{ 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 125 of file lm_ots.h.

125{ 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 140 of file lm_ots.h.

140{ return m_p; }

Referenced by Botan::LMOTS_Signature::from_bytes_or_throw(), Botan::LMOTS_Private_Key::LMOTS_Private_Key(), 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 130 of file lm_ots.h.

130{ return m_w; }

Referenced by create_or_throw(), and create_or_throw().


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