Botan  2.11.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)
 

Detailed Description

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

Definition at line 22 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 61 of file xmss_tools.h.

References Botan::CPUID::is_little_endian().

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

62  {
63  const uint8_t* src_bytes = reinterpret_cast<const uint8_t*>(&src);
65  {
66  std::reverse_copy(src_bytes,
67  src_bytes + sizeof(src),
68  std::back_inserter(target));
69  }
70  else
71  {
72  std::copy(src_bytes,
73  src_bytes + sizeof(src),
74  std::back_inserter(target));
75  }
76  }
static bool is_little_endian()
Definition: cpuid.h:71

◆ 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 80 of file xmss_tools.h.

References Botan::CPUID::is_little_endian().

83  {
84  size_t c = static_cast<size_t>(std::min(len, sizeof(src)));
85  if(len > sizeof(src))
86  {
87  target.resize(target.size() + len - sizeof(src), 0);
88  }
89 
90  const uint8_t* src_bytes = reinterpret_cast<const uint8_t*>(&src);
92  {
93  std::reverse_copy(src_bytes,
94  src_bytes + c,
95  std::back_inserter(target));
96  }
97  else
98  {
99  std::copy(src_bytes + sizeof(src) - c,
100  src_bytes + sizeof(src),
101  std::back_inserter(target));
102  }
103  }
static bool is_little_endian()
Definition: cpuid.h:71

◆ operator=()

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

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