]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Fixes for ecdsa-sign-test in noasm and mini-gmp builds.
authorNiels Möller <nisse@lysator.liu.se>
Tue, 14 Nov 2023 19:40:29 +0000 (20:40 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Tue, 14 Nov 2023 19:40:29 +0000 (20:40 +0100)
ChangeLog
ecc-pm1-redc.c
ecc-pp1-redc.c
ecc-secp192r1.c
ecc-secp384r1.c
testsuite/ecdsa-sign-test.c

index 276556676749b8be540eedbf14a9d0e656f8986e..e65ddf78ad68cf0246f8b720ae6d189023f35f9d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
        * ecc-mod-arith.c: Convert most asserts to assert_maybe.
        * ecc-mod-inv.c (ecc_mod_inv): Likewise.
        * ecc-mod.c (ecc_mod): Likewise.
+       * ecc-pm1-redc.c (ecc_pm1_redc): Likewise.
+       * ecc-pp1-redc.c (ecc_pp1_redc): Likewise.
+       * ecc-secp192r1.c (ecc_secp192r1_modp): Likewise.
+       * ecc-secp384r1.c (ecc_secp384r1_modp): Likewise.
        * testsuite/ecdsa-sign-test.c (test_ecdsa): Add calls to
        mark_bytes_undefined and mark_bytes_defined.
-       (test_main): Skip test if both side channel tests and extra
-       asserts are enabled.
+       (test_main): Skip side-channel tests in builds with mini-gmp or
+       extra asserts enabled.
        * testsuite/sc-ecdsa-sign-test: New testcase.
        * testsuite/Makefile.in (TS_SC): Add sc-ecdsa-sign-test.
 
index cc95c6e407d1c272b9720aff670f2de63203ce02..0f728a37ed70390457988a88ce2884d1f3e0f283 100644 (file)
@@ -54,7 +54,7 @@ ecc_pm1_redc (const struct ecc_modulo *m, mp_limb_t *rp, mp_limb_t *xp)
                          m->redc_mpm1, m->size - k, xp[i]);
   hi = mpn_sub_n (xp, xp + m->size, xp, m->size);
   cy = mpn_cnd_add_n (hi, rp, xp, m->m, m->size);
-  assert (cy == hi);
+  assert_maybe (cy == hi);
 
   if (shift > 0)
     {
index b088c4c575d2450e73a69e68d9524bb70f916f9a..c472204196af4f60c63158d26e301aeb763688d1 100644 (file)
@@ -64,6 +64,6 @@ ecc_pp1_redc (const struct ecc_modulo *m, mp_limb_t *rp, mp_limb_t *xp)
   else
     {
       cy = mpn_cnd_sub_n (hi, rp, rp, m->m, m->size);
-      assert (cy == hi);      
+      assert_maybe (cy == hi);
     }
 }
index 4a07bca31c3f83d404436ea3e6897cd90bce407f..6097622bd2edb0a637a5f10607ebed783f9c860a 100644 (file)
@@ -90,7 +90,7 @@ ecc_secp192r1_modp (const struct ecc_modulo *m UNUSED, mp_limb_t *rp, mp_limb_t
   cy = mpn_add_n (xp + 1, xp + 1, xp + 4, 2);
   cy = sec_add_1 (xp + 3, xp + 3, 1, cy);
   cy += mpn_add_n (xp + 2, xp + 2, xp + 4, 2);
-  assert (cy <= 2);
+  assert_maybe (cy <= 2);
 
   xp[4] = cy;
 
@@ -99,9 +99,9 @@ ecc_secp192r1_modp (const struct ecc_modulo *m UNUSED, mp_limb_t *rp, mp_limb_t
   cy = sec_add_1 (xp + 2, xp + 2, 1, cy);
   cy += mpn_add_n (xp + 1, xp + 1, xp + 3, 2);
 
-  assert (cy <= 1);
+  assert_maybe (cy <= 1);
   cy = mpn_cnd_add_n (cy, rp, xp, ecc_Bmodp, 3);
-  assert (cy == 0);  
+  assert_maybe (cy == 0);
 }
   
 #else
index abac5e6d449f61f4927a11759878042014b4b22c..bf5f402f39076d9d4db6886974bb53e9c134ea68 100644 (file)
@@ -122,7 +122,7 @@ ecc_secp384r1_modp (const struct ecc_modulo *p, mp_limb_t *rp, mp_limb_t *xp)
   cy += mpn_add_n (xp + 2, xp + 2, tp, 6);
   cy += mpn_add_n (xp + 4, xp + 4, xp + 8, 4);
 
-  assert (cy <= 2);
+  assert_maybe (cy <= 2);
   xp[8] = cy;
 
   /* Reduce from 9 to 6 limbs */
@@ -137,10 +137,10 @@ ecc_secp384r1_modp (const struct ecc_modulo *p, mp_limb_t *rp, mp_limb_t *xp)
   cy += mpn_add_n (xp + 2, xp + 2, xp + 6, 3);
 
   cy = sec_add_1 (xp + 5, xp + 5, 1, cy);
-  assert (cy <= 1);
+  assert_maybe (cy <= 1);
 
   cy = mpn_cnd_add_n (cy, xp, xp, p->B, ECC_LIMB_SIZE);
-  assert (cy == 0);
+  assert_maybe (cy == 0);
   mpn_copyi (rp, xp, ECC_LIMB_SIZE);
 }
 #else
index a3c43568f686537fb8304e7654cd836d7c23bcde..46fc27384d2fa9e7359746f33ce022a3529fd2f2 100644 (file)
@@ -70,7 +70,7 @@ test_ecdsa (const struct ecc_curve *ecc,
 void
 test_main (void)
 {
-#if WITH_EXTRA_ASSERTS
+#if NETTLE_USE_MINI_GMP || WITH_EXTRA_ASSERTS
   if (test_side_channel)
     SKIP();
 #endif