aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-09-17 06:03:38 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-09-17 06:03:38 +0200
commit511ff33bf574476eb61b0c9d218a628b0dcb2d8d (patch)
tree86648057f201a23f8c5f8f45e9f7c7c56eb56e7b
parentcrypto: pass simd by reference (diff)
downloadwireguard-monolithic-historical-511ff33bf574476eb61b0c9d218a628b0dcb2d8d.tar.xz
wireguard-monolithic-historical-511ff33bf574476eb61b0c9d218a628b0dcb2d8d.zip
chacha20-x86_64: don't activate simd for small blocks
-rw-r--r--src/crypto/zinc/chacha20/chacha20-x86_64-glue.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/crypto/zinc/chacha20/chacha20-x86_64-glue.h b/src/crypto/zinc/chacha20/chacha20-x86_64-glue.h
index 34919c7..aef9697 100644
--- a/src/crypto/zinc/chacha20/chacha20-x86_64-glue.h
+++ b/src/crypto/zinc/chacha20/chacha20-x86_64-glue.h
@@ -61,7 +61,8 @@ static inline bool chacha20_arch(u8 *dst, const u8 *src, const size_t len,
const u32 key[8], const u32 counter[4],
simd_context_t *simd_context)
{
- if (!simd_use(simd_context))
+ if ((len < CHACHA20_BLOCK_SIZE && !(*simd_context && HAVE_SIMD_IN_USE)) ||
+ !simd_use(simd_context))
return false;
#ifdef CONFIG_AS_AVX512