aboutsummaryrefslogtreecommitdiff
path: root/crypto/chacha20_generic.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-09-01 10:30:03 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-01 10:30:03 -0700
commita1c516a60a702630347e27c7beb7f2f44ca7a8b5 (patch)
treebfb6c8d70457ff7596ebdba8f0d9c1233bffa93f /crypto/chacha20_generic.c
parente89ce1f89f62c7e527db3850a91dab3389772af3 (diff)
parent445a582738de6802669aeed9c33ca406c23c3b1f (diff)
downloadlinux-stericsson-a1c516a60a702630347e27c7beb7f2f44ca7a8b5.tar.gz
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fixes from Herbert Xu: "This fixes the following issues: - Regression in chacha20 handling of chunked input - Crash in algif_skcipher when used with async io - Potential bogus pointer dereference in lib/mpi" * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: crypto: algif_skcipher - only call put_page on referenced and used pages crypto: testmgr - add chunked test cases for chacha20 crypto: chacha20 - fix handling of chunked input lib/mpi: kunmap after finishing accessing buffer
Diffstat (limited to 'crypto/chacha20_generic.c')
-rw-r--r--crypto/chacha20_generic.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/crypto/chacha20_generic.c b/crypto/chacha20_generic.c
index 8b3c04d625c3..4a45fa4890c0 100644
--- a/crypto/chacha20_generic.c
+++ b/crypto/chacha20_generic.c
@@ -91,9 +91,14 @@ int crypto_chacha20_crypt(struct skcipher_request *req)
crypto_chacha20_init(state, ctx, walk.iv);
while (walk.nbytes > 0) {
+ unsigned int nbytes = walk.nbytes;
+
+ if (nbytes < walk.total)
+ nbytes = round_down(nbytes, walk.stride);
+
chacha20_docrypt(state, walk.dst.virt.addr, walk.src.virt.addr,
- walk.nbytes);
- err = skcipher_walk_done(&walk, 0);
+ nbytes);
+ err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
}
return err;