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 <peter.barada@gmail.com>
This commit is contained in:
Peter Barada 2026-07-09 15:49:32 -04:00 committed by Xiang Xiao
parent d071a0b585
commit 27c466a429

View file

@ -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);