diff --git a/lib/nettle/wmnaf.c b/lib/nettle/wmnaf.c index 778518a..d9e4cef 100644 --- a/lib/nettle/wmnaf.c +++ b/lib/nettle/wmnaf.c @@ -33,6 +33,7 @@ #define ABS(x) ((x) >= 0 ? (x) : -(x)) +#if 0 /* * A local replacement for mpz_tstbit. * It is needed because for negative numbers original mpz_tstbit @@ -58,6 +59,7 @@ mpz_unitstbit (mpz_srcptr u, mp_bitcnt_t bit_index) return (limb >> (bit_index % GMP_NUMB_BITS)) & 1; } +#endif /* * Return an array with wMNAF representation together with its length. @@ -96,6 +98,8 @@ ecc_wMNAF (mpz_t x, size_t * wmnaf_len) goto done; } + x->_mp_size *= sign; + /* total number of bits */ len = mpz_sizeinbase (x, 2); @@ -135,7 +139,7 @@ ecc_wMNAF (mpz_t x, size_t * wmnaf_len) /* fill c with next LSB */ c >>= 1; - c += BASEW * mpz_unitstbit (x, i + WMNAF_WINSIZE); + c += BASEW * mpz_tstbit (x, i + WMNAF_WINSIZE); } *wmnaf_len = i--; @@ -150,5 +154,6 @@ ecc_wMNAF (mpz_t x, size_t * wmnaf_len) *wmnaf_len = i; } done: + x->_mp_size *= sign; return ret; }