Botan  2.4.0
Crypto and TLS for C++11
Public Member Functions | Static Public Member Functions | List of all members
Botan::XMSS_Tools Class Referencefinal

#include <xmss_tools.h>

Public Member Functions

void operator= (const XMSS_Tools &)=delete
 
 XMSS_Tools (const XMSS_Tools &)=delete
 

Static Public Member Functions

template<typename T , typename U = typename std::enable_if<std::is_integral<T>::value, void>::type>
static void concat (secure_vector< uint8_t > &target, const T &src)
 
template<typename T , typename U = typename std::enable_if<std::is_integral<T>::value, void>::type>
static void concat (secure_vector< uint8_t > &target, const T &src, size_t len)
 
static size_t max_threads ()
 

Detailed Description

Helper tools for low level byte operations required for the XMSS implementation.

Definition at line 28 of file xmss_tools.h.

Constructor & Destructor Documentation

◆ XMSS_Tools()

Botan::XMSS_Tools::XMSS_Tools ( const XMSS_Tools )
delete

Member Function Documentation

◆ concat() [1/2]

template<typename T , typename U >
void Botan::XMSS_Tools::concat ( secure_vector< uint8_t > &  target,
const T src 
)
static

Concatenates the byte representation in big-endian order of any integral value to a secure_vector.

Parameters
targetVector to concatenate the byte representation of the integral value to.
srcintegral value to concatenate.

Definition at line 103 of file xmss_tools.h.

References Botan::CPUID::is_little_endian().

Referenced by Botan::XMSS_WOTS_PrivateKey::at(), Botan::XMSS_WOTS_Parameters::base_w(), Botan::XMSS_Signature_Operation::sign(), and Botan::XMSS_Verification_Operation::XMSS_Verification_Operation().

104  {
105  const uint8_t* src_bytes = reinterpret_cast<const uint8_t*>(&src);
107  {
108  std::reverse_copy(src_bytes,
109  src_bytes + sizeof(src),
110  std::back_inserter(target));
111  }
112  else
113  {
114  std::copy(src_bytes,
115  src_bytes + sizeof(src),
116  std::back_inserter(target));
117  }
118  }
static bool is_little_endian()
Definition: cpuid.h:75

◆ concat() [2/2]

template<typename T , typename U >
void Botan::XMSS_Tools::concat ( secure_vector< uint8_t > &  target,
const T src,
size_t  len 
)
static

Concatenates the last n bytes of the byte representation in big-endian order of any integral value to a to a secure_vector.

Parameters
targetVector to concatenate the byte representation of the integral value to.
srcIntegral value to concatenate.
lennumber of bytes to concatenate. This value must be smaller or equal to the size of type T.

Definition at line 122 of file xmss_tools.h.

References Botan::CPUID::is_little_endian().

125  {
126  size_t c = static_cast<size_t>(std::min(len, sizeof(src)));
127  if(len > sizeof(src))
128  {
129  target.resize(target.size() + len - sizeof(src), 0);
130  }
131 
132  const uint8_t* src_bytes = reinterpret_cast<const uint8_t*>(&src);
134  {
135  std::reverse_copy(src_bytes,
136  src_bytes + c,
137  std::back_inserter(target));
138  }
139  else
140  {
141  std::copy(src_bytes + sizeof(src) - c,
142  src_bytes + sizeof(src),
143  std::back_inserter(target));
144  }
145  }
static bool is_little_endian()
Definition: cpuid.h:75

◆ max_threads()

static size_t Botan::XMSS_Tools::max_threads ( )
static

Not a public API function - will be removed in a future release.

Determines the maximum number of threads to be used efficiently, based on runtime timining measurements. Ideally the result will correspond to the physical number of cores. On systems supporting simultaneous multi threading (SMT) std::thread::hardware_concurrency() usually reports a supported number of threads which is bigger (typically by a factor of 2) than the number of physical cores available. Using more threads than physically available cores for computationally intesive tasks resulted in slowdowns compared to using a number of threads equal to the number of physical cores on test systems. This function is a temporary workaround to prevent performance degradation due to overstressing the CPU with too many threads.

Returns
Presumed number of physical cores based on timing measurements.

Referenced by Botan::XMSS_PrivateKey::tree_hash().

◆ operator=()

void Botan::XMSS_Tools::operator= ( const XMSS_Tools )
delete

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