Botan 3.5.0
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 99 of file lm_ots.cpp.

99 {
100 auto [hash_name, w] = [](const LMOTS_Algorithm_Type& lmots_type) -> std::pair<std::string_view, uint8_t> {
101 switch(lmots_type) {
103 return {"SHA-256", 1};
105 return {"SHA-256", 2};
107 return {"SHA-256", 4};
109 return {"SHA-256", 8};
111 return {"Truncated(SHA-256,192)", 1};
113 return {"Truncated(SHA-256,192)", 2};
115 return {"Truncated(SHA-256,192)", 4};
117 return {"Truncated(SHA-256,192)", 8};
119 return {"SHAKE-256(256)", 1};
121 return {"SHAKE-256(256)", 2};
123 return {"SHAKE-256(256)", 4};
125 return {"SHAKE-256(256)", 8};
127 return {"SHAKE-256(192)", 1};
129 return {"SHAKE-256(192)", 2};
131 return {"SHAKE-256(192)", 4};
133 return {"SHAKE-256(192)", 8};
135 throw Decoding_Error("Unsupported LMS algorithm type");
136 }
137 throw Decoding_Error("Unsupported LMS algorithm type");
138 }(type);
139
140 return LMOTS_Params(type, hash_name, w);
141}
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 143 of file lm_ots.cpp.

143 {
144 if(w != 1 && w != 2 && w != 4 && w != 8) {
145 throw Decoding_Error("Invalid Winternitz parameter");
146 }
147 LMOTS_Algorithm_Type type = [](std::string_view hash, uint8_t w_p) -> LMOTS_Algorithm_Type {
148 if(hash == "SHA-256") {
149 switch(w_p) {
150 case 1:
152 case 2:
154 case 4:
156 case 8:
158 default:
159 throw Decoding_Error("Unsupported Winternitz parameter");
160 }
161 }
162 if(hash == "Truncated(SHA-256,192)") {
163 switch(w_p) {
164 case 1:
166 case 2:
168 case 4:
170 case 8:
172 default:
173 throw Decoding_Error("Unsupported Winternitz parameter");
174 }
175 }
176 if(hash == "SHAKE-256(256)") {
177 switch(w_p) {
178 case 1:
180 case 2:
182 case 4:
184 case 8:
186 default:
187 throw Decoding_Error("Unsupported Winternitz parameter");
188 }
189 }
190 if(hash == "SHAKE-256(192)") {
191 switch(w_p) {
192 case 1:
194 case 2:
196 case 4:
198 case 8:
200 default:
201 throw Decoding_Error("Unsupported Winternitz parameter");
202 }
203 }
204 throw Decoding_Error("Unsupported hash function");
205 }(hash_name, w);
206
207 return LMOTS_Params(type, hash_name, w);
208}
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(), Botan::LMOTS_Private_Key::sign(), 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: