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-30 03:07:51 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-10-02 03:41:49 +0200
commit26b94a83ba634669cfcc0fc362ffe1f2eaefb43f (patch)
tree9dcf99b3d71414beee6ad924e667f66bd7173708 /src/crypto/zinc/chacha20/chacha20-x86_64-glue.h
parentqemu: support m68k (diff)
downloadwireguard-monolithic-historical-26b94a83ba634669cfcc0fc362ffe1f2eaefb43f.tar.xz
wireguard-monolithic-historical-26b94a83ba634669cfcc0fc362ffe1f2eaefb43f.zip
chacha20: split chacha20_ctx into union
This avoids casts and makes counter increments obvious.
Diffstat (limited to '')
-rw-r--r--src/crypto/zinc/chacha20/chacha20-x86_64-glue.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/crypto/zinc/chacha20/chacha20-x86_64-glue.h b/src/crypto/zinc/chacha20/chacha20-x86_64-glue.h
index 2939f1e..b1fc4c8 100644
--- a/src/crypto/zinc/chacha20/chacha20-x86_64-glue.h
+++ b/src/crypto/zinc/chacha20/chacha20-x86_64-glue.h
@@ -50,7 +50,7 @@ static void __init chacha20_fpu_init(void)
#endif
}
-static inline bool chacha20_arch(struct chacha20_ctx *state, u8 *dst,
+static inline bool chacha20_arch(struct chacha20_ctx *ctx, u8 *dst,
const u8 *src, size_t len,
simd_context_t *simd_context)
{
@@ -67,16 +67,16 @@ static inline bool chacha20_arch(struct chacha20_ctx *state, u8 *dst,
if (IS_ENABLED(CONFIG_AS_AVX512) && chacha20_use_avx512 &&
len >= CHACHA20_BLOCK_SIZE * 8)
- chacha20_avx512(dst, src, bytes, state->key, state->counter);
+ chacha20_avx512(dst, src, bytes, ctx->key, ctx->counter);
else if (IS_ENABLED(CONFIG_AS_AVX512) && chacha20_use_avx512vl &&
len >= CHACHA20_BLOCK_SIZE * 4)
- chacha20_avx512vl(dst, src, bytes, state->key, state->counter);
+ chacha20_avx512vl(dst, src, bytes, ctx->key, ctx->counter);
else if (IS_ENABLED(CONFIG_AS_AVX2) && chacha20_use_avx2 &&
len >= CHACHA20_BLOCK_SIZE * 4)
- chacha20_avx2(dst, src, bytes, state->key, state->counter);
+ chacha20_avx2(dst, src, bytes, ctx->key, ctx->counter);
else
- chacha20_ssse3(dst, src, bytes, state->key, state->counter);
- state->counter[0] += (bytes + 63) / 64;
+ chacha20_ssse3(dst, src, bytes, ctx->key, ctx->counter);
+ ctx->counter[0] += (bytes + 63) / 64;
len -= bytes;
if (!len)
break;