1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Eric Biggers <ebiggers@google.com>
3 Date: Sun, 17 Nov 2019 23:22:16 -0800
4 Subject: [PATCH] crypto: lib/chacha20poly1305 - use chacha20_crypt()
6 commit 413808b71e6204b0cc1eeaa77960f7c3cd381d33 upstream.
8 Use chacha20_crypt() instead of chacha_crypt(), since it's not really
9 appropriate for users of the ChaCha library API to be passing the number
10 of rounds as an argument.
12 Signed-off-by: Eric Biggers <ebiggers@google.com>
13 Acked-by: Ard Biesheuvel <ardb@kernel.org>
14 Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
15 Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
17 lib/crypto/chacha20poly1305.c | 16 ++++++++--------
18 1 file changed, 8 insertions(+), 8 deletions(-)
20 --- a/lib/crypto/chacha20poly1305.c
21 +++ b/lib/crypto/chacha20poly1305.c
22 @@ -66,14 +66,14 @@ __chacha20poly1305_encrypt(u8 *dst, cons
26 - chacha_crypt(chacha_state, b.block0, pad0, sizeof(b.block0), 20);
27 + chacha20_crypt(chacha_state, b.block0, pad0, sizeof(b.block0));
28 poly1305_init(&poly1305_state, b.block0);
30 poly1305_update(&poly1305_state, ad, ad_len);
32 poly1305_update(&poly1305_state, pad0, 0x10 - (ad_len & 0xf));
34 - chacha_crypt(chacha_state, dst, src, src_len, 20);
35 + chacha20_crypt(chacha_state, dst, src, src_len);
37 poly1305_update(&poly1305_state, dst, src_len);
39 @@ -140,7 +140,7 @@ __chacha20poly1305_decrypt(u8 *dst, cons
40 if (unlikely(src_len < POLY1305_DIGEST_SIZE))
43 - chacha_crypt(chacha_state, b.block0, pad0, sizeof(b.block0), 20);
44 + chacha20_crypt(chacha_state, b.block0, pad0, sizeof(b.block0));
45 poly1305_init(&poly1305_state, b.block0);
47 poly1305_update(&poly1305_state, ad, ad_len);
48 @@ -160,7 +160,7 @@ __chacha20poly1305_decrypt(u8 *dst, cons
50 ret = crypto_memneq(b.mac, src + dst_len, POLY1305_DIGEST_SIZE);
52 - chacha_crypt(chacha_state, dst, src, dst_len, 20);
53 + chacha20_crypt(chacha_state, dst, src, dst_len);
55 memzero_explicit(&b, sizeof(b));
57 @@ -241,7 +241,7 @@ bool chacha20poly1305_crypt_sg_inplace(s
58 b.iv[1] = cpu_to_le64(nonce);
60 chacha_init(chacha_state, b.k, (u8 *)b.iv);
61 - chacha_crypt(chacha_state, b.block0, pad0, sizeof(b.block0), 20);
62 + chacha20_crypt(chacha_state, b.block0, pad0, sizeof(b.block0));
63 poly1305_init(&poly1305_state, b.block0);
65 if (unlikely(ad_len)) {
66 @@ -278,14 +278,14 @@ bool chacha20poly1305_crypt_sg_inplace(s
68 if (unlikely(length < sl))
69 l &= ~(CHACHA_BLOCK_SIZE - 1);
70 - chacha_crypt(chacha_state, addr, addr, l, 20);
71 + chacha20_crypt(chacha_state, addr, addr, l);
76 if (unlikely(length > 0)) {
77 - chacha_crypt(chacha_state, b.chacha_stream, pad0,
78 - CHACHA_BLOCK_SIZE, 20);
79 + chacha20_crypt(chacha_state, b.chacha_stream, pad0,
81 crypto_xor(addr, b.chacha_stream, length);