10#include <botan/internal/bit_ops.h>
11#include <botan/internal/isa_extn.h>
12#include <botan/internal/simd_4x32.h>
26consteval std::array<uint8_t, 256 * 32> zfec_vperm_table() {
27 std::array<uint8_t, 256 * 32> tbl = {};
29 for(
size_t y = 0; y != 256; ++y) {
30 for(
size_t i = 0; i != 16; ++i) {
31 tbl[32 * y + i] =
poly_mul<0x1D>(
static_cast<uint8_t
>(i),
static_cast<uint8_t
>(y));
32 tbl[32 * y + 16 + i] =
poly_mul<0x1D>(
static_cast<uint8_t
>(i << 4),
static_cast<uint8_t
>(y));
39alignas(256)
constexpr auto GFTBL = zfec_vperm_table();
45BOTAN_FN_ISA_SIMD_4X32
void vperm_linear_combination_pass(
46 uint8_t z[],
const uint8_t*
const x[],
const uint8_t y[],
bool accum,
size_t size) {
51 for(
size_t t = 0; t != N; ++t) {
57 while(off + 16 <= size) {
60 for(
size_t t = 0; t != N; ++t) {
64 const auto x_lo = x_t & mask;
66 const auto x_hi = x_t.shr<4>() & mask;
80BOTAN_FN_ISA_SIMD_4X32
size_t
81ZFEC::linear_combination_vperm(uint8_t z[],
const uint8_t*
const x[],
const uint8_t y[],
size_t k,
size_t size) {
82 const size_t blocks = size - (size % 16);
90 vperm_linear_combination_pass<4>(z, x + j, y + j, j > 0, blocks);
94 vperm_linear_combination_pass<2>(z, x + j, y + j, j > 0, blocks);
98 vperm_linear_combination_pass<1>(z, x + j, y + j, j > 0, blocks);
void BOTAN_FN_ISA_SIMD_4X32 store_le(uint32_t out[4]) const noexcept
static SIMD_4x32 BOTAN_FN_ISA_SIMD_4X32 load_le(const void *in) noexcept
static SIMD_4x32 BOTAN_FN_ISA_SIMD_4X32 byte_shuffle(const SIMD_4x32 &tbl, const SIMD_4x32 &idx)
static SIMD_4x32 BOTAN_FN_ISA_SIMD_4X32 splat_u8(uint8_t B) noexcept
constexpr T poly_mul(T x, uint8_t y)