* [PATCH] lib/crypto: tests: Annotate POLYVAL test vectors with __nonstring
@ 2026-12-04 13:11 HexCodeYT
0 siblings, 0 replies; only message in thread
From: HexCodeYT @ 2026-12-04 13:11 UTC (permalink / raw)
To: ebiggers, Jason, ardb; +Cc: linux-crypto
The RFC8452 POLYVAL test vectors use fixed-size binary arrays that
intentionally omit the terminating NUL byte.
GCC emits three diagnostics when
-Wunterminated-string-initialization is enabled because these
arrays lack the nonstring attribute.
Annotate raw_key, data and expected_hash with __nonstring to
eliminate these diagnostics without changing the array sizes or
test vector contents.
Verified by compiling polyval_kunit.o on arm64 with GCC 16.2.1
using -Werror=unterminated-string-initialization and with Clang
22.1.8. KUnit runtime tests were not run.
ChatGPT (GPT-6.2) assisted with the proposed annotations, test
procedure and commit message. The contributor independently
reviewed the changes and verified the compilation results.
Closes: https://github.com/KSPP/linux/issues/381
Signed-off-by: HexCodeYT <pawan@hexcode.au>
---
lib/crypto/tests/polyval_kunit.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/crypto/tests/polyval_kunit.c b/lib/crypto/tests/polyval_kunit.c
index 2835929e8..54fbde732 100644
--- a/lib/crypto/tests/polyval_kunit.c
+++ b/lib/crypto/tests/polyval_kunit.c
@@ -38,17 +38,17 @@ static void polyval_withtestkey(const u8 *data, size_t len,
*/
static void test_polyval_rfc8452_testvec(struct kunit *test)
{
- static const u8 raw_key[POLYVAL_BLOCK_SIZE] =
+ static const u8 raw_key[POLYVAL_BLOCK_SIZE] __nonstring =
"\x31\x07\x28\xd9\x91\x1f\x1f\x38"
"\x37\xb2\x43\x16\xc3\xfa\xb9\xa0";
- static const u8 data[48] =
+ static const u8 data[48] __nonstring =
"\x65\x78\x61\x6d\x70\x6c\x65\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00"
"\x48\x65\x6c\x6c\x6f\x20\x77\x6f"
"\x72\x6c\x64\x00\x00\x00\x00\x00"
"\x38\x00\x00\x00\x00\x00\x00\x00"
"\x58\x00\x00\x00\x00\x00\x00\x00";
- static const u8 expected_hash[POLYVAL_BLOCK_SIZE] =
+ static const u8 expected_hash[POLYVAL_BLOCK_SIZE] __nonstring =
"\xad\x7f\xcf\x0b\x51\x69\x85\x16"
"\x62\x67\x2f\x3c\x5f\x95\x13\x8f";
u8 hash[POLYVAL_BLOCK_SIZE];
--
2.56.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-04 13:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 13:11 [PATCH] lib/crypto: tests: Annotate POLYVAL test vectors with __nonstring HexCodeYT
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox