]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Use mpz_powm_sec.
authorNiels Möller <nisse@lysator.liu.se>
Mon, 20 Jun 2016 18:04:56 +0000 (20:04 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Mon, 20 Jun 2016 18:04:56 +0000 (20:04 +0200)
bignum.h
configure.ac
dsa-sign.c
rsa-blind.c
rsa-sign-tr.c
rsa-sign.c

index 24158e069561514c0c221fc3309c38a5a3dedb6b..64ed2787f14e22ac06fc5b9e3982f2ca45cb5fa5 100644 (file)
--- a/bignum.h
+++ b/bignum.h
@@ -53,6 +53,8 @@
 # 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_pwm
 #else
 # include <gmp.h>
 #endif
index e1ee64c2e7bdc08b479651076c0bd394fe822974..92a3605544cd236893f957fe88be7f4a52257224 100644 (file)
@@ -236,9 +236,9 @@ fi
 # Checks for libraries
 if test "x$enable_public_key" = "xyes" ; then
   if test "x$enable_mini_gmp" = "xno" ; then
-    AC_CHECK_LIB(gmp, __gmpz_getlimbn,,
+    AC_CHECK_LIB(gmp, __gmpz_mpz_powm,,
         [AC_MSG_WARN(
-    [GNU MP not found, or not 3.1 or up, see http://gmplib.org/.
+    [GNU MP not found, or too old. GMP-5.0 or later is needed, see http://gmplib.org/.
     Support for public key algorithms will be unavailable.])]
         enable_public_key=no)
 
index 62c7d4acb651df4e8b6f0963d883827f6427f8b2..9d6bb1849de248604b9e3c8403167e85b060b116 100644 (file)
@@ -65,7 +65,7 @@ dsa_sign(const struct dsa_params *params,
   mpz_add_ui(k, k, 1);
 
   /* Compute r = (g^k (mod p)) (mod q) */
-  mpz_powm(tmp, params->g, k, params->p);
+  mpz_powm_sec(tmp, params->g, k, params->p);
   mpz_fdiv_r(signature->r, tmp, params->q);
 
   /* Compute hash */
index 7662f5034a80fb1ef19be73e506beeef70385f49..16b03d77a757a3af98956fee8f397276a6833a47 100644 (file)
@@ -61,7 +61,7 @@ _rsa_blind (const struct rsa_public_key *pub,
   while (!mpz_invert (ri, r, pub->n));
 
   /* c = c*(r^e) mod n */
-  mpz_powm(r, r, pub->e, pub->n);
+  mpz_powm_sec(r, r, pub->e, pub->n);
   mpz_mul(c, c, r);
   mpz_fdiv_r(c, c, pub->n);
 
index 3d80ed4e94d7d87886e5abb8bec01c0c9b51cab7..68233a3c7543756b658f63799749ae06e495aa3d 100644 (file)
@@ -60,7 +60,7 @@ rsa_blind (const struct rsa_public_key *pub,
   while (!mpz_invert (ri, r, pub->n));
 
   /* c = c*(r^e) mod n */
-  mpz_powm(r, r, pub->e, pub->n);
+  mpz_powm_sec(r, r, pub->e, pub->n);
   mpz_mul(c, m, r);
   mpz_fdiv_r(c, c, pub->n);
 
@@ -97,7 +97,7 @@ rsa_compute_root_tr(const struct rsa_public_key *pub,
 
   rsa_compute_root (key, xb, mb);
 
-  mpz_powm(t, xb, pub->e, pub->n);
+  mpz_powm_sec(t, xb, pub->e, pub->n);
   res = (mpz_cmp(mb, t) == 0);
 
   if (res)
index eba7388dfb32fc0619f698440c0b85bfb279c5fd..48323527dfadad4848170456050c841d8f2f139a 100644 (file)
@@ -96,11 +96,11 @@ rsa_compute_root(const struct rsa_private_key *key,
 
   /* Compute xq = m^d % q = (m%q)^b % q */
   mpz_fdiv_r(xq, m, key->q);
-  mpz_powm(xq, xq, key->b, key->q);
+  mpz_powm_sec(xq, xq, key->b, key->q);
 
   /* Compute xp = m^d % p = (m%p)^a % p */
   mpz_fdiv_r(xp, m, key->p);
-  mpz_powm(xp, xp, key->a, key->p);
+  mpz_powm_sec(xp, xp, key->a, key->p);
 
   /* Set xp' = (xp - xq) c % p. */
   mpz_sub(xp, xp, xq);