diff options
author | 2025-05-05 11:18:22 -0700 | |
---|---|---|
committer | 2025-05-12 13:32:53 +0800 | |
commit | 32c9541189eb31ba6b25e2ff28e42660394a62af (patch) | |
tree | ff4c599abd810c65b6b5e6ff590b16395bf55ab9 /lib | |
parent | crypto: lib/chacha - strongly type the ChaCha state (diff) | |
download | linux-rng-32c9541189eb31ba6b25e2ff28e42660394a62af.tar.xz linux-rng-32c9541189eb31ba6b25e2ff28e42660394a62af.zip |
crypto: lib/chacha - use struct assignment to copy state
Use struct assignment instead of memcpy() in lib/crypto/chacha.c where
appropriate. No functional change.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/crypto/chacha.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/crypto/chacha.c b/lib/crypto/chacha.c index a7f5eb091839..ae50e441f9fb 100644 --- a/lib/crypto/chacha.c +++ b/lib/crypto/chacha.c @@ -76,11 +76,9 @@ static void chacha_permute(struct chacha_state *state, int nrounds) */ void chacha_block_generic(struct chacha_state *state, u8 *stream, int nrounds) { - struct chacha_state permuted_state; + struct chacha_state permuted_state = *state; int i; - memcpy(permuted_state.x, state->x, 64); - chacha_permute(&permuted_state, nrounds); for (i = 0; i < ARRAY_SIZE(state->x); i++) @@ -105,9 +103,7 @@ EXPORT_SYMBOL(chacha_block_generic); void hchacha_block_generic(const struct chacha_state *state, u32 *stream, int nrounds) { - struct chacha_state permuted_state; - - memcpy(permuted_state.x, state->x, 64); + struct chacha_state permuted_state = *state; chacha_permute(&permuted_state, nrounds); |