[PATCH] t-kem: fix test loop iteration

Jussi Kivilinna jussi.kivilinna at iki.fi
Wed Sep 17 18:02:41 CEST 2025


* tests/t-kem.c (check_kem): Reset loop iterator for each algo test loop.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
 tests/t-kem.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/tests/t-kem.c b/tests/t-kem.c
index cafb68b1..dee879a0 100644
--- a/tests/t-kem.c
+++ b/tests/t-kem.c
@@ -483,17 +483,17 @@ check_kem (int n_loops)
   info ("Checking KEM.\n");
 
   ntests = 0;
-  testno = 0;
+
   if ((selected_algo & SELECTED_ALGO_SNTRUP761))
     {
-      for (; testno < n_loops; testno++)
+      for (testno = 0; testno < n_loops; testno++)
         test_kem_sntrup761 (testno);
       ntests += n_loops;
     }
 
   if ((selected_algo & SELECTED_ALGO_CM6688128F))
     {
-      for (; testno < n_loops; testno++)
+      for (testno = 0; testno < n_loops; testno++)
         test_kem_mceliece6688128f (testno);
       ntests += n_loops;
     }
@@ -501,21 +501,21 @@ check_kem (int n_loops)
 #ifdef USE_KYBER
   if ((selected_algo & SELECTED_ALGO_MLKEM512))
     {
-      for (; testno < ntests + n_loops; testno++)
+      for (testno = 0; testno < ntests + n_loops; testno++)
         test_kem_mlkem512 (testno);
       ntests += n_loops;
     }
 
   if ((selected_algo & SELECTED_ALGO_MLKEM768))
     {
-      for (; testno < ntests + n_loops; testno++)
+      for (testno = 0; testno < ntests + n_loops; testno++)
         test_kem_mlkem768 (testno);
       ntests += n_loops;
     }
 
   if ((selected_algo & SELECTED_ALGO_MLKEM1024))
     {
-      for (; testno < ntests + n_loops; testno++)
+      for (testno = 0; testno < ntests + n_loops; testno++)
         test_kem_mlkem1024 (testno);
       ntests += n_loops;
     }
@@ -523,14 +523,14 @@ check_kem (int n_loops)
 
   if ((selected_algo & SELECTED_ALGO_RAW_X25519))
     {
-      for (; testno < ntests + n_loops; testno++)
+      for (testno = 0; testno < ntests + n_loops; testno++)
         test_kem_raw_x25519 (testno);
       ntests += n_loops;
     }
 
   if ((selected_algo & SELECTED_ALGO_DHKEM25519))
     {
-      for (; testno < ntests + n_loops; testno++)
+      for (testno = 0; testno < ntests + n_loops; testno++)
         test_kem_dhkem_x25519 (testno);
       ntests += n_loops;
     }
-- 
2.48.1




More information about the Gcrypt-devel mailing list