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

Configure Feed

Select the types of activity you want to include in your feed.

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

+14 -10
+14 -10
include/crypto/curve25519.h
··· 13 13 CURVE25519_KEY_SIZE = 32 14 14 }; 15 15 16 - void curve25519_generic(u8 out[CURVE25519_KEY_SIZE], 17 - const u8 scalar[CURVE25519_KEY_SIZE], 18 - const u8 point[CURVE25519_KEY_SIZE]); 16 + void curve25519_generic(u8 out[at_least CURVE25519_KEY_SIZE], 17 + const u8 scalar[at_least CURVE25519_KEY_SIZE], 18 + const u8 point[at_least CURVE25519_KEY_SIZE]); 19 19 20 - bool __must_check curve25519(u8 mypublic[CURVE25519_KEY_SIZE], 21 - const u8 secret[CURVE25519_KEY_SIZE], 22 - const u8 basepoint[CURVE25519_KEY_SIZE]); 20 + bool __must_check 21 + curve25519(u8 mypublic[at_least CURVE25519_KEY_SIZE], 22 + const u8 secret[at_least CURVE25519_KEY_SIZE], 23 + const u8 basepoint[at_least CURVE25519_KEY_SIZE]); 23 24 24 - bool __must_check curve25519_generate_public(u8 pub[CURVE25519_KEY_SIZE], 25 - const u8 secret[CURVE25519_KEY_SIZE]); 25 + bool __must_check 26 + curve25519_generate_public(u8 pub[at_least CURVE25519_KEY_SIZE], 27 + const u8 secret[at_least CURVE25519_KEY_SIZE]); 26 28 27 - static inline void curve25519_clamp_secret(u8 secret[CURVE25519_KEY_SIZE]) 29 + static inline void 30 + curve25519_clamp_secret(u8 secret[at_least CURVE25519_KEY_SIZE]) 28 31 { 29 32 secret[0] &= 248; 30 33 secret[31] = (secret[31] & 127) | 64; 31 34 } 32 35 33 - static inline void curve25519_generate_secret(u8 secret[CURVE25519_KEY_SIZE]) 36 + static inline void 37 + curve25519_generate_secret(u8 secret[at_least CURVE25519_KEY_SIZE]) 34 38 { 35 39 get_random_bytes_wait(secret, CURVE25519_KEY_SIZE); 36 40 curve25519_clamp_secret(secret);