This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 27c466a42 crypto: Fix CRC-32 test case 8
27c466a42 is described below

commit 27c466a4292b09557eda087811c32e75d5a347a8
Author: Peter Barada <[email protected]>
AuthorDate: Thu Jul 9 15:49:32 2026 -0400

    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 <[email protected]>
---
 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 */
 
-  for (i = 0; i < 8; i++)
+  ret = syscrc32_start(&crc32_ctx, &startval);
+  if (ret != 0)
     {
-      ret = syscrc32_start(&crc32_ctx, &startval);
-      if (ret != 0)
-        {
-          printf("syscrc32 start failed\n");
-          goto err;
-        }
+      printf("syscrc32 start failed\n");
+      goto err;
+    }
 
+  for (i = 0; i < 8; i++)
+    {
       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);

Reply via email to