Botan 3.6.1
Crypto and TLS for C&
Botan::Sphincs_Parameters Class Referencefinal

#include <sp_parameters.h>

Public Member Functions

uint32_t a () const
 
AlgorithmIdentifier algorithm_identifier () const
 
uint32_t bitsec () const
 
uint32_t d () const
 
uint32_t fors_message_bytes () const
 
uint32_t fors_signature_bytes () const
 
uint32_t h () const
 
uint32_t h_msg_digest_bytes () const
 
std::string hash_name () const
 
Sphincs_Hash_Type hash_type () const
 
uint32_t ht_signature_bytes () const
 
bool is_available () const
 
bool is_slh_dsa () const
 
uint32_t k () const
 
uint32_t leaf_digest_bytes () const
 
uint32_t log_w () const
 
size_t n () const
 
OID object_identifier () const
 
Sphincs_Parameter_Set parameter_set () const
 
uint32_t private_key_bytes () const
 
uint32_t public_key_bytes () const
 
uint32_t sphincs_signature_bytes () const
 
std::string to_string () const
 
uint32_t tree_digest_bytes () const
 
uint32_t w () const
 
uint32_t wots_bytes () const
 
uint32_t wots_checksum_bytes () const
 
uint32_t wots_len () const
 
uint32_t wots_len_1 () const
 
uint32_t wots_len_2 () const
 
uint32_t xmss_signature_bytes () const
 
uint32_t xmss_tree_height () const
 

Static Public Member Functions

static Sphincs_Parameters create (const OID &oid)
 
static Sphincs_Parameters create (Sphincs_Parameter_Set set, Sphincs_Hash_Type hash)
 
static Sphincs_Parameters create (std::string_view name)
 

Detailed Description

Container for all SLH-DSA parameters defined by a specific instance (see FIPS 205, Table 2). Also contains getters for various parameters that are derived from the given parameters.

Definition at line 45 of file sp_parameters.h.

Member Function Documentation

◆ a()

uint32_t Botan::Sphincs_Parameters::a ( ) const
inline

This is the desired height of the FORS trees, aka log(t) with t being the number of leaves in each FORS tree.

Returns
Height of the FORS trees

Definition at line 114 of file sp_parameters.h.

114{ return m_a; }

Referenced by Botan::fors_public_key_from_signature(), and Botan::fors_sign_and_pkgen().

◆ algorithm_identifier()

AlgorithmIdentifier Botan::Sphincs_Parameters::algorithm_identifier ( ) const
Returns
the algorithm specifier for the selected parameter set

Definition at line 410 of file sp_parameters.cpp.

410 {
411 return AlgorithmIdentifier(object_identifier(), AlgorithmIdentifier::USE_EMPTY_PARAM);
412}

◆ bitsec()

uint32_t Botan::Sphincs_Parameters::bitsec ( ) const
inline
Returns
the bit security given by Table 3 (NIST R3.1 submission, page 39) for the selected parameter set

Definition at line 130 of file sp_parameters.h.

130{ return m_bitsec; }

◆ create() [1/3]

Sphincs_Parameters Botan::Sphincs_Parameters::create ( const OID & oid)
static

Definition at line 402 of file sp_parameters.cpp.

402 {
403 return Sphincs_Parameters::create(oid.to_formatted_string());
404}
static Sphincs_Parameters create(Sphincs_Parameter_Set set, Sphincs_Hash_Type hash)

References Botan::OID::to_formatted_string().

◆ create() [2/3]

Sphincs_Parameters Botan::Sphincs_Parameters::create ( Sphincs_Parameter_Set set,
Sphincs_Hash_Type hash )
static

Definition at line 349 of file sp_parameters.cpp.

350 {
351 // See FIPS 205, Table 2
352 switch(set) {
355 return Sphincs_Parameters(set, hash, 16, 63, 7, 12, 14, 16, 133);
358 return Sphincs_Parameters(set, hash, 16, 66, 22, 6, 33, 16, 128);
359
362 return Sphincs_Parameters(set, hash, 24, 63, 7, 14, 17, 16, 193);
365 return Sphincs_Parameters(set, hash, 24, 66, 22, 8, 33, 16, 194);
366
369 return Sphincs_Parameters(set, hash, 32, 64, 8, 14, 22, 16, 255);
372 return Sphincs_Parameters(set, hash, 32, 68, 17, 9, 35, 16, 255);
373 }
375}
#define BOTAN_ASSERT_UNREACHABLE()
Definition assert.h:137

References BOTAN_ASSERT_UNREACHABLE.

Referenced by Botan::create_private_key().

◆ create() [3/3]

Sphincs_Parameters Botan::Sphincs_Parameters::create ( std::string_view name)
static

Definition at line 377 of file sp_parameters.cpp.

377 {
378 auto [param_set, hash_type] = set_and_hash_from_name(name);
379 return Sphincs_Parameters::create(param_set, hash_type);
380}
Sphincs_Hash_Type hash_type() const
std::string name

References name.

◆ d()

uint32_t Botan::Sphincs_Parameters::d ( ) const
inline
Returns
Number of XMSS layers in the SLH-DSA hypertree

Definition at line 106 of file sp_parameters.h.

106{ return m_d; }

Referenced by Botan::ht_sign(), Botan::ht_verify(), and Botan::xmss_gen_root().

◆ fors_message_bytes()

uint32_t Botan::Sphincs_Parameters::fors_message_bytes ( ) const
inline
Returns
the byte length of the FORS input message

Definition at line 185 of file sp_parameters.h.

185{ return m_fors_message_bytes; }

◆ fors_signature_bytes()

uint32_t Botan::Sphincs_Parameters::fors_signature_bytes ( ) const
inline
Returns
the byte length of a FORS signature

Definition at line 180 of file sp_parameters.h.

180{ return m_fors_sig_bytes; }

Referenced by Botan::fors_sign_and_pkgen().

◆ h()

uint32_t Botan::Sphincs_Parameters::h ( ) const
inline
Returns
Height of the SLH-DSA hypertree

Definition at line 101 of file sp_parameters.h.

101{ return m_h; }

◆ h_msg_digest_bytes()

uint32_t Botan::Sphincs_Parameters::h_msg_digest_bytes ( ) const
inline
Returns
the byte length of the output of H_msg. Corresponds to 'm' of FIPS 205, Table 2.

Definition at line 216 of file sp_parameters.h.

216{ return m_h_msg_digest_bytes; }

◆ hash_name()

std::string Botan::Sphincs_Parameters::hash_name ( ) const
Returns
the algorithm specifier of the hash function to be used

Definition at line 386 of file sp_parameters.cpp.

386 {
387 switch(m_hash_type) {
389 return "SHA-256";
391 return fmt("SHAKE-256({})", 8 * n());
393 return "Haraka";
394 }
396}
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53
@ Haraka
Haraka is currently not supported.

References BOTAN_ASSERT_UNREACHABLE, and Botan::fmt().

◆ hash_type()

Sphincs_Hash_Type Botan::Sphincs_Parameters::hash_type ( ) const
inline
Returns
the hash type used by those parameters

Definition at line 71 of file sp_parameters.h.

71{ return m_hash_type; }

Referenced by Botan::Sphincs_Hash_Functions::create().

◆ ht_signature_bytes()

uint32_t Botan::Sphincs_Parameters::ht_signature_bytes ( ) const
inline
Returns
the byte length of a the xmss hypertree signature

Definition at line 145 of file sp_parameters.h.

145{ return m_ht_sig_bytes; }

Referenced by Botan::ht_sign(), and Botan::ht_verify().

◆ is_available()

bool Botan::Sphincs_Parameters::is_available ( ) const
Returns
true iff the given parameter set and hash combination is available in this build. Note that parameter sets can only be used if this function evaluates to true.

Definition at line 324 of file sp_parameters.cpp.

324 {
325 [[maybe_unused]] const bool is_slh_dsa = is_slh_dsa_set(m_set);
326#ifdef BOTAN_HAS_SLH_DSA_WITH_SHA2
327 if(is_slh_dsa && m_hash_type == Sphincs_Hash_Type::Sha256) {
328 return true;
329 }
330#endif
331#ifdef BOTAN_HAS_SLH_DSA_WITH_SHAKE
332 if(is_slh_dsa && m_hash_type == Sphincs_Hash_Type::Shake256) {
333 return true;
334 }
335#endif
336#ifdef BOTAN_HAS_SPHINCS_PLUS_WITH_SHA2
337 if(!is_slh_dsa && m_hash_type == Sphincs_Hash_Type::Sha256) {
338 return true;
339 }
340#endif
341#ifdef BOTAN_HAS_SPHINCS_PLUS_WITH_SHAKE
342 if(!is_slh_dsa && m_hash_type == Sphincs_Hash_Type::Shake256) {
343 return true;
344 }
345#endif
346 return false;
347}

Referenced by Botan::SphincsPlus_PrivateKey::SphincsPlus_PrivateKey(), Botan::SphincsPlus_PrivateKey::SphincsPlus_PrivateKey(), and Botan::SphincsPlus_PublicKey::SphincsPlus_PublicKey().

◆ is_slh_dsa()

bool Botan::Sphincs_Parameters::is_slh_dsa ( ) const
Returns
true for SLH-DSA parameter sets. False for SPHINCS+ Round 3.1 parameter sets.

Definition at line 382 of file sp_parameters.cpp.

382 {
383 return is_slh_dsa_set(m_set);
384}

◆ k()

uint32_t Botan::Sphincs_Parameters::k ( ) const
inline
Returns
Number of FORS trees to use

Definition at line 119 of file sp_parameters.h.

119{ return m_k; }

Referenced by Botan::fors_public_key_from_signature(), and Botan::fors_sign_and_pkgen().

◆ leaf_digest_bytes()

uint32_t Botan::Sphincs_Parameters::leaf_digest_bytes ( ) const
inline
Returns
the byte length of the leaf index output of H_msg

Definition at line 210 of file sp_parameters.h.

210{ return m_leaf_digest_bytes; }

◆ log_w()

uint32_t Botan::Sphincs_Parameters::log_w ( ) const
inline
Returns
the base 2 logarithm of the Winternitz parameter for WOTS+ signatures

Definition at line 150 of file sp_parameters.h.

150{ return m_lg_w; }

◆ n()

◆ object_identifier()

OID Botan::Sphincs_Parameters::object_identifier ( ) const
Returns
the OID of the algorithm specified by those parameters

Definition at line 406 of file sp_parameters.cpp.

406 {
407 return OID::from_string(to_string());
408}
static OID from_string(std::string_view str)
Definition asn1_oid.cpp:86
std::string to_string() const

◆ parameter_set()

Sphincs_Parameter_Set Botan::Sphincs_Parameters::parameter_set ( ) const
inline
Returns
the generic algorithm parameterization set to be used by those parameters

Definition at line 76 of file sp_parameters.h.

76{ return m_set; }

◆ private_key_bytes()

uint32_t Botan::Sphincs_Parameters::private_key_bytes ( ) const
inline
Returns
the byte length of an encoded private key for this parameter set

Definition at line 200 of file sp_parameters.h.

200{ return m_n * 2 + public_key_bytes(); }
uint32_t public_key_bytes() const

Referenced by Botan::SphincsPlus_PrivateKey::SphincsPlus_PrivateKey().

◆ public_key_bytes()

uint32_t Botan::Sphincs_Parameters::public_key_bytes ( ) const
inline
Returns
the byte length of an encoded public key for this parameter set

Definition at line 195 of file sp_parameters.h.

195{ return m_n * 2; }

Referenced by Botan::SphincsPlus_PrivateKey::SphincsPlus_PrivateKey().

◆ sphincs_signature_bytes()

uint32_t Botan::Sphincs_Parameters::sphincs_signature_bytes ( ) const
inline
Returns
the byte length of a SLH-DSA signature

Definition at line 190 of file sp_parameters.h.

190{ return m_sp_sig_bytes; }

◆ to_string()

std::string Botan::Sphincs_Parameters::to_string ( ) const
Returns
a string representation of this parameter set

Definition at line 398 of file sp_parameters.cpp.

398 {
399 return name_from_set_and_hash(parameter_set(), hash_type());
400}
Sphincs_Parameter_Set parameter_set() const

◆ tree_digest_bytes()

uint32_t Botan::Sphincs_Parameters::tree_digest_bytes ( ) const
inline
Returns
the byte length of the tree index output of H_msg

Definition at line 205 of file sp_parameters.h.

205{ return m_tree_digest_bytes; }

◆ w()

uint32_t Botan::Sphincs_Parameters::w ( ) const
inline
Returns
the Winternitz parameter for WOTS+ signatures

Definition at line 124 of file sp_parameters.h.

124{ return m_w; }

Referenced by Botan::wots_public_key_from_signature(), and Botan::wots_sign_and_pkgen().

◆ wots_bytes()

uint32_t Botan::Sphincs_Parameters::wots_bytes ( ) const
inline
Returns
the byte length of a WOTS+ signature

Definition at line 170 of file sp_parameters.h.

170{ return m_wots_bytes; }

Referenced by Botan::ht_verify(), Botan::wots_sign_and_pkgen(), Botan::xmss_gen_root(), and Botan::xmss_sign_and_pkgen().

◆ wots_checksum_bytes()

uint32_t Botan::Sphincs_Parameters::wots_checksum_bytes ( ) const
inline
Returns
the number of bytes a WOTS+ signature consists of

Definition at line 175 of file sp_parameters.h.

175{ return m_wots_checksum_bytes; }

◆ wots_len()

uint32_t Botan::Sphincs_Parameters::wots_len ( ) const
inline
Returns
the len parameter for WOTS+ signatures

Definition at line 165 of file sp_parameters.h.

165{ return m_wots_len; }

Referenced by Botan::wots_public_key_from_signature(), and Botan::wots_sign_and_pkgen().

◆ wots_len_1()

uint32_t Botan::Sphincs_Parameters::wots_len_1 ( ) const
inline
Returns
the len1 parameter for WOTS+ signatures

Definition at line 155 of file sp_parameters.h.

155{ return m_wots_len1; }

Referenced by Botan::chain_lengths().

◆ wots_len_2()

uint32_t Botan::Sphincs_Parameters::wots_len_2 ( ) const
inline
Returns
the len2 parameter for WOTS+ signatures

Definition at line 160 of file sp_parameters.h.

160{ return m_wots_len2; }

Referenced by Botan::chain_lengths().

◆ xmss_signature_bytes()

uint32_t Botan::Sphincs_Parameters::xmss_signature_bytes ( ) const
inline
Returns
the byte length of a single xmss signature

Definition at line 140 of file sp_parameters.h.

140{ return m_xmss_sig_bytes; }

Referenced by Botan::ht_sign().

◆ xmss_tree_height()

uint32_t Botan::Sphincs_Parameters::xmss_tree_height ( ) const
inline
Returns
the tree height of an XMSS tree

Definition at line 135 of file sp_parameters.h.

135{ return m_xmss_tree_height; }

Referenced by Botan::ht_sign(), Botan::ht_verify(), Botan::xmss_gen_root(), and Botan::xmss_sign_and_pkgen().


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