+2023-11-12 Niels Möller <nisse@lysator.liu.se>
+
+ * gmp-glue.h (GMP_LIMB_BITS) [NETTLE_USE_MINI_GMP]: Define as alias for
+ GMP_NUMB_BITS.
+ (is_zero_limb): Move inline function here. Add static, for
+ compatibility with c89. and mini-gmp builds.
+ * gmp-glue.c (sec_zero_p): Use is_zero_limb.
+
2023-11-06 Niels Möller <nisse@lysator.liu.se>
Avoid comparison like cnd = (x == 0) in code intended to be
#define curve25519_eh_to_x _nettle_curve25519_eh_to_x
#define curve448_eh_to_x _nettle_curve448_eh_to_x
-inline int
-is_zero_limb (mp_limb_t x)
-{
- x |= (x << 1);
- return ((x >> 1) - 1) >> (GMP_LIMB_BITS - 1);
-}
-
extern const struct ecc_curve _nettle_secp_192r1;
extern const struct ecc_curve _nettle_secp_224r1;
extern const struct ecc_curve _nettle_secp_256r1;
for (i = 0, w = 0; i < n; i++)
w |= ap[i];
- return w == 0;
+ return is_zero_limb (w);
}
/* Additional convenience functions. */
#define TMP_GMP_FREE(name) (gmp_free(name, tmp_##name##_size))
#if NETTLE_USE_MINI_GMP
+#define GMP_LIMB_BITS GMP_NUMB_BITS
+
mp_limb_t
mpn_cnd_add_n (mp_limb_t cnd, mp_limb_t *rp,
const mp_limb_t *ap, const mp_limb_t *bp, mp_size_t n);
mp_size_t rn, unsigned tn, unsigned k);
#endif
+static inline int
+is_zero_limb (mp_limb_t x)
+{
+ x |= (x << 1);
+ return ((x >> 1) - 1) >> (GMP_LIMB_BITS - 1);
+}
+
/* Side-channel silent variant of mpn_zero_p. */
int
sec_zero_p (const mp_limb_t *ap, mp_size_t n);