From 7a45413771553a372b8b1db7eb99260e778d4414 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 11 Nov 2018 16:06:56 -0500 Subject: chacha20: enable sse2 path --- src/crypto/zinc/chacha20/chacha20-x86_64-glue.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/crypto/zinc/chacha20/chacha20-x86_64-glue.c') diff --git a/src/crypto/zinc/chacha20/chacha20-x86_64-glue.c b/src/crypto/zinc/chacha20/chacha20-x86_64-glue.c index f5a9c21..49a7105 100644 --- a/src/crypto/zinc/chacha20/chacha20-x86_64-glue.c +++ b/src/crypto/zinc/chacha20/chacha20-x86_64-glue.c @@ -10,6 +10,8 @@ asmlinkage void hchacha20_ssse3(u32 *derived_key, const u8 *nonce, const u8 *key); +asmlinkage void chacha20_sse2(u8 *out, const u8 *in, const size_t len, + const u32 key[8], const u32 counter[4]); asmlinkage void chacha20_ssse3(u8 *out, const u8 *in, const size_t len, const u32 key[8], const u32 counter[4]); asmlinkage void chacha20_avx2(u8 *out, const u8 *in, const size_t len, @@ -61,8 +63,7 @@ static inline bool chacha20_arch(struct chacha20_ctx *ctx, u8 *dst, BUILD_BUG_ON(PAGE_SIZE < CHACHA20_BLOCK_SIZE || PAGE_SIZE % CHACHA20_BLOCK_SIZE); - if (!IS_ENABLED(CONFIG_AS_SSSE3) || !chacha20_use_ssse3 || - len <= CHACHA20_BLOCK_SIZE || !simd_use(simd_context)) + if (len <= CHACHA20_BLOCK_SIZE || !simd_use(simd_context)) return false; for (;;) { @@ -77,8 +78,10 @@ static inline bool chacha20_arch(struct chacha20_ctx *ctx, u8 *dst, else if (IS_ENABLED(CONFIG_AS_AVX2) && chacha20_use_avx2 && len >= CHACHA20_BLOCK_SIZE * 4) chacha20_avx2(dst, src, bytes, ctx->key, ctx->counter); - else + else if (IS_ENABLED(CONFIG_AS_SSSE3) && chacha20_use_ssse3) chacha20_ssse3(dst, src, bytes, ctx->key, ctx->counter); + else + chacha20_sse2(dst, src, bytes, ctx->key, ctx->counter); ctx->counter[0] += (bytes + 63) / 64; len -= bytes; if (!len) -- cgit v1.2.3-59-g8ed1b