8#include <botan/internal/noekeon.h>
9#include <botan/internal/loadstor.h>
10#include <botan/internal/rotate.h>
11#include <botan/internal/cpuid.h>
20inline void theta(uint32_t& A0, uint32_t& A1,
21 uint32_t& A2, uint32_t& A3,
25 T ^= rotl<8>(
T) ^ rotr<8>(
T);
35 T ^= rotl<8>(
T) ^ rotr<8>(
T);
43inline void theta(uint32_t& A0, uint32_t& A1,
44 uint32_t& A2, uint32_t& A3)
47 T ^= rotl<8>(
T) ^ rotr<8>(
T);
52 T ^= rotl<8>(
T) ^ rotr<8>(
T);
60inline void gamma(uint32_t& A0, uint32_t& A1, uint32_t& A2, uint32_t& A3)
79#if defined(BOTAN_HAS_NOEKEON_SIMD)
91#if defined(BOTAN_HAS_NOEKEON_SIMD)
104const uint8_t Noekeon::RC[] = {
105 0x80, 0x1B, 0x36, 0x6C, 0xD8, 0xAB, 0x4D, 0x9A,
106 0x2F, 0x5E, 0xBC, 0x63, 0xC6, 0x97, 0x35, 0x6A,
116#if defined(BOTAN_HAS_NOEKEON_SIMD)
121 simd_encrypt_4(in, out);
129 for(
size_t i = 0; i != blocks; ++i)
136 for(
size_t j = 0; j != 16; ++j)
139 theta(A0, A1, A2, A3, m_EK.data());
145 gamma(A0, A1, A2, A3);
153 theta(A0, A1, A2, A3, m_EK.data());
169#if defined(BOTAN_HAS_NOEKEON_SIMD)
174 simd_decrypt_4(in, out);
182 for(
size_t i = 0; i != blocks; ++i)
189 for(
size_t j = 16; j != 0; --j)
191 theta(A0, A1, A2, A3, m_DK.data());
198 gamma(A0, A1, A2, A3);
205 theta(A0, A1, A2, A3, m_DK.data());
217 return !m_EK.empty();
223void Noekeon::key_schedule(
const uint8_t key[],
size_t )
230 for(
size_t i = 0; i != 16; ++i)
233 theta(A0, A1, A2, A3);
239 gamma(A0, A1, A2, A3);
254 theta(A0, A1, A2, A3);
static bool has_simd_32()
size_t parallelism() const override
void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
std::string provider() const override
void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
bool has_keying_material() const override
void assert_key_material_set() const
void zap(std::vector< T, Alloc > &vec)
void theta(SIMD_4x32 &A0, SIMD_4x32 &A1, SIMD_4x32 &A2, SIMD_4x32 &A3, const SIMD_4x32 &K0, const SIMD_4x32 &K1, const SIMD_4x32 &K2, const SIMD_4x32 &K3)
constexpr uint32_t load_be< uint32_t >(const uint8_t in[], size_t off)
constexpr void store_be(uint16_t in, uint8_t out[2])
void gamma(SIMD_4x32 &A0, SIMD_4x32 &A1, SIMD_4x32 &A2, SIMD_4x32 &A3)