Commit f9e3227f authored by Niels Möller's avatar Niels Möller

cnd_mpn_zero: Use a volatile-declared mask variable.

parent dbaf6abb
2018-11-25 Niels Möller <nisse@lysator.liu.se>
* rsa-sign-tr.c (_rsa_sec_compute_root_tr): Renamed, from...
(rsa_sec_compute_root_tr): ... old name. Updated callers.
* rsa.h (rsa_sec_compute_root_tr): Deleted declaration, moved to ...
* rsa-internal.h (_rsa_sec_compute_root_tr): ... new location.
* rsa-sign-tr.c (_rsa_sec_compute_root_tr): Renamed, from...
(rsa_sec_compute_root_tr): ... old name. Updated callers.
(cnd_mpn_zero): Use a volatile-declared mask variable.
* testsuite/testutils.c (mpz_urandomb) [NETTLE_USE_MINI_GMP]: Fix
masking of most significant bits.
......
......@@ -245,6 +245,7 @@ sec_equal(const mp_limb_t *a, const mp_limb_t *b, size_t limbs)
z |= (a[i] ^ b[i]);
}
/* FIXME: Might compile to a branch instruction on some platforms. */
return z == 0;
}
......@@ -278,11 +279,12 @@ static void
cnd_mpn_zero (int cnd, volatile mp_ptr rp, mp_size_t n)
{
volatile mp_limb_t c;
volatile mp_limb_t mask = (mp_limb_t) cnd - 1;
while (--n >= 0)
{
c = rp[n];
c &= ((mp_limb_t)cnd - 1);
c &= mask;
rp[n] = c;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment