kernel: 5.4: import wireguard backport
[openwrt/openwrt.git] / target / linux / generic / backport-5.4 / 080-wireguard-0034-crypto-chacha_generic-remove-unnecessary-setkey-func.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Eric Biggers <ebiggers@google.com>
3 Date: Sun, 17 Nov 2019 23:21:29 -0800
4 Subject: [PATCH] crypto: chacha_generic - remove unnecessary setkey()
5 functions
6
7 commit 2043323a799a660bc84bbee404cf7a2617ec6157 upstream.
8
9 Use chacha20_setkey() and chacha12_setkey() from
10 <crypto/internal/chacha.h> instead of defining them again in
11 chacha_generic.c.
12
13 Signed-off-by: Eric Biggers <ebiggers@google.com>
14 Acked-by: Ard Biesheuvel <ardb@kernel.org>
15 Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
16 Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
17 ---
18 crypto/chacha_generic.c | 18 +++---------------
19 1 file changed, 3 insertions(+), 15 deletions(-)
20
21 --- a/crypto/chacha_generic.c
22 +++ b/crypto/chacha_generic.c
23 @@ -37,18 +37,6 @@ static int chacha_stream_xor(struct skci
24 return err;
25 }
26
27 -static int crypto_chacha20_setkey(struct crypto_skcipher *tfm, const u8 *key,
28 - unsigned int keysize)
29 -{
30 - return chacha_setkey(tfm, key, keysize, 20);
31 -}
32 -
33 -static int crypto_chacha12_setkey(struct crypto_skcipher *tfm, const u8 *key,
34 - unsigned int keysize)
35 -{
36 - return chacha_setkey(tfm, key, keysize, 12);
37 -}
38 -
39 static int crypto_chacha_crypt(struct skcipher_request *req)
40 {
41 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
42 @@ -91,7 +79,7 @@ static struct skcipher_alg algs[] = {
43 .max_keysize = CHACHA_KEY_SIZE,
44 .ivsize = CHACHA_IV_SIZE,
45 .chunksize = CHACHA_BLOCK_SIZE,
46 - .setkey = crypto_chacha20_setkey,
47 + .setkey = chacha20_setkey,
48 .encrypt = crypto_chacha_crypt,
49 .decrypt = crypto_chacha_crypt,
50 }, {
51 @@ -106,7 +94,7 @@ static struct skcipher_alg algs[] = {
52 .max_keysize = CHACHA_KEY_SIZE,
53 .ivsize = XCHACHA_IV_SIZE,
54 .chunksize = CHACHA_BLOCK_SIZE,
55 - .setkey = crypto_chacha20_setkey,
56 + .setkey = chacha20_setkey,
57 .encrypt = crypto_xchacha_crypt,
58 .decrypt = crypto_xchacha_crypt,
59 }, {
60 @@ -121,7 +109,7 @@ static struct skcipher_alg algs[] = {
61 .max_keysize = CHACHA_KEY_SIZE,
62 .ivsize = XCHACHA_IV_SIZE,
63 .chunksize = CHACHA_BLOCK_SIZE,
64 - .setkey = crypto_chacha12_setkey,
65 + .setkey = chacha12_setkey,
66 .encrypt = crypto_xchacha_crypt,
67 .decrypt = crypto_xchacha_crypt,
68 }