X-Git-Url: https://www.bearssl.org/gitweb//home/git/?p=BearSSL;a=blobdiff_plain;f=src%2Fsymcipher%2Faes_x86ni_ctr.c;h=1cddd6065dd7058e5073a557bf680950c99a0397;hp=41c31b2634a50e0b0971e9916383235fcdd05b7d;hb=b715b43e411dc5d5949df6f75ef7bb65952db11c;hpb=2f88a673049d1e183d1a8f78e2030bf02362b8bf diff --git a/src/symcipher/aes_x86ni_ctr.c b/src/symcipher/aes_x86ni_ctr.c index 41c31b2..1cddd60 100644 --- a/src/symcipher/aes_x86ni_ctr.c +++ b/src/symcipher/aes_x86ni_ctr.c @@ -22,24 +22,17 @@ * SOFTWARE. */ +#define BR_ENABLE_INTRINSICS 1 #include "inner.h" #if BR_AES_X86NI -#if BR_AES_X86NI_GCC -#if BR_AES_X86NI_GCC_OLD -#pragma GCC target("sse2,sse4.1,aes,pclmul") -#endif -#include -#include -#define bswap32 __builtin_bswap32 -#endif - -#if BR_AES_X86NI_MSC -#include -#include -#define bswap32 _byteswap_ulong -#endif +/* see bearssl_block.h */ +const br_block_ctr_class * +br_aes_x86ni_ctr_get_vtable(void) +{ + return br_aes_x86ni_supported() ? &br_aes_x86ni_ctr_vtable : NULL; +} /* see bearssl_block.h */ void @@ -50,6 +43,8 @@ br_aes_x86ni_ctr_init(br_aes_x86ni_ctr_keys *ctx, ctx->num_rounds = br_aes_x86ni_keysched_enc(ctx->skey.skni, key, len); } +BR_TARGETS_X86_UP + /* see bearssl_block.h */ BR_TARGET("sse2,sse4.1,aes") uint32_t @@ -73,10 +68,10 @@ br_aes_x86ni_ctr_run(const br_aes_x86ni_ctr_keys *ctx, while (len > 0) { __m128i x0, x1, x2, x3; - x0 = _mm_insert_epi32(ivx, bswap32(cc + 0), 3); - x1 = _mm_insert_epi32(ivx, bswap32(cc + 1), 3); - x2 = _mm_insert_epi32(ivx, bswap32(cc + 2), 3); - x3 = _mm_insert_epi32(ivx, bswap32(cc + 3), 3); + x0 = _mm_insert_epi32(ivx, br_bswap32(cc + 0), 3); + x1 = _mm_insert_epi32(ivx, br_bswap32(cc + 1), 3); + x2 = _mm_insert_epi32(ivx, br_bswap32(cc + 2), 3); + x3 = _mm_insert_epi32(ivx, br_bswap32(cc + 3), 3); x0 = _mm_xor_si128(x0, sk[0]); x1 = _mm_xor_si128(x1, sk[0]); x2 = _mm_xor_si128(x2, sk[0]); @@ -190,6 +185,8 @@ br_aes_x86ni_ctr_run(const br_aes_x86ni_ctr_keys *ctx, return cc; } +BR_TARGETS_X86_DOWN + /* see bearssl_block.h */ const br_block_ctr_class br_aes_x86ni_ctr_vtable = { sizeof(br_aes_x86ni_ctr_keys), @@ -202,13 +199,6 @@ const br_block_ctr_class br_aes_x86ni_ctr_vtable = { &br_aes_x86ni_ctr_run }; -/* see bearssl_block.h */ -const br_block_ctr_class * -br_aes_x86ni_ctr_get_vtable(void) -{ - return br_aes_x86ni_supported() ? &br_aes_x86ni_ctr_vtable : NULL; -} - #else /* see bearssl_block.h */