From bf587cd520729a1dfeab605d1e206a47f115393c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Thu, 11 Apr 2013 08:36:08 +0200 Subject: [PATCH] Replace mp_bitcnt_t by unsigned, for compatibility with older gmp versions. --- ChangeLog | 6 ++++++ ecc-mul-a.c | 6 ++++-- ecc-mul-g.c | 4 +++- eccdata.c | 4 +++- sec-modinv.c | 4 +++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6aab71e6..015f3c08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2013-04-11 Niels Möller <nisse@lysator.liu.se> + * ecc-mul-a.c (ecc_mul_a): Avoid using mp_bitcnt_t, for + compatibility with older GMP versions. + * ecc-mul-g.c (ecc_mul_g): Likewise. + * eccdata.c (ecc_mul_binary): Likewise. + * sec-modinv.c (sec_modinv): Likewise. + * x86_64/sha3-permute.asm: Go via memory for moves between general registers and xmm registers. diff --git a/ecc-mul-a.c b/ecc-mul-a.c index b23bdc5d..7a537bf6 100644 --- a/ecc-mul-a.c +++ b/ecc-mul-a.c @@ -122,8 +122,10 @@ ecc_mul_a (const struct ecc_curve *ecc, mp_limb_t *scratch_out = table + (3*ecc->size << ECC_MUL_A_WBITS); int is_zero = 0; - mp_bitcnt_t blocks = (ecc->bit_size + ECC_MUL_A_WBITS - 1) / ECC_MUL_A_WBITS; - mp_bitcnt_t bit_index = (blocks-1) * ECC_MUL_A_WBITS; + /* Avoid the mp_bitcnt_t type for compatibility with older GMP + versions. */ + unsigned blocks = (ecc->bit_size + ECC_MUL_A_WBITS - 1) / ECC_MUL_A_WBITS; + unsigned bit_index = (blocks-1) * ECC_MUL_A_WBITS; mp_size_t limb_index = bit_index / GMP_NUMB_BITS; unsigned shift = bit_index % GMP_NUMB_BITS; diff --git a/ecc-mul-g.c b/ecc-mul-g.c index d95e518d..8e41c110 100644 --- a/ecc-mul-g.c +++ b/ecc-mul-g.c @@ -66,7 +66,9 @@ ecc_mul_g (const struct ecc_curve *ecc, mp_limb_t *r, for (j = 0; j * c < bit_rows; j++) { unsigned bits; - mp_bitcnt_t bit_index; + /* Avoid the mp_bitcnt_t type for compatibility with older GMP + versions. */ + unsigned bit_index; /* Extract c bits from n, stride k, starting at i + kcj, ending at i + k (cj + c - 1)*/ diff --git a/eccdata.c b/eccdata.c index 9cc24f1a..7431d79b 100644 --- a/eccdata.c +++ b/eccdata.c @@ -219,7 +219,9 @@ static void ecc_mul_binary (const struct ecc_curve *ecc, struct ecc_point *r, const mpz_t n, const struct ecc_point *p) { - mp_bitcnt_t k; + /* Avoid the mp_bitcnt_t type for compatibility with older GMP + versions. */ + unsigned k; assert (r != p); assert (mpz_sgn (n) > 0); diff --git a/sec-modinv.c b/sec-modinv.c index 0991a98c..16b67384 100644 --- a/sec-modinv.c +++ b/sec-modinv.c @@ -72,7 +72,9 @@ sec_modinv (mp_limb_t *vp, mp_limb_t *ap, mp_size_t n, #define dp (scratch + n) #define up (scratch + 2*n) - mp_bitcnt_t i; + /* Avoid the mp_bitcnt_t type for compatibility with older GMP + versions. */ + unsigned i; /* Maintain -- GitLab