7#ifndef BOTAN_POLYVAL_FN_H_
8#define BOTAN_POLYVAL_FN_H_
10#include <botan/internal/simd_4x32.h>
12#if defined(BOTAN_SIMD_USE_SSSE3)
13 #include <wmmintrin.h>
22 static_assert(M == 0x00 || M == 0x01 || M == 0x10 || M == 0x11,
"Valid clmul mode");
24#if defined(BOTAN_SIMD_USE_SSSE3)
26#elif defined(BOTAN_SIMD_USE_NEON)
27 const uint64_t a = vgetq_lane_u64(vreinterpretq_u64_u32(x.
raw()), M & 0x01);
28 const uint64_t b = vgetq_lane_u64(vreinterpretq_u64_u32(H.
raw()), (M & 0x10) >> 4);
30 #if defined(BOTAN_BUILD_COMPILER_IS_MSVC)
31 __n64 a1 = {a}, b1 = {b};
34 return SIMD_4x32(
reinterpret_cast<uint32x4_t
>(vmull_p64(a, b)));
37#elif defined(BOTAN_SIMD_USE_VSX)
39 constexpr uint8_t flip = (std::endian::native == std::endian::big) ? 0x11 : 0x00;
44 if constexpr(std::endian::native == std::endian::big) {
49 if constexpr(M == (0x11 ^ flip)) {
52 }
else if constexpr(M == (0x10 ^ flip)) {
54 }
else if constexpr(M == (0x01 ^ flip)) {
56 }
else if constexpr(M == (0x00 ^ flip)) {
57 i1 = mask_lo.
andc(i1);
58 i2 = mask_lo.
andc(i2);
61 auto i1v =
reinterpret_cast<__vector
unsigned long long>(i1.
raw());
62 auto i2v =
reinterpret_cast<__vector
unsigned long long>(i2.
raw());
64 #if BOTAN_COMPILER_HAS_BUILTIN(__builtin_crypto_vpmsumd)
65 auto rv = __builtin_crypto_vpmsumd(i1v, i2v);
67 auto rv = __builtin_altivec_crypto_vpmsumd(i1v, i2v);
70 auto z =
SIMD_4x32(
reinterpret_cast<__vector
unsigned int>(rv));
72 if constexpr(std::endian::native == std::endian::big) {
73 z = z.reverse_all_bytes().bswap();
105 const auto V =
SIMD_4x32(0x00000001, 0x00000000, 0x00000000, 0xc2000000);
111 const auto top_bits = h.
shr<31>().shift_elems_left<1>();
114 const auto shifted_h = h.
shl<1>() | top_bits;
116 return shifted_h ^ (mask & V);
135 const auto D = C ^ B.swap_halves();
void BOTAN_FN_ISA_SIMD_4X32 store_le(uint32_t out[4]) const noexcept
SIMD_4x32 BOTAN_FN_ISA_SIMD_4X32 top_bit_mask() const
SIMD_4x32 BOTAN_FN_ISA_SIMD_4X32 shr() const noexcept
static SIMD_4x32 BOTAN_FN_ISA_SIMD_4X32 load_le(const void *in) noexcept
SIMD_4x32 BOTAN_FN_ISA_SIMD_4X32 shl() const noexcept
BOTAN_FN_ISA_SIMD_4X32 SIMD_4x32 reverse_all_bytes() const
native_simd_type BOTAN_FN_ISA_SIMD_4X32 raw() const noexcept
SIMD_4x32 BOTAN_FN_ISA_SIMD_4X32 shift_elems_right() const noexcept
SIMD_4x32 BOTAN_FN_ISA_SIMD_4X32 andc(const SIMD_4x32 &other) const noexcept
BOTAN_FN_ISA_SIMD_4X32 SIMD_4x32 bswap() const noexcept
SIMD_4x32 BOTAN_FN_ISA_SIMD_4X32 shift_elems_left() const noexcept
SIMD_4x32 BOTAN_FN_ISA_SIMD_4X32 swap_halves() const
#define BOTAN_FORCE_INLINE
BOTAN_FORCE_INLINE SIMD_4x32 BOTAN_FN_ISA_SIMD_4X32 mulx_polyval(const SIMD_4x32 &h)
BOTAN_FORCE_INLINE BOTAN_FN_ISA_SIMD_4X32 SIMD_4x32 load_block(const uint8_t in[])
BOTAN_FORCE_INLINE SIMD_4x32 BOTAN_FN_ISA_CLMUL polyval_multiply(const SIMD_4x32 &H, const SIMD_4x32 &x)
BOTAN_FORCE_INLINE SIMD_4x32 BOTAN_FN_ISA_CLMUL polyval_reduce(const SIMD_4x32 &hi, const SIMD_4x32 &lo)
BOTAN_FORCE_INLINE BOTAN_FN_ISA_CLMUL SIMD_4x32 clmul(const SIMD_4x32 &H, const SIMD_4x32 &x)
BOTAN_FORCE_INLINE BOTAN_FN_ISA_SIMD_4X32 void store_block(const SIMD_4x32 &b, uint8_t out[])