From: HexCodeYT <pawan@hexcode.au>
To: ebiggers@kernel.org, Jason@zx2c4.com, ardb@kernel.org
Cc: linux-crypto@vger.kernel.org
Subject: [PATCH] lib/crypto: tests: Annotate POLYVAL test vectors with __nonstring
Date: Sat, 5 Dec 2026 00:11:28 +1100 [thread overview]
Message-ID: <20261204131128.74519-1-pawan@hexcode.au> (raw)
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
reply other threads:[~2026-12-04 13:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204131128.74519-1-pawan@hexcode.au \
--to=pawan@hexcode.au \
--cc=Jason@zx2c4.com \
--cc=ardb@kernel.org \
--cc=ebiggers@kernel.org \
--cc=linux-crypto@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox