Convert more functions to macros

This commit is contained in:
Frank Denis 2015-10-11 00:43:44 +02:00
parent 69aac7d0af
commit 0b20d292df

View File

@ -415,68 +415,72 @@ do { \
__m128i in##a = _mm_load_si128((const __m128i *) (in + a * 16)); __m128i in##a = _mm_load_si128((const __m128i *) (in + a * 16));
/* full encrypt & checksum 8 blocks at once */ /* full encrypt & checksum 8 blocks at once */
static inline void #define aesni_encrypt8full(out_, n_, rkeys, in_, accum, hv_, h2v_, h3v_, h4v_) \
aesni_encrypt8full(unsigned char *out, uint32_t *n, const __m128i *rkeys, do { \
const unsigned char *in, unsigned char *accum, unsigned char *out = out_; \
const __m128i hv, const __m128i h2v, const __m128i h3v, uint32_t *n = n_; \
const __m128i h4v) const unsigned char *in = in_; \
{ const __m128i hv = hv_; \
const __m128i pt = _mm_set_epi8(12, 13, 14, 15, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); const __m128i h2v = h2v_; \
const __m128i rev = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); const __m128i h3v = h3v_; \
__m128i accv = _mm_loadu_si128((const __m128i *) accum); const __m128i h4v = h4v_; \
int i; const __m128i pt = _mm_set_epi8(12, 13, 14, 15, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); \
const __m128i rev = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); \
MAKE8(NVDECLx); __m128i accv = _mm_loadu_si128((const __m128i *) accum); \
MAKE8(TEMPDECLx); int i; \
MAKE8(NVx); \
MAKE8(TEMPx); MAKE8(NVDECLx); \
#pragma unroll(13) MAKE8(TEMPDECLx); \
for (i = 1; i < 14; i++) { MAKE8(NVx); \
MAKE8(AESENCx); MAKE8(TEMPx); \
} for (i = 1; i < 14; i++) { \
MAKE8(AESENCLASTx); MAKE8(AESENCx); \
MAKE8(XORx); } \
MAKE8(STOREx); MAKE8(AESENCLASTx); \
REDUCE4(rev, hv, h2v, h3v, h4v, temp3, temp2, temp1, temp0, accv); MAKE8(XORx); \
REDUCE4(rev, hv, h2v, h3v, h4v, temp7, temp6, temp5, temp4, accv); MAKE8(STOREx); \
_mm_storeu_si128((__m128i *) accum, accv); REDUCE4(rev, hv, h2v, h3v, h4v, temp3, temp2, temp1, temp0, accv); \
} REDUCE4(rev, hv, h2v, h3v, h4v, temp7, temp6, temp5, temp4, accv); \
_mm_storeu_si128((__m128i *) accum, accv); \
} while(0)
/* checksum 8 blocks at once */ /* checksum 8 blocks at once */
static inline void #define aesni_addmul8full(in_, accum, hv_, h2v_, h3v_, h4v_) \
aesni_addmul8full(const unsigned char *in, unsigned char *accum, do { \
const __m128i hv, const __m128i h2v, const unsigned char *in = in_; \
const __m128i h3v, const __m128i h4v) const __m128i hv = hv_; \
{ const __m128i h2v = h2v_ ; \
const __m128i rev = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); const __m128i h3v = h3v_ ; \
__m128i accv = _mm_loadu_si128((const __m128i *) accum); const __m128i h4v = h4v_ ; \
const __m128i rev = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); \
MAKE8(LOADx); __m128i accv = _mm_loadu_si128((const __m128i *) accum); \
REDUCE4(rev, hv, h2v, h3v, h4v, in3, in2, in1, in0, accv); \
REDUCE4(rev, hv, h2v, h3v, h4v, in7, in6, in5, in4, accv); MAKE8(LOADx); \
_mm_storeu_si128((__m128i *) accum, accv); REDUCE4(rev, hv, h2v, h3v, h4v, in3, in2, in1, in0, accv); \
} REDUCE4(rev, hv, h2v, h3v, h4v, in7, in6, in5, in4, accv); \
_mm_storeu_si128((__m128i *) accum, accv); \
} while(0)
/* decrypt 8 blocks at once */ /* decrypt 8 blocks at once */
static inline void #define aesni_decrypt8full(out_, n_, rkeys, in_) \
aesni_decrypt8full(unsigned char *out, uint32_t *n, const __m128i *rkeys, do { \
const unsigned char *in) unsigned char *out = out_; \
{ uint32_t *n = n_; \
const __m128i pt = _mm_set_epi8(12, 13, 14, 15, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); const unsigned char *in = in_; \
int i; const __m128i pt = _mm_set_epi8(12, 13, 14, 15, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); \
int i; \
MAKE8(NVDECLx); \
MAKE8(TEMPDECLx); MAKE8(NVDECLx); \
MAKE8(NVx); MAKE8(TEMPDECLx); \
MAKE8(TEMPx); MAKE8(NVx); \
#pragma unroll(13) MAKE8(TEMPx); \
for (i = 1; i < 14; i++) { for (i = 1; i < 14; i++) { \
MAKE8(AESENCx); MAKE8(AESENCx); \
} } \
MAKE8(AESENCLASTx); MAKE8(AESENCLASTx); \
MAKE8(XORx); MAKE8(XORx); \
MAKE8(STOREx); MAKE8(STOREx); \
} } while(0)
int int
crypto_aead_aes256gcm_aesni_beforenm(crypto_aead_aes256gcm_aesni_state *ctx_, crypto_aead_aes256gcm_aesni_beforenm(crypto_aead_aes256gcm_aesni_state *ctx_,