diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-09-20 16:31:01 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-09-21 16:05:22 +0200 |
commit | f61fb1b86c28225353ee67802b512c8529d21fb0 (patch) | |
tree | 19ed9b2463f47fca15b706d82faf8080a5c28742 /src/crypto/zinc/chacha20/chacha20-x86_64-glue.h | |
parent | 08edd02db06f9dd424bc023703fed8ea8c42c97d (diff) |
chacha20-arm: go with Ard's version to optimize for Cortex-A7
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/crypto/zinc/chacha20/chacha20-x86_64-glue.h')
-rw-r--r-- | src/crypto/zinc/chacha20/chacha20-x86_64-glue.h | 23 |
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, |