]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
crypto: lib/chacha - strongly type the ChaCha state
authorEric Biggers <ebiggers@google.com>
Mon, 5 May 2025 18:18:21 +0000 (11:18 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 12 May 2025 05:32:53 +0000 (13:32 +0800)
commit98066f2f8901ccf72f3c5d6c391c8fff1cabd49d
treea88e8b02bcfc5fbc4a1b71213ba078d98c07fba1
parent97855e7f1ccf4917f305baab199edb9f2595ff5b
crypto: lib/chacha - strongly type the ChaCha state

The ChaCha state matrix is 16 32-bit words.  Currently it is represented
in the code as a raw u32 array, or even just a pointer to u32.  This
weak typing is error-prone.  Instead, introduce struct chacha_state:

    struct chacha_state {
            u32 x[16];
    };

Convert all ChaCha and HChaCha functions to use struct chacha_state.
No functional changes.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
19 files changed:
arch/arm/lib/crypto/chacha-glue.c
arch/arm/lib/crypto/chacha-scalar-core.S
arch/arm64/lib/crypto/chacha-neon-glue.c
arch/mips/lib/crypto/chacha-glue.c
arch/powerpc/lib/crypto/chacha-p10-glue.c
arch/powerpc/lib/crypto/chacha-p10le-8x.S
arch/riscv/lib/crypto/chacha-riscv64-glue.c
arch/riscv/lib/crypto/chacha-riscv64-zvkb.S
arch/s390/lib/crypto/chacha-glue.c
arch/x86/lib/crypto/chacha_glue.c
crypto/chacha.c
drivers/char/random.c
fs/bcachefs/checksum.c
include/crypto/chacha.h
lib/crypto/chacha.c
lib/crypto/chacha20poly1305-selftest.c
lib/crypto/chacha20poly1305.c
lib/crypto/libchacha.c
tools/testing/crypto/chacha20-s390/test-cipher.c