aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/xmss/xmss_tools.h
diff options
context:
space:
mode:
authorMatthias Gierlings <[email protected]>2016-11-11 13:02:58 +0100
committerMatthias Gierlings <[email protected]>2016-11-11 15:56:33 +0100
commiteb949db1a01e9f6fd71e25c89c7f015021af12e0 (patch)
treea83347201260d59347f8740ca9ef02f449ee2797 /src/lib/pubkey/xmss/xmss_tools.h
parent8b06b4fe5fbe189c7d5250becb189bf2b87b9013 (diff)
Implements changes from XMSS review
- Removes custom XMSS_Hash assignment operator. - Changes mutex type used in XMSS_Index_Registryfrom std::mutex to Botan::mutex_type, changes lock_guard accordingly. - Removes singleton and endianess detection from XMSS_Tools, changes XMSS_Tools::concat() to be a static method. - XMSS/XMSS_WOTS check_key() now always returns true.
Diffstat (limited to 'src/lib/pubkey/xmss/xmss_tools.h')
-rw-r--r--src/lib/pubkey/xmss/xmss_tools.h25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/lib/pubkey/xmss/xmss_tools.h b/src/lib/pubkey/xmss/xmss_tools.h
index 07e36ea71..773953fae 100644
--- a/src/lib/pubkey/xmss/xmss_tools.h
+++ b/src/lib/pubkey/xmss/xmss_tools.h
@@ -11,6 +11,7 @@
#include <stdint.h>
#include <iterator>
#include <type_traits>
+#include <botan/cpuid.h>
#include <botan/types.h>
#include <botan/secmem.h>
@@ -26,16 +27,6 @@ namespace Botan {
XMSS_Tools(const XMSS_Tools&) = delete;
void operator=(const XMSS_Tools&) = delete;
- static const XMSS_Tools& get();
-
- /**
- * Retrieves information about endianess
- *
- * @return true if machine uses little-endian byte order, false
- * otherwise.
- **/
- inline bool is_little_endian() const { return m_is_little_endian; }
-
/**
* Concatenates the byte representation in big-endian order of any
* integral value to a secure_vector.
@@ -47,7 +38,7 @@ namespace Botan {
template<typename T,
typename U = typename std::enable_if<std::is_integral<T>::value,
void>::type>
- void concat(secure_vector<byte>& target, const T& src) const;
+ static void concat(secure_vector<byte>& target, const T& src);
/**
* Concatenates the last n bytes of the byte representation in big-endian
@@ -62,19 +53,17 @@ namespace Botan {
template <typename T,
typename U = typename std::enable_if<std::is_integral<T>::value,
void>::type>
- void concat(secure_vector<byte>& target, const T& src, size_t len) const;
+ static void concat(secure_vector<byte>& target, const T& src, size_t len);
private:
XMSS_Tools();
-
- bool m_is_little_endian;
};
template <typename T, typename U>
-void XMSS_Tools::concat(secure_vector<byte>& target, const T& src) const
+void XMSS_Tools::concat(secure_vector<byte>& target, const T& src)
{
const byte* src_bytes = reinterpret_cast<const byte*>(&src);
- if(is_little_endian())
+ if(CPUID::is_little_endian())
std::reverse_copy(src_bytes,
src_bytes + sizeof(src),
std::back_inserter(target));
@@ -88,7 +77,7 @@ void XMSS_Tools::concat(secure_vector<byte>& target, const T& src) const
template <typename T, typename U>
void XMSS_Tools::concat(secure_vector<byte>& target,
const T& src,
- size_t len) const
+ size_t len)
{
size_t c = static_cast<size_t>(std::min(len, sizeof(src)));
if(len > sizeof(src))
@@ -97,7 +86,7 @@ void XMSS_Tools::concat(secure_vector<byte>& target,
}
const byte* src_bytes = reinterpret_cast<const byte*>(&src);
- if(is_little_endian())
+ if(CPUID::is_little_endian())
std::reverse_copy(src_bytes,
src_bytes + c,
std::back_inserter(target));