crypto: chacha20 - Fix keystream alignment for chacha20_block()
authorEric Biggers <ebiggers@google.com>
Wed, 22 Nov 2017 19:51:39 +0000 (11:51 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Jun 2022 09:46:24 +0000 (11:46 +0200)
commitf83ff022179e7ba4b5e14d96524fc0b74b6e3845
tree72a387195ea01a5b46a8e70819cec593b96efa99
parenta0764df52607180d3b3712d698f491196731844b
crypto: chacha20 - Fix keystream alignment for chacha20_block()

commit 9f480faec58cd6197a007ea1dcac6b7c3daf1139 upstream.

When chacha20_block() outputs the keystream block, it uses 'u32' stores
directly.  However, the callers (crypto/chacha20_generic.c and
drivers/char/random.c) declare the keystream buffer as a 'u8' array,
which is not guaranteed to have the needed alignment.

Fix it by having both callers declare the keystream as a 'u32' array.
For now this is preferable to switching over to the unaligned access
macros because chacha20_block() is only being used in cases where we can
easily control the alignment (stack buffers).

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
crypto/chacha20_generic.c
drivers/char/random.c
include/crypto/chacha20.h
lib/chacha20.c