32 #ifndef MCKL_RANDOM_INTERNAL_THREEFRY_GENERIC_HPP 33 #define MCKL_RANDOM_INTERNAL_THREEFRY_GENERIC_HPP 51 template <
typename T, std::size_t K, std::size_t Rounds,
typename Constants,
52 int = std::numeric_limits<T>::digits>
57 const void *plain,
void *cipher,
const std::array<T, K + 4> &par)
61 std::array<char, sizeof(T) * K> r;
64 std::memcpy(buf.s.data(), plain,
sizeof(T) * K);
65 union_le<char>(buf.s);
68 std::memcpy(cipher, buf.s.data(),
sizeof(T) * K);
71 template <
typename ResultType>
73 Counter<T, K> &ctr, ResultType *r,
const std::array<T, K + 4> &par)
78 std::array<ResultType,
sizeof(T) * K /
sizeof(ResultType)> r;
83 #if MCKL_REQUIRE_ENDIANNESS_NEUTURAL 84 union_le<typename Counter<T, K>::value_type>(buf.s);
87 #if MCKL_REQUIRE_ENDIANNESS_NEUTURAL 90 std::memcpy(r, buf.r.data(),
sizeof(T) * K);
93 template <
typename ResultType>
95 const std::array<T, K + 4> &par)
97 constexpr std::size_t rstride =
sizeof(T) * K /
sizeof(ResultType);
99 for (std::size_t i = 0; i != n; ++i, r += rstride) {
105 template <std::
size_t>
107 std::array<T, K> &,
const std::array<T, K + 4> &, std::false_type)
111 template <std::
size_t N>
113 std::array<T, K> &s,
const std::array<T, K + 4> &par, std::true_type)
118 template <std::
size_t N>
120 std::array<T, K> &s,
const std::array<T, K + 4> &par)
123 std::integral_constant<bool, (N % 4 == 0 && N <= Rounds)>());
126 template <std::
size_t N>
128 std::array<T, K> &,
const std::array<T, K + 4> &, std::false_type)
132 template <std::
size_t N>
134 std::array<T, K> &s,
const std::array<T, K + 4> &par, std::true_type)
139 template <std::
size_t N>
142 rbox<N>(s, std::integral_constant<bool, (N > 0 && N <= Rounds)>());
145 template <std::
size_t N>
146 static void rbox(std::array<T, K> &, std::false_type)
150 template <std::
size_t N>
151 static void rbox(std::array<T, K> &s, std::true_type)
157 template <
typename T>
163 template <
typename T>
169 template <
typename T>
175 template <
typename T>
181 template <
typename T>
187 template <
typename T>
193 template <
typename T>
199 template <
typename T>
205 template <
typename T>
215 #endif // MCKL_RANDOM_INTERNAL_THREEFRY_GENERIC_HPP
static void eval(const void *plain, void *cipher, const std::array< T, K+4 > &par)
typename internal::CounterImpl< T, K >::type Counter
A counter type with the same width as std::array<T, K> but with possibly fewer elements.
static void eval(Counter< T, K > &ctr, std::size_t n, ResultType *r, const std::array< T, K+4 > &par)
static void eval(std::array< T, K > &s)
#define MCKL_RANDOM_INTERNAL_THREEFRY_UNROLL_ROUND(N, s, par)
Default Threefry constants.
void increment(std::array< T, K > &ctr, std::integral_constant< T, NSkip >)
Increment a counter by given steps.
#define MCKL_ALIGNMENT
The default alignment for scalar type.
static void eval(Counter< T, K > &ctr, ResultType *r, const std::array< T, K+4 > &par)
static void eval(std::array< T, K > &s, const std::array< T, K+4 > &par)