diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2020-03-23 23:55:21 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-03-23 23:55:21 +0100 |
commit | 979e52ca0469fb38646bc51d26a0263a740c9f03 (patch) | |
tree | 30e74fe523f2114c76bce93863fec38955d58fa4 /lib | |
parent | Linux 5.6-rc7 (diff) | |
parent | crypto: arm64/chacha - correctly walk through blocks (diff) | |
download | linux-979e52ca0469fb38646bc51d26a0263a740c9f03.tar.xz linux-979e52ca0469fb38646bc51d26a0263a740c9f03.zip |
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fix from Herbert Xu:
"This fixes a correctness bug in the ARM64 version of ChaCha for
lib/crypto used by WireGuard"
* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
crypto: arm64/chacha - correctly walk through blocks
Diffstat (limited to 'lib')
-rw-r--r-- | lib/crypto/chacha20poly1305-selftest.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/crypto/chacha20poly1305-selftest.c b/lib/crypto/chacha20poly1305-selftest.c index c391a91364e9..fa43deda2660 100644 --- a/lib/crypto/chacha20poly1305-selftest.c +++ b/lib/crypto/chacha20poly1305-selftest.c @@ -9028,10 +9028,15 @@ bool __init chacha20poly1305_selftest(void) && total_len <= 1 << 10; ++total_len) { for (i = 0; i <= total_len; ++i) { for (j = i; j <= total_len; ++j) { + k = 0; sg_init_table(sg_src, 3); - sg_set_buf(&sg_src[0], input, i); - sg_set_buf(&sg_src[1], input + i, j - i); - sg_set_buf(&sg_src[2], input + j, total_len - j); + if (i) + sg_set_buf(&sg_src[k++], input, i); + if (j - i) + sg_set_buf(&sg_src[k++], input + i, j - i); + if (total_len - j) + sg_set_buf(&sg_src[k++], input + j, total_len - j); + sg_init_marker(sg_src, k); memset(computed_output, 0, total_len); memset(input, 0, total_len); |