28 #define AESNI_KEY_ROUNDS(x) (10 + x *2) 29 #define AESNI_KEY_BYTES(x) (16 + x * 8) 39 r1 ^= _mm_slli_si128 (r1, 4);
40 r1 ^= _mm_slli_si128 (r1, 4);
41 r1 ^= _mm_slli_si128 (r1, 4);
42 return r1 ^ _mm_shuffle_epi32 (r2, 0xff);
48 k[0] = _mm_loadu_si128 ((
const __m128i *) key);
65 *r1 ^= r = _mm_slli_si128 (*r1, 0x4);
66 *r1 ^= r = _mm_slli_si128 (r, 0x4);
67 *r1 ^= _mm_slli_si128 (r, 0x4);
68 *r1 ^= _mm_shuffle_epi32 (*r2, 0x55);
69 *r3 ^= _mm_slli_si128 (*r3, 0x4);
70 *r3 ^= *r2 = _mm_shuffle_epi32 (*r1, 0xff);
78 k[0] = r1 = _mm_loadu_si128 ((__m128i *) key);
83 r2 = _mm_aeskeygenassist_si128 (r3, 0x1);
85 k[1] = (__m128i) _mm_shuffle_pd ((__m128d) k[1], (__m128d) r1, 0);
86 k[2] = (__m128i) _mm_shuffle_pd ((__m128d) r1, (__m128d) r3, 1);
87 r2 = _mm_aeskeygenassist_si128 (r3, 0x2);
92 r2 = _mm_aeskeygenassist_si128 (r3, 0x4);
94 k[4] = (__m128i) _mm_shuffle_pd ((__m128d) k[4], (__m128d) r1, 0);
95 k[5] = (__m128i) _mm_shuffle_pd ((__m128d) r1, (__m128d) r3, 1);
96 r2 = _mm_aeskeygenassist_si128 (r3, 0x8);
101 r2 = _mm_aeskeygenassist_si128 (r3, 0x10);
103 k[7] = (__m128i) _mm_shuffle_pd ((__m128d) k[7], (__m128d) r1, 0);
104 k[8] = (__m128i) _mm_shuffle_pd ((__m128d) r1, (__m128d) r3, 1);
105 r2 = _mm_aeskeygenassist_si128 (r3, 0x20);
110 r2 = _mm_aeskeygenassist_si128 (r3, 0x40);
112 k[10] = (__m128i) _mm_shuffle_pd ((__m128d) k[10], (__m128d) r1, 0);
113 k[11] = (__m128i) _mm_shuffle_pd ((__m128d) r1, (__m128d) r3, 1);
114 r2 = _mm_aeskeygenassist_si128 (r3, 0x80);
123 *r1 ^= r = _mm_slli_si128 (*r1, 0x4);
124 *r1 ^= r = _mm_slli_si128 (r, 0x4);
125 *r1 ^= _mm_slli_si128 (r, 0x4);
126 *r1 ^= *r2 = _mm_shuffle_epi32 (*r2, 0xff);
133 *r3 ^= r = _mm_slli_si128 (*r3, 0x4);
134 *r3 ^= r = _mm_slli_si128 (r, 0x4);
135 *r3 ^= _mm_slli_si128 (r, 0x4);
136 *r3 ^= _mm_shuffle_epi32 (_mm_aeskeygenassist_si128 (r1, 0x0), 0xaa);
143 k[0] = r1 = _mm_loadu_si128 ((__m128i *) key);
144 k[1] = r3 = _mm_loadu_si128 ((__m128i *) (key + 16));
145 r2 = _mm_aeskeygenassist_si128 (k[1], 0x01);
150 r2 = _mm_aeskeygenassist_si128 (r3, 0x02);
155 r2 = _mm_aeskeygenassist_si128 (r3, 0x04);
160 r2 = _mm_aeskeygenassist_si128 (r3, 0x08);
165 r2 = _mm_aeskeygenassist_si128 (r3, 0x10);
170 r2 = _mm_aeskeygenassist_si128 (r3, 0x20);
175 r2 = _mm_aeskeygenassist_si128 (r3, 0x40);
208 for (
int i = 1;
i < (rounds / 2);
i++)
211 k[rounds -
i] = _mm_aesimc_si128 (k[
i]);
212 k[
i] = _mm_aesimc_si128 (r);
215 k[rounds / 2] = _mm_aesimc_si128 (k[rounds / 2]);
static_always_inline void aes192_key_expand(__m128i *k, u8 *key)
#define AESNI_KEY_ROUNDS(x)
static_always_inline void aes_key_expand(__m128i *k, u8 *key, aesni_key_size_t ks)
static_always_inline __m128i aes128_key_assist(__m128i r1, __m128i r2)
#define static_always_inline
static_always_inline void aes256_key_expand(__m128i *k, u8 *key)
static_always_inline void aes256_key_assist1(__m128i *r1, __m128i *r2)
static_always_inline void aes256_key_assist2(__m128i r1, __m128i *r3)
static_always_inline void aes128_key_expand(__m128i *k, u8 *key)
static_always_inline void aes_key_enc_to_dec(__m128i *k, aesni_key_size_t ks)
static_always_inline void aes192_key_assist(__m128i *r1, __m128i *r2, __m128i *r3)
#define CLIB_MEM_OVERFLOW_LOAD(f, src)