From 27c466a4292b09557eda087811c32e75d5a347a8 Mon Sep 17 00:00:00 2001 From: Peter Barada Date: Thu, 9 Jul 2026 15:49:32 -0400 Subject: [PATCH] crypto: Fix CRC-32 test case 8 Normal Crypto API usage is to call ioctl(CGCGSESSION) to initialize the session, then one (or more) calls to ioctl(CIOCCRYPT) with flag bit COP_FLAG_UPDATE set to append to the hash/xform calculation, then a call to ioctl(CIOCCRYPT) with flag bit COP_FLAG_UPDATE cleared to extract the result, and finally ioctl(CIOCFSESSION) to finish the session. This follows the classic init / update* / finish data processing model. However crc32.c test case 8 precedes ioctl(CIOCCRYPT) with COP_FLAG_UPDATE set with ioctl(CIOCGSESSION) and follows it with ioctl(CIOCCRYPT) with COP_FLAG_UPDATE cleared to extract the CRC, and then ioctl(CIOCFSESSION) to finish the session, all _within_ the loop to CRC eight segments. This works with the software implementation since the intermediate CRC-32 is carried forward out of one session to seed the next session. Fix by moving the init and finish portions out of the loop in test case 8. Signed-off-by: Peter Barada --- testing/drivers/crypto/crc32.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/testing/drivers/crypto/crc32.c b/testing/drivers/crypto/crc32.c index f21fd8d28..89aa98cdc 100644 --- a/testing/drivers/crypto/crc32.c +++ b/testing/drivers/crypto/crc32.c @@ -258,15 +258,15 @@ int main(void) /* testcase 8: test segmented computing capabilities in crc32 mode */ + ret = syscrc32_start(&crc32_ctx, &startval); + if (ret != 0) + { + printf("syscrc32 start failed\n"); + goto err; + } + for (i = 0; i < 8; i++) { - ret = syscrc32_start(&crc32_ctx, &startval); - if (ret != 0) - { - printf("syscrc32 start failed\n"); - goto err; - } - ret = syscrc32_update(&crc32_ctx, g_crc32_testcase[7].data, g_crc32_testcase[7].datalen); if (ret) @@ -274,13 +274,13 @@ int main(void) printf("syscrc32 update failed\n"); goto err; } + } - ret = syscrc32_finish(&crc32_ctx, &startval); - if (ret) - { - printf("syscrc32 finish failed\n"); - goto err; - } + ret = syscrc32_finish(&crc32_ctx, &startval); + if (ret) + { + printf("syscrc32 finish failed\n"); + goto err; } ret = match(g_crc32_testcase[7].result, startval);