7#include <botan/internal/ctr.h>
9#include <botan/assert.h>
10#include <botan/internal/simd_avx2.h>
15size_t CTR_BE::ctr_proc_bs16_ctr4_avx2(
const uint8_t* in, uint8_t* out,
size_t length) {
19 const size_t pad_size = m_pad.size();
20 if(length < pad_size) {
24 const size_t ctr_blocks = m_ctr_blocks;
29 const SIMD_8x32 bswap_ctr(
30 0x03020100, 0x07060504, 0x0B0A0908, 0x0C0D0E0F, 0x03020100, 0x07060504, 0x0B0A0908, 0x0C0D0E0F);
36 const SIMD_8x32 inc4(0, 0, 0, 4);
38 const uint32_t N =
static_cast<uint32_t
>(ctr_blocks);
39 SIMD_8x32 batch_ctr0 = starting_ctr + SIMD_8x32(0, 0, 0, N, 0, 0, 0, N + 1);
40 SIMD_8x32 batch_ctr1 = starting_ctr + SIMD_8x32(0, 0, 0, N + 2, 0, 0, 0, N + 3);
41 const uint8_t* pad_buf = m_pad.data();
42 uint8_t* ctr_buf = m_counter.data();
44 const size_t ctr_block_quads = ctr_blocks / 4;
48 while(length >= pad_size) {
49 for(
size_t i = 0; i != ctr_block_quads; ++i) {
50 const size_t off = i * 64;
67 i0.store_le(out + off);
68 i1.store_le(out + off + 32);
74 processed += pad_size;
77 m_cipher->encrypt_n(m_counter.data(), m_pad.data(), ctr_blocks);
#define BOTAN_ASSERT_NOMSG(expr)
#define BOTAN_DEBUG_ASSERT(expr)
static BOTAN_FN_ISA_AVX2 SIMD_8x32 load_le128(const uint8_t *in) noexcept
static BOTAN_FN_ISA_AVX2 SIMD_8x32 load_le(const uint8_t *in) noexcept
static SIMD_8x32 BOTAN_FN_ISA_AVX2 byte_shuffle(const SIMD_8x32 &tbl, const SIMD_8x32 &idx)
BOTAN_FN_ISA_AVX2 void store_le(uint8_t out[]) const noexcept