aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/crypto
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-09-19 04:02:01 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-09-20 00:57:59 +0200
commitaa9e0904955015a880b8bb3ecc29c03f56043fe1 (patch)
treea33a2136b03d19cba4dbbd03227ec7ac042a904f /src/crypto
parentpoly1305: no need to trick gcc 8.1 (diff)
downloadwireguard-monolithic-historical-aa9e0904955015a880b8bb3ecc29c03f56043fe1.tar.xz
wireguard-monolithic-historical-aa9e0904955015a880b8bb3ecc29c03f56043fe1.zip
chacha20: prefer crypto_xor_cpy to avoid memmove
Suggested-by: Eric Biggers <ebiggers@kernel.org>
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/zinc/chacha20/chacha20.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/crypto/zinc/chacha20/chacha20.c b/src/crypto/zinc/chacha20/chacha20.c
index a7c7adc..72e24da 100644
--- a/src/crypto/zinc/chacha20/chacha20.c
+++ b/src/crypto/zinc/chacha20/chacha20.c
@@ -105,18 +105,16 @@ static void chacha20_generic(u8 *out, const u8 *in, u32 len, const u32 key[8],
counter[0], counter[1], counter[2], counter[3]
};
- if (out != in)
- memmove(out, in, len);
-
while (len >= CHACHA20_BLOCK_SIZE) {
chacha20_block_generic(buf, x);
- crypto_xor(out, (u8 *)buf, CHACHA20_BLOCK_SIZE);
+ crypto_xor_cpy(out, in, (u8 *)buf, CHACHA20_BLOCK_SIZE);
len -= CHACHA20_BLOCK_SIZE;
out += CHACHA20_BLOCK_SIZE;
+ in += CHACHA20_BLOCK_SIZE;
}
if (len) {
chacha20_block_generic(buf, x);
- crypto_xor(out, (u8 *)buf, len);
+ crypto_xor_cpy(out, in, (u8 *)buf, len);
}
}