From 814bcdcb5ff67c56cd5dde266e1570f6a76d4df0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niels=20M=C3=B6ller?= Date: Mon, 28 Apr 2025 20:23:52 +0200 Subject: [PATCH] Adopt mp_bitcnt_t type. --- ChangeLog | 9 +++++++++ bignum-random-prime.c | 5 +---- ecc-mod-inv.c | 4 +--- ecc-mul-a-eh.c | 6 ++---- ecc-mul-a.c | 6 ++---- ecc-mul-g-eh.c | 4 +--- ecc-mul-g.c | 4 +--- eccdata.c | 4 +--- 8 files changed, 18 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2d1bce4..fcfd57ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2025-04-28 Niels Möller + * bignum-random-prime.c (miller_rabin_pocklington): Adopt + mp_bitcnt_t type. + * ecc-mod-inv.c (ecc_mod_inv): Likewise. + * ecc-mul-a-eh.c (ecc_mul_a_eh): Likewise. + * ecc-mul-a.c (ecc_mul_a): Likewise. + * ecc-mul-g-eh.c (ecc_mul_g_eh): Likewise. + * ecc-mul-g.c (ecc_mul_g): Likewise. + * eccdata.c (ecc_mul_binary): Likewise. + * sha.h: Deleted file. * nettle.texinfo: Delete all mention of sha.h. * Makefile.in (HEADERS): Delete sha.h. diff --git a/bignum-random-prime.c b/bignum-random-prime.c index 48d9c0ac..aa41ac21 100644 --- a/bignum-random-prime.c +++ b/bignum-random-prime.c @@ -184,10 +184,7 @@ miller_rabin_pocklington(mpz_t n, mpz_t nm1, mpz_t nm1dq, mpz_t a) mpz_t y; int is_prime = 0; - /* Avoid the mp_bitcnt_t type for compatibility with older GMP - versions. */ - unsigned k; - unsigned j; + mp_bitcnt_t k, j; VERBOSE("."); diff --git a/ecc-mod-inv.c b/ecc-mod-inv.c index 5d1f8475..8da08c09 100644 --- a/ecc-mod-inv.c +++ b/ecc-mod-inv.c @@ -73,9 +73,7 @@ ecc_mod_inv (const struct ecc_modulo *m, #define up (scratch + 2*n) mp_size_t n = m->size; - /* Avoid the mp_bitcnt_t type for compatibility with older GMP - versions. */ - unsigned i; + mp_bitcnt_t i; /* Maintain diff --git a/ecc-mul-a-eh.c b/ecc-mul-a-eh.c index 30130aea..bdccb0d8 100644 --- a/ecc-mul-a-eh.c +++ b/ecc-mul-a-eh.c @@ -119,10 +119,8 @@ ecc_mul_a_eh (const struct ecc_curve *ecc, #define table (scratch + 3*ecc->p.size) mp_limb_t *scratch_out = table + (3*ecc->p.size << ECC_MUL_A_EH_WBITS); - /* Avoid the mp_bitcnt_t type for compatibility with older GMP - versions. */ - unsigned blocks = (ecc->p.bit_size + ECC_MUL_A_EH_WBITS - 1) / ECC_MUL_A_EH_WBITS; - unsigned bit_index = (blocks-1) * ECC_MUL_A_EH_WBITS; + mp_bitcnt_t blocks = (ecc->p.bit_size + ECC_MUL_A_EH_WBITS - 1) / ECC_MUL_A_EH_WBITS; + mp_bitcnt_t bit_index = (blocks-1) * ECC_MUL_A_EH_WBITS; mp_size_t limb_index = bit_index / GMP_NUMB_BITS; unsigned shift = bit_index % GMP_NUMB_BITS; diff --git a/ecc-mul-a.c b/ecc-mul-a.c index cc2a7960..08f5fbd1 100644 --- a/ecc-mul-a.c +++ b/ecc-mul-a.c @@ -125,10 +125,8 @@ ecc_mul_a (const struct ecc_curve *ecc, mp_limb_t *scratch_out = table + (3*ecc->p.size << ECC_MUL_A_WBITS); int is_zero = 0; - /* Avoid the mp_bitcnt_t type for compatibility with older GMP - versions. */ - unsigned blocks = (ecc->p.bit_size + ECC_MUL_A_WBITS - 1) / ECC_MUL_A_WBITS; - unsigned bit_index = (blocks-1) * ECC_MUL_A_WBITS; + mp_bitcnt_t blocks = (ecc->p.bit_size + ECC_MUL_A_WBITS - 1) / ECC_MUL_A_WBITS; + mp_bitcnt_t 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-eh.c b/ecc-mul-g-eh.c index 57df1c6d..a4ddf1f9 100644 --- a/ecc-mul-g-eh.c +++ b/ecc-mul-g-eh.c @@ -68,9 +68,7 @@ ecc_mul_g_eh (const struct ecc_curve *ecc, mp_limb_t *r, for (j = 0; j * c < bit_rows; j++) { unsigned bits; - /* Avoid the mp_bitcnt_t type for compatibility with older GMP - versions. */ - unsigned bit_index; + mp_bitcnt_t bit_index; /* Extract c bits from n, stride k, starting at i + kcj, ending at i + k (cj + c - 1)*/ diff --git a/ecc-mul-g.c b/ecc-mul-g.c index 97bbabad..4cc89ba4 100644 --- a/ecc-mul-g.c +++ b/ecc-mul-g.c @@ -69,9 +69,7 @@ ecc_mul_g (const struct ecc_curve *ecc, mp_limb_t *r, for (j = 0; j * c < bit_rows; j++) { unsigned bits; - /* Avoid the mp_bitcnt_t type for compatibility with older GMP - versions. */ - unsigned bit_index; + mp_bitcnt_t bit_index; int bits_is_zero; /* Extract c bits from n, stride k, starting at i + kcj, diff --git a/eccdata.c b/eccdata.c index 3f8e3f13..ae982ee2 100644 --- a/eccdata.c +++ b/eccdata.c @@ -368,9 +368,7 @@ static void ecc_mul_binary (const struct ecc_curve *ecc, struct ecc_point *r, const mpz_t n, const struct ecc_point *p) { - /* Avoid the mp_bitcnt_t type for compatibility with older GMP - versions. */ - unsigned k; + mp_bitcnt_t k; assert (r != p); assert (mpz_sgn (n) > 0); -- 2.47.3