diff --git a/ChangeLog b/ChangeLog index 276556676749b8be540eedbf14a9d0e656f8986e..e65ddf78ad68cf0246f8b720ae6d189023f35f9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,10 +10,14 @@ * 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. diff --git a/ecc-pm1-redc.c b/ecc-pm1-redc.c index cc95c6e407d1c272b9720aff670f2de63203ce02..0f728a37ed70390457988a88ce2884d1f3e0f283 100644 --- a/ecc-pm1-redc.c +++ b/ecc-pm1-redc.c @@ -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) { diff --git a/ecc-pp1-redc.c b/ecc-pp1-redc.c index b088c4c575d2450e73a69e68d9524bb70f916f9a..c472204196af4f60c63158d26e301aeb763688d1 100644 --- a/ecc-pp1-redc.c +++ b/ecc-pp1-redc.c @@ -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); } } diff --git a/ecc-secp192r1.c b/ecc-secp192r1.c index 4a07bca31c3f83d404436ea3e6897cd90bce407f..6097622bd2edb0a637a5f10607ebed783f9c860a 100644 --- a/ecc-secp192r1.c +++ b/ecc-secp192r1.c @@ -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 diff --git a/ecc-secp384r1.c b/ecc-secp384r1.c index abac5e6d449f61f4927a11759878042014b4b22c..bf5f402f39076d9d4db6886974bb53e9c134ea68 100644 --- a/ecc-secp384r1.c +++ b/ecc-secp384r1.c @@ -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 diff --git a/testsuite/ecdsa-sign-test.c b/testsuite/ecdsa-sign-test.c index a3c43568f686537fb8304e7654cd836d7c23bcde..46fc27384d2fa9e7359746f33ce022a3529fd2f2 100644 --- a/testsuite/ecdsa-sign-test.c +++ b/testsuite/ecdsa-sign-test.c @@ -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