Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

lib/crypto: sha1: 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 sha1 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-6-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>

+7 -5
+7 -5
include/crypto/sha1.h
··· 84 84 * 85 85 * Context: Any context. 86 86 */ 87 - void sha1_final(struct sha1_ctx *ctx, u8 out[SHA1_DIGEST_SIZE]); 87 + void sha1_final(struct sha1_ctx *ctx, u8 out[at_least SHA1_DIGEST_SIZE]); 88 88 89 89 /** 90 90 * sha1() - Compute SHA-1 message digest in one shot ··· 94 94 * 95 95 * Context: Any context. 96 96 */ 97 - void sha1(const u8 *data, size_t len, u8 out[SHA1_DIGEST_SIZE]); 97 + void sha1(const u8 *data, size_t len, u8 out[at_least SHA1_DIGEST_SIZE]); 98 98 99 99 /** 100 100 * struct hmac_sha1_key - Prepared key for HMAC-SHA1 ··· 181 181 * 182 182 * Context: Any context. 183 183 */ 184 - void hmac_sha1_final(struct hmac_sha1_ctx *ctx, u8 out[SHA1_DIGEST_SIZE]); 184 + void hmac_sha1_final(struct hmac_sha1_ctx *ctx, 185 + u8 out[at_least SHA1_DIGEST_SIZE]); 185 186 186 187 /** 187 188 * hmac_sha1() - Compute HMAC-SHA1 in one shot, using a prepared key ··· 196 195 * Context: Any context. 197 196 */ 198 197 void hmac_sha1(const struct hmac_sha1_key *key, 199 - const u8 *data, size_t data_len, u8 out[SHA1_DIGEST_SIZE]); 198 + const u8 *data, size_t data_len, 199 + u8 out[at_least SHA1_DIGEST_SIZE]); 200 200 201 201 /** 202 202 * hmac_sha1_usingrawkey() - Compute HMAC-SHA1 in one shot, using a raw key ··· 214 212 */ 215 213 void hmac_sha1_usingrawkey(const u8 *raw_key, size_t raw_key_len, 216 214 const u8 *data, size_t data_len, 217 - u8 out[SHA1_DIGEST_SIZE]); 215 + u8 out[at_least SHA1_DIGEST_SIZE]); 218 216 219 217 #endif /* _CRYPTO_SHA1_H */