32 #ifndef MCKL_RANDOM_INTERNAL_PHILOX_GENERIC_HPP 33 #define MCKL_RANDOM_INTERNAL_PHILOX_GENERIC_HPP 46 template <
typename T, std::size_t K, std::size_t Rounds,
typename Constants,
47 int = std::numeric_limits<T>::digits>
52 const void *plain,
void *cipher,
const std::array<T, K / 2> &key)
56 std::array<char, sizeof(T) * K> r;
59 std::memcpy(buf.s.data(), plain,
sizeof(T) * K);
60 union_le<char>(buf.s);
63 std::memcpy(cipher, buf.s.data(),
sizeof(T) * K);
66 template <
typename ResultType>
68 Counter<T, K> &ctr, ResultType *r,
const std::array<T, K / 2> &key)
73 std::array<ResultType,
sizeof(T) * K /
sizeof(ResultType)> r;
78 #if MCKL_REQUIRE_ENDIANNESS_NEUTURAL 79 union_le<typename Counter<T, K>::value_type>(buf.s);
82 #if MCKL_REQUIRE_ENDIANNESS_NEUTURAL 85 std::memcpy(r, buf.r.data(),
sizeof(T) * K);
88 template <
typename ResultType>
90 const std::array<T, K / 2> &key)
92 constexpr std::size_t R =
sizeof(T) * K /
sizeof(ResultType);
94 for (std::size_t i = 0; i != n; ++i, r += R) {
100 template <std::
size_t>
102 std::array<T, K> &,
const std::array<T, K / 2> &, std::false_type)
106 template <std::
size_t N>
108 std::array<T, K> &s,
const std::array<T, K / 2> &k, std::true_type)
113 template <std::
size_t N>
115 std::array<T, K> &s,
const std::array<T, K / 2> &k)
117 rbox<N>(s, k, std::integral_constant<bool, (N > 0 && N <= Rounds)>());
120 template <std::
size_t>
122 std::array<T, K> &,
const std::array<T, K / 2> &, std::false_type)
126 template <std::
size_t N>
128 std::array<T, K> &s,
const std::array<T, K / 2> &k, std::true_type)
134 template <
typename T,
typename Constants,
int D>
140 template <
typename T,
typename Constants>
146 template <
typename T,
typename Constants,
int D>
152 template <
typename T,
typename Constants>
162 #endif // MCKL_RANDOM_INTERNAL_PHILOX_GENERIC_HPP static void eval(Counter< T, K > &ctr, ResultType *r, const std::array< T, K/2 > &key)
static void eval(const void *plain, void *cipher, const std::array< T, K/2 > &key)
static void eval(std::array< T, K > &s, const std::array< T, K/2 > &k)
typename internal::CounterImpl< T, K >::type Counter
A counter type with the same width as std::array<T, K> but with possibly fewer elements.
#define MCKL_RANDOM_INTERNAL_PHILOX_UNROLL_ROUND(N, s, rk)
static void eval(Counter< T, K > &ctr, std::size_t n, ResultType *r, const std::array< T, K/2 > &key)
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.