lib/crypto: chacha: Add at_least decoration to fixed-size array params
Add the at_least (i.e. 'static') decoration to the fixed-size array parameters of the chacha library functions. This causes clang to warn when a too-small array of known size is passed. Acked-by: Ard Biesheuvel <ardb@kernel.org> Acked-by: "Jason A. Donenfeld" <Jason@zx2c4.com> Link: https://lore.kernel.org/r/20251122194206.31822-2-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org>pull/1354/merge
parent
ac653d57ad
commit
1b31b43bf5
|
|
@ -38,18 +38,18 @@ struct chacha_state {
|
||||||
};
|
};
|
||||||
|
|
||||||
void chacha_block_generic(struct chacha_state *state,
|
void chacha_block_generic(struct chacha_state *state,
|
||||||
u8 out[CHACHA_BLOCK_SIZE], int nrounds);
|
u8 out[at_least CHACHA_BLOCK_SIZE], int nrounds);
|
||||||
static inline void chacha20_block(struct chacha_state *state,
|
static inline void chacha20_block(struct chacha_state *state,
|
||||||
u8 out[CHACHA_BLOCK_SIZE])
|
u8 out[at_least CHACHA_BLOCK_SIZE])
|
||||||
{
|
{
|
||||||
chacha_block_generic(state, out, 20);
|
chacha_block_generic(state, out, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hchacha_block_generic(const struct chacha_state *state,
|
void hchacha_block_generic(const struct chacha_state *state,
|
||||||
u32 out[HCHACHA_OUT_WORDS], int nrounds);
|
u32 out[at_least HCHACHA_OUT_WORDS], int nrounds);
|
||||||
|
|
||||||
void hchacha_block(const struct chacha_state *state,
|
void hchacha_block(const struct chacha_state *state,
|
||||||
u32 out[HCHACHA_OUT_WORDS], int nrounds);
|
u32 out[at_least HCHACHA_OUT_WORDS], int nrounds);
|
||||||
|
|
||||||
enum chacha_constants { /* expand 32-byte k */
|
enum chacha_constants { /* expand 32-byte k */
|
||||||
CHACHA_CONSTANT_EXPA = 0x61707865U,
|
CHACHA_CONSTANT_EXPA = 0x61707865U,
|
||||||
|
|
@ -67,8 +67,8 @@ static inline void chacha_init_consts(struct chacha_state *state)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void chacha_init(struct chacha_state *state,
|
static inline void chacha_init(struct chacha_state *state,
|
||||||
const u32 key[CHACHA_KEY_WORDS],
|
const u32 key[at_least CHACHA_KEY_WORDS],
|
||||||
const u8 iv[CHACHA_IV_SIZE])
|
const u8 iv[at_least CHACHA_IV_SIZE])
|
||||||
{
|
{
|
||||||
chacha_init_consts(state);
|
chacha_init_consts(state);
|
||||||
state->x[4] = key[0];
|
state->x[4] = key[0];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue