]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Require gmp-6.1.0 or later, for mpn_zero_p.
authorNiels Möller <nisse@lysator.liu.se>
Sat, 25 Apr 2020 18:01:00 +0000 (20:01 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Sat, 25 Apr 2020 18:01:00 +0000 (20:01 +0200)
ChangeLog
configure.ac
ecc-ecdsa-verify.c
testsuite/testutils.c
testsuite/testutils.h

index 31735d8faa06b0954b1c4401a100e01828d70893..f2f46ed682a614b722c0a4fd8c410b0e0a04c9e2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2020-04-25  Niels Möller  <nisse@lysator.liu.se>
 
+       * 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
+       replaced with mpn_zero_p.
+       * testsuite/testutils.c (mpn_zero_p): Delete conditional
+       definition.
+       * testsuite/testutils.h: Delete corresponding declarations.
+
        * Makefile.in (DISTFILES): Add poly1305-internal.h.
        * testsuite/Makefile.in (DISTFILES): Delete setup-env.
 
index e5824ae01cb02913a7d6ac3c1849b385881356de..dd7d66057813461282d8a47667e6537e5a1b4ba7 100644 (file)
@@ -243,9 +243,10 @@ fi
 # Checks for libraries
 if test "x$enable_public_key" = "xyes" ; then
   if test "x$enable_mini_gmp" = "xno" ; then
-    AC_CHECK_LIB(gmp, __gmpn_sec_div_r,,
+    # mpn_zero_p was added in GMP-6.1.0
+    AC_CHECK_LIB(gmp, __gmpn_zero_p,,
         [AC_MSG_WARN(
-    [GNU MP not found, or too old. GMP-6.0 or later is needed, see https://gmplib.org/.
+    [GNU MP not found, or too old. GMP-6.1.0 or later is needed, see https://gmplib.org/.
     Support for public key algorithms will be unavailable.])]
         enable_public_key=no)
 
index 6f9fb5d98175e0efe6addd4b40bb837e5a77be60..c43bdadc68b0d84f4a5952dcdb79c8d3690190be 100644 (file)
 
 /* Low-level ECDSA verify */
 
-/* FIXME: Use mpn_zero_p. */
-static int
-zero_p (const mp_limb_t *xp, mp_size_t n)
-{
-  while (n > 0)
-    if (xp[--n] > 0)
-      return 0;
-  return 1;
-}
-
 static int
 ecdsa_in_range (const struct ecc_curve *ecc, const mp_limb_t *xp)
 {
-  return !zero_p (xp, ecc->p.size)
+  return !mpn_zero_p (xp, ecc->p.size)
     && mpn_cmp (xp, ecc->q.m, ecc->p.size) < 0;
 }
 
@@ -122,7 +112,7 @@ ecc_ecdsa_verify (const struct ecc_curve *ecc,
 
   /* u = 0 can happen only if h = 0 or h = q, which is extremely
      unlikely. */
-  if (!zero_p (u1, ecc->p.size))
+  if (!mpn_zero_p (u1, ecc->p.size))
     {
       /* Total storage: 7*ecc->p.size + ecc->mul_g_itch (ecc->p.size) */
       ecc->mul_g (ecc, P1, u1, P1 + 3*ecc->p.size);
index 187da0efda2935323aa27d23a8e62b29a5c34920..1f279e9a0e2ac6b9b0a9b8f6c2847e6fe9bb0d8f 100644 (file)
@@ -1063,19 +1063,6 @@ test_armor(const struct nettle_armor *armor,
 
 #if WITH_HOGWEED
 
-#ifndef mpn_zero_p
-int
-mpn_zero_p (mp_srcptr ap, mp_size_t n)
-{
-  while (--n >= 0)
-    {
-      if (ap[n] != 0)
-       return 0;
-    }
-  return 1;
-}
-#endif
-
 void
 mpn_out_str (FILE *f, int base, const mp_limb_t *xp, mp_size_t xn)
 {
index 8ace6a82357f416a4a461d652f6e3acdb4262ee4..0dc235c6c28fa53c272d72f0bd2ac1c5fd3da950 100644 (file)
@@ -164,17 +164,8 @@ void mpz_urandomb (mpz_t r, struct knuth_lfib_ctx *ctx, mp_bitcnt_t bits);
 /* This is cheating */
 #define mpz_rrandomb mpz_urandomb
 
-/* mini-gmp defines this function (in the GMP library, it was added in
-   gmp in version 6.1.0). */
-#define mpn_zero_p mpn_zero_p
-
 #endif /* NETTLE_USE_MINI_GMP */
 
-#ifndef mpn_zero_p
-int
-mpn_zero_p (mp_srcptr ap, mp_size_t n);
-#endif
-
 void
 mpn_out_str (FILE *f, int base, const mp_limb_t *xp, mp_size_t xn);