2020-04-25 Niels Möller <nisse@lysator.liu.se>
+ * gmp-glue.c (mpz_limbs_read, mpz_limbs_write, mpz_limbs_modify)
+ (mpz_limbs_finish, mpz_roinit_n): Delete compatibility
+ definitions. These functions available in GMP since version 6.0.0.
+ * gmp-glue.h: Delete corresponding declarations, and preprocessor
+ conditions.
+
* configure.ac: Update required version of GMP to 6.1.0, needed
for mpn_zero_p.
* ecc-ecdsa-verify.c (zero_p): Deleted static function, usage
# define GMP_NUMB_MASK (~(mp_limb_t) 0)
-/* Function missing in older gmp versions, and checked for with ifdef */
-# define mpz_limbs_read mpz_limbs_read
/* Side-channel silent powm not available in mini-gmp. */
# define mpz_powm_sec mpz_powm
#else
#include "gmp-glue.h"
-#if !GMP_HAVE_mpz_limbs_read
-
-/* This implementation tries to make a minimal use of GMP internals.
- We access and _mp_size and _mp_d, but not _mp_alloc. */
-
-/* Use macros compatible with gmp-impl.h. */
-#define ABS(x) ((x) >= 0 ? (x) : -(x))
-#define PTR(x) ((x)->_mp_d)
-#define SIZ(x) ((x)->_mp_size)
-#define ABSIZ(x) ABS (SIZ (x))
-
-#define MPN_NORMALIZE(xp, xn) do { \
- while ( (xn) > 0 && (xp)[xn-1] == 0) \
- (xn)--; \
- } while (0)
-
-/* NOTE: Makes an unnecessary realloc if allocation is already large
- enough, but looking at _mp_alloc may break in future GMP
- versions. */
-#define MPZ_REALLOC(x, n) \
- (ABSIZ(x) >= (n) ? PTR(x) : (_mpz_realloc ((x),(n)), PTR (x)))
-
-#define MPZ_NEWALLOC MPZ_REALLOC
-
-/* Read access to mpz numbers. */
-
-/* Return limb pointer, for read-only operations. Use mpz_size to get
- the number of limbs. */
-const mp_limb_t *
-mpz_limbs_read (mpz_srcptr x)
-{
- return PTR (x);
-}
-
-/* Write access to mpz numbers. */
-
-/* Get a limb pointer for writing, previous contents may be
- destroyed. */
-mp_limb_t *
-mpz_limbs_write (mpz_ptr x, mp_size_t n)
-{
- assert (n > 0);
- return MPZ_NEWALLOC (x, n);
-}
-
-/* Get a limb pointer for writing, previous contents is intact. */
-mp_limb_t *
-mpz_limbs_modify (mpz_ptr x, mp_size_t n)
-{
- assert (n > 0);
- return MPZ_REALLOC (x, n);
-}
-
-void
-mpz_limbs_finish (mpz_ptr x, mp_size_t n)
-{
- assert (n >= 0);
- MPN_NORMALIZE (PTR(x), n);
-
- SIZ (x) = n;
-}
-
-/* Needs some ugly casts. */
-mpz_srcptr
-mpz_roinit_n (mpz_ptr x, const mp_limb_t *xp, mp_size_t xs)
-{
- mp_size_t xn = ABS (xs);
-
- MPN_NORMALIZE (xp, xn);
-
- x->_mp_size = xs < 0 ? -xn : xn;
- x->_mp_alloc = 0;
- x->_mp_d = (mp_limb_t *) xp;
- return x;
-}
-#endif /* !GMP_HAVE_mpz_limbs_read */
-
void
cnd_swap (mp_limb_t cnd, mp_limb_t *ap, mp_limb_t *bp, mp_size_t n)
{
#include "bignum.h"
-#ifdef mpz_limbs_read
-#define GMP_HAVE_mpz_limbs_read 1
-#else
-#define GMP_HAVE_mpz_limbs_read 0
-#endif
-
-/* Name mangling. */
-#if !GMP_HAVE_mpz_limbs_read
-#define mpz_limbs_read _nettle_mpz_limbs_read
-#define mpz_limbs_write _nettle_mpz_limbs_write
-#define mpz_limbs_modify _nettle_mpz_limbs_modify
-#define mpz_limbs_finish _nettle_mpz_limbs_finish
-#define mpz_roinit_n _nettle_mpz_roinit_n
-#endif
-
#define cnd_swap _nettle_cnd_swap
#define mpz_limbs_cmp _nettle_mpz_limbs_cmp
#define mpz_limbs_read_n _nettle_mpz_limbs_read_n
#define NETTLE_OCTET_SIZE_TO_LIMB_SIZE(n) \
(((n) * 8 + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS)
-/* Some functions for interfacing between mpz and mpn code. Signs of
- the mpz numbers are generally ignored. */
-
-#if !GMP_HAVE_mpz_limbs_read
-/* Read access to mpz numbers. */
-
-/* Return limb pointer, for read-only operations. Use mpz_size to get
- the number of limbs. */
-const mp_limb_t *
-mpz_limbs_read (const mpz_srcptr x);
-
-/* Write access to mpz numbers. */
-
-/* Get a limb pointer for writing, previous contents may be
- destroyed. */
-mp_limb_t *
-mpz_limbs_write (mpz_ptr x, mp_size_t n);
-
-/* Get a limb pointer for writing, previous contents is intact. */
-mp_limb_t *
-mpz_limbs_modify (mpz_ptr x, mp_size_t n);
-
-/* Update size. */
-void
-mpz_limbs_finish (mpz_ptr x, mp_size_t n);
-
-/* Using an mpn number as an mpz. Can be used for read-only access
- only. x must not be cleared or reallocated. */
-mpz_srcptr
-mpz_roinit_n (mpz_ptr x, const mp_limb_t *xp, mp_size_t xs);
-
-#endif /* !GMP_HAVE_mpz_limbs_read */
-
void
cnd_swap (mp_limb_t cnd, mp_limb_t *ap, mp_limb_t *bp, mp_size_t n);