Commit b188d67a authored by Niels Möller's avatar Niels Möller

Delete code for supporting GMP older than 5.0.

parent 4c9842b7
2016-07-13 Niels Möller <nisse@lysator.liu.se>
* bignum.c (nettle_mpz_from_octets): Unconditionally use
mpz_import.
* gmp-glue.c (mpn_copyd, mpn_copyi, mpn_zero): Deleted
compatibility definitions for older versions of GMP.
* gmp-glue.h (mpn_sqr): Deleted compatibility definition.
* testsuite/testutils.c (mpz_combit): Deleted compatibility
definition.
2016-07-12 Niels Möller <nisse@lysator.liu.se>
* configure.ac: Check for mpz_powm_sec, and require GMP-5.0 or
......
......@@ -135,26 +135,9 @@ nettle_mpz_get_str_256(size_t length, uint8_t *s, const mpz_t x)
/* Converting from strings */
#ifdef mpz_import
/* Was introduced in GMP-4.1 */
# define nettle_mpz_from_octets(x, length, s) \
/* mpz_import was introduced in GMP-4.1 */
#define nettle_mpz_from_octets(x, length, s) \
mpz_import((x), (length), 1, 1, 0, 0, (s))
#else
static void
nettle_mpz_from_octets(mpz_t x,
size_t length, const uint8_t *s)
{
size_t i;
mpz_set_ui(x, 0);
for (i = 0; i < length; i++)
{
mpz_mul_2exp(x, x, 8);
mpz_add_ui(x, x, s[i]);
}
}
#endif
void
nettle_mpz_set_str_256_u(mpz_t x,
......
......@@ -46,13 +46,8 @@
# define GMP_NUMB_MASK (~(mp_limb_t) 0)
/* Functions missing in older gmp versions, and checked for with ifdef */
/* Function missing in older gmp versions, and checked for with ifdef */
# define mpz_limbs_read mpz_limbs_read
# define mpn_copyd mpn_copyd
# define mpn_sqr mpn_sqr
# define mpz_combit mpz_combit
# define mpz_import mpz_import
# define mpz_export mpz_export
/* Side-channel silent powm not available in mini-gmp. */
# define mpz_powm_sec mpz_powm
#else
......
......@@ -116,32 +116,6 @@ mpz_roinit_n (mpz_ptr x, const mp_limb_t *xp, mp_size_t xs)
}
#endif /* !GMP_HAVE_mpz_limbs_read */
#if !GMP_HAVE_mpn_copyd
void
mpn_copyd (mp_ptr dst, mp_srcptr src, mp_size_t n)
{
mp_size_t i;
for (i = n - 1; i >= 0; i--)
dst[i] = src[i];
}
void
mpn_copyi (mp_ptr dst, mp_srcptr src, mp_size_t n)
{
mp_size_t i;
for (i = 0; i < n; i++)
dst[i] = src[i];
}
void
mpn_zero (mp_ptr ptr, mp_size_t n)
{
mp_size_t i;
for (i = 0; i < n; i++)
ptr[i] = 0;
}
#endif /* !GMP_HAVE_mpn_copyd */
void
cnd_swap (mp_limb_t cnd, mp_limb_t *ap, mp_limb_t *bp, mp_size_t n)
{
......
......@@ -41,12 +41,6 @@
#define GMP_HAVE_mpz_limbs_read 0
#endif
#ifdef mpn_copyd
#define GMP_HAVE_mpn_copyd 1
#else
#define GMP_HAVE_mpn_copyd 0
#endif
/* Name mangling. */
#if !GMP_HAVE_mpz_limbs_read
#define mpz_limbs_read _nettle_mpz_limbs_read
......@@ -56,16 +50,6 @@
#define mpz_roinit_n _nettle_mpz_roinit_n
#endif
#if !GMP_HAVE_mpn_copyd
#define mpn_copyd _nettle_mpn_copyd
#define mpn_copyi _nettle_mpn_copyi
#define mpn_zero _nettle_mpn_zero
#endif
#ifndef mpn_sqr
#define mpn_sqr(rp, ap, n) mpn_mul_n((rp), (ap), (ap), (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
......@@ -130,20 +114,6 @@ mpz_roinit_n (mpz_ptr x, const mp_limb_t *xp, mp_size_t xs);
#endif /* !GMP_HAVE_mpz_limbs_read */
#if !GMP_HAVE_mpn_copyd
/* Copy elements, backwards */
void
mpn_copyd (mp_ptr dst, mp_srcptr src, mp_size_t n);
/* Copy elements, forwards */
void
mpn_copyi (mp_ptr dst, mp_srcptr src, mp_size_t n);
/* Zero elements */
void
mpn_zero (mp_ptr ptr, mp_size_t n);
#endif /* !GMP_HAVE_mpn_copyd */
void
cnd_swap (mp_limb_t cnd, mp_limb_t *ap, mp_limb_t *bp, mp_size_t n);
......
......@@ -606,18 +606,6 @@ test_armor(const struct nettle_armor *armor,
#if WITH_HOGWEED
#ifndef mpz_combit
/* Missing in older gmp */
static void
mpz_combit (mpz_t x, unsigned long int bit)
{
if (mpz_tstbit(x, bit))
mpz_clrbit(x, bit);
else
mpz_setbit(x, bit);
}
#endif
#ifndef mpn_zero_p
int
mpn_zero_p (mp_srcptr ap, mp_size_t n)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment