aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/crypto/zinc/chacha20/chacha20-x86_64-glue.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-09-20 16:31:01 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-09-21 16:05:22 +0200
commit09247c03ab40754365a506a150531f4582826077 (patch)
tree44d6a1d4d9a5b94e7efcf4f5987e8b11a3b97d1d /src/crypto/zinc/chacha20/chacha20-x86_64-glue.h
parentchacha20-mips32r2: remove reorder directives (diff)
downloadwireguard-monolithic-historical-09247c03ab40754365a506a150531f4582826077.tar.xz
wireguard-monolithic-historical-09247c03ab40754365a506a150531f4582826077.zip
chacha20-arm: go with Ard's version to optimize for Cortex-A7
Diffstat (limited to 'src/crypto/zinc/chacha20/chacha20-x86_64-glue.h')
-rw-r--r--src/crypto/zinc/chacha20/chacha20-x86_64-glue.h23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/crypto/zinc/chacha20/chacha20-x86_64-glue.h b/src/crypto/zinc/chacha20/chacha20-x86_64-glue.h
index 46fe24c..77dacf6 100644
--- a/src/crypto/zinc/chacha20/chacha20-x86_64-glue.h
+++ b/src/crypto/zinc/chacha20/chacha20-x86_64-glue.h
@@ -56,8 +56,8 @@ static void __init chacha20_fpu_init(void)
#endif
}
-static inline bool chacha20_arch(u8 *dst, const u8 *src, const size_t len,
- const u32 key[8], const u32 counter[4],
+static inline bool chacha20_arch(struct chacha20_ctx *state, u8 *dst,
+ const u8 *src, const size_t len,
simd_context_t *simd_context)
{
if (!chacha20_use_ssse3 || len <= CHACHA20_BLOCK_SIZE ||
@@ -66,27 +66,30 @@ static inline bool chacha20_arch(u8 *dst, const u8 *src, const size_t len,
#ifdef CONFIG_AS_AVX512
if (chacha20_use_avx512 && len >= CHACHA20_BLOCK_SIZE * 8) {
- chacha20_avx512(dst, src, len, key, counter);
- return true;
+ chacha20_avx512(dst, src, len, state->key, state->counter);
+ goto success;
}
if (chacha20_use_avx512vl && len >= CHACHA20_BLOCK_SIZE * 4) {
- chacha20_avx512vl(dst, src, len, key, counter);
- return true;
+ chacha20_avx512vl(dst, src, len, state->key, state->counter);
+ goto success;
}
#endif
#ifdef CONFIG_AS_AVX2
if (chacha20_use_avx2 && len >= CHACHA20_BLOCK_SIZE * 4) {
- chacha20_avx2(dst, src, len, key, counter);
- return true;
+ chacha20_avx2(dst, src, len, state->key, state->counter);
+ goto success;
}
#endif
#ifdef CONFIG_AS_SSSE3
if (chacha20_use_ssse3) {
- chacha20_ssse3(dst, src, len, key, counter);
- return true;
+ chacha20_ssse3(dst, src, len, state->key, state->counter);
+ goto success;
}
#endif
return false;
+success:
+ state->counter[0] += (len + 63) / 64;
+ return true;
}
static inline bool hchacha20_arch(u8 *derived_key, const u8 *nonce,