From c96ba19397d9fbb444d87615d7e7bc9679e05688 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 18 Jan 2019 20:39:13 -0800 Subject: mpi: some params should be mp_size, not mp_digit. * mpi/mpi.c (s_mp_2expt, mp_trunc_comp, mp_trunc, mp_bit): Arguments that give a number of bits or bit position should be mp_size; they are not related to digit values. * mpi/mpi.h (mp_trunc_comp, mp_trunc, mp_bit): Declaration updated. --- mpi/mpi.c | 12 ++++++------ mpi/mpi.h | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'mpi') diff --git a/mpi/mpi.c b/mpi/mpi.c index 673c29a1..ef91437b 100644 --- a/mpi/mpi.c +++ b/mpi/mpi.c @@ -150,7 +150,7 @@ mp_err s_mp_sqr(mp_int *a); /* magnitude square */ #endif mp_err s_mp_div(mp_int *a, mp_int *b); /* magnitude divide */ -mp_err s_mp_2expt(mp_int *a, mp_digit k); /* a = 2^k */ +mp_err s_mp_2expt(mp_int *a, mp_size k); /* a = 2^k */ int s_mp_cmp(mp_int *a, mp_int *b); /* magnitude comparison */ int s_mp_cmp_d(mp_int *a, mp_digit d); /* magnitude digit compare */ mp_size s_mp_ispow2(mp_int *v); /* is v a power of 2? */ @@ -2139,7 +2139,7 @@ mp_err mp_comp(mp_int *a, mp_int *b) return MP_OKAY; } -mp_err mp_trunc_comp(mp_int *a, mp_int *b, mp_digit bits) +mp_err mp_trunc_comp(mp_int *a, mp_int *b, mp_size bits) { mp_err res; mp_size ix, dig = bits / DIGIT_BIT, rembits = bits % DIGIT_BIT; @@ -2182,7 +2182,7 @@ mp_err mp_trunc_comp(mp_int *a, mp_int *b, mp_digit bits) return MP_OKAY; } -mp_err mp_trunc(mp_int *a, mp_int *b, mp_digit bits) +mp_err mp_trunc(mp_int *a, mp_int *b, mp_size bits) { mp_err res; mp_size ix, dig = bits / DIGIT_BIT, rembits = bits % DIGIT_BIT; @@ -2276,12 +2276,12 @@ mp_err mp_shift(mp_int *a, mp_int *b, int bits) return MP_OKAY; } -mp_err mp_bit(mp_int *a, mp_digit bit) +mp_err mp_bit(mp_int *a, mp_size bit) { mp_int tmp; mp_err res; int a_neg = ISNEG(a); - mp_digit digit = bit / MP_DIGIT_BIT; + mp_size digit = bit / MP_DIGIT_BIT; mp_digit mask = convert(mp_digit, 1) << (bit % MP_DIGIT_BIT); if (a_neg) { @@ -3799,7 +3799,7 @@ T: return res; } -mp_err s_mp_2expt(mp_int *a, mp_digit k) +mp_err s_mp_2expt(mp_int *a, mp_size k) { mp_err res; mp_size dig, bit; diff --git a/mpi/mpi.h b/mpi/mpi.h index c1b50296..0fd9b740 100644 --- a/mpi/mpi.h +++ b/mpi/mpi.h @@ -153,10 +153,10 @@ mp_err mp_and(mp_int *a, mp_int *b, mp_int *c); mp_err mp_or(mp_int *a, mp_int *b, mp_int *c); mp_err mp_xor(mp_int *a, mp_int *b, mp_int *c); mp_err mp_comp(mp_int *a, mp_int *b); -mp_nign mp_err mp_trunc_comp(mp_int *a, mp_int *b, mp_digit bits); -mp_nign mp_err mp_trunc(mp_int *a, mp_int *b, mp_digit bits); +mp_nign mp_err mp_trunc_comp(mp_int *a, mp_int *b, mp_size bits); +mp_nign mp_err mp_trunc(mp_int *a, mp_int *b, mp_size bits); mp_nign mp_err mp_shift(mp_int *a, mp_int *b, int bits); /* + left, - right */ -mp_err mp_bit(mp_int *a, mp_digit bit); +mp_err mp_bit(mp_int *a, mp_size bit); mp_nign mp_err mp_to_double(mp_int *mp, double *d); -- cgit v1.2.3