crypto: chacha20 - Fix keystream alignment for chacha20_block()

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>
This commit is contained in:
Eric Biggers
2017-11-22 11:51:39 -08:00
zatwierdzone przez Herbert Xu
rodzic 796c99fbd7
commit 9f480faec5
4 zmienionych plików z 18 dodań i 17 usunięć

Wyświetl plik

@@ -21,7 +21,7 @@ static inline u32 rotl32(u32 v, u8 n)
return (v << n) | (v >> (sizeof(v) * 8 - n));
}
extern void chacha20_block(u32 *state, void *stream)
void chacha20_block(u32 *state, u32 *stream)
{
u32 x[16], *out = stream;
int i;