aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/crypto/zinc/poly1305/poly1305-x86_64-glue.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-09-18 02:18:47 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-09-18 04:21:16 +0200
commit7905a1f5dff38cc30af873461f083f30893adcbe (patch)
tree44e5b8aec599b509df0df1dc99d13d5e68d54022 /src/crypto/zinc/poly1305/poly1305-x86_64-glue.h
parentchacha20-x86_64: more limited cascade (diff)
downloadwireguard-monolithic-historical-7905a1f5dff38cc30af873461f083f30893adcbe.tar.xz
wireguard-monolithic-historical-7905a1f5dff38cc30af873461f083f30893adcbe.zip
crypto: allow for disabling simd in zinc modules
Diffstat (limited to 'src/crypto/zinc/poly1305/poly1305-x86_64-glue.h')
-rw-r--r--src/crypto/zinc/poly1305/poly1305-x86_64-glue.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/crypto/zinc/poly1305/poly1305-x86_64-glue.h b/src/crypto/zinc/poly1305/poly1305-x86_64-glue.h
index 0ca3485..2158863 100644
--- a/src/crypto/zinc/poly1305/poly1305-x86_64-glue.h
+++ b/src/crypto/zinc/poly1305/poly1305-x86_64-glue.h
@@ -71,7 +71,8 @@ static inline bool poly1305_blocks_arch(void *ctx, const u8 *inp,
{
struct poly1305_arch_internal *state = ctx;
- if ((len < (POLY1305_BLOCK_SIZE * 18) && !state->simd_is_engaged) ||
+ if (!poly1305_use_avx ||
+ (len < (POLY1305_BLOCK_SIZE * 18) && !state->simd_is_engaged) ||
!simd_use(simd_context))
poly1305_blocks_x86_64(ctx, inp, len, padbit);
else
@@ -98,18 +99,24 @@ static inline bool poly1305_emit_arch(void *ctx, u8 mac[POLY1305_MAC_SIZE],
const u32 nonce[4],
simd_context_t *simd_context)
{
+ struct poly1305_arch_internal *state = ctx;
+
+ if (!poly1305_use_avx || !state->simd_is_engaged ||
+ !simd_use(simd_context))
+ poly1305_emit_x86_64(ctx, mac, nonce);
+ else
#ifdef CONFIG_AS_AVX512
- if (poly1305_use_avx512 && simd_use(simd_context))
+ if (poly1305_use_avx512)
poly1305_emit_avx(ctx, mac, nonce);
else
#endif
#ifdef CONFIG_AS_AVX2
- if (poly1305_use_avx2 && simd_use(simd_context))
+ if (poly1305_use_avx2)
poly1305_emit_avx(ctx, mac, nonce);
else
#endif
#ifdef CONFIG_AS_AVX
- if (poly1305_use_avx && simd_use(simd_context))
+ if (poly1305_use_avx)
poly1305_emit_avx(ctx, mac, nonce);
else
#endif