lib/crypto: md5: 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 md5 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-4-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
pull/1354/merge
Eric Biggers 2025-11-22 11:42:03 -08:00
parent 2143d622cd
commit 580f1d31df
1 changed files with 6 additions and 5 deletions

View File

@ -76,7 +76,7 @@ void md5_update(struct md5_ctx *ctx, const u8 *data, size_t len);
*
* Context: Any context.
*/
void md5_final(struct md5_ctx *ctx, u8 out[MD5_DIGEST_SIZE]);
void md5_final(struct md5_ctx *ctx, u8 out[at_least MD5_DIGEST_SIZE]);
/**
* md5() - Compute MD5 message digest in one shot
@ -86,7 +86,7 @@ void md5_final(struct md5_ctx *ctx, u8 out[MD5_DIGEST_SIZE]);
*
* Context: Any context.
*/
void md5(const u8 *data, size_t len, u8 out[MD5_DIGEST_SIZE]);
void md5(const u8 *data, size_t len, u8 out[at_least MD5_DIGEST_SIZE]);
/**
* struct hmac_md5_key - Prepared key for HMAC-MD5
@ -173,7 +173,7 @@ static inline void hmac_md5_update(struct hmac_md5_ctx *ctx,
*
* Context: Any context.
*/
void hmac_md5_final(struct hmac_md5_ctx *ctx, u8 out[MD5_DIGEST_SIZE]);
void hmac_md5_final(struct hmac_md5_ctx *ctx, u8 out[at_least MD5_DIGEST_SIZE]);
/**
* hmac_md5() - Compute HMAC-MD5 in one shot, using a prepared key
@ -187,7 +187,8 @@ void hmac_md5_final(struct hmac_md5_ctx *ctx, u8 out[MD5_DIGEST_SIZE]);
* Context: Any context.
*/
void hmac_md5(const struct hmac_md5_key *key,
const u8 *data, size_t data_len, u8 out[MD5_DIGEST_SIZE]);
const u8 *data, size_t data_len,
u8 out[at_least MD5_DIGEST_SIZE]);
/**
* hmac_md5_usingrawkey() - Compute HMAC-MD5 in one shot, using a raw key
@ -204,6 +205,6 @@ void hmac_md5(const struct hmac_md5_key *key,
*/
void hmac_md5_usingrawkey(const u8 *raw_key, size_t raw_key_len,
const u8 *data, size_t data_len,
u8 out[MD5_DIGEST_SIZE]);
u8 out[at_least MD5_DIGEST_SIZE]);
#endif /* _CRYPTO_MD5_H */