summaryrefslogtreecommitdiff
path: root/mpi
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2016-02-25 12:01:10 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2016-02-25 12:01:10 +0900
commitfdfa5bfefdde316688a3c8021bd3528c5273b0f4 (patch)
tree827d1b6e8bb90400b1c51980f180efd139e015ad /mpi
parent2b40a16333fa75f1cee85ab901a5aa9cff845a92 (diff)
downloadlibgcrypt-fdfa5bfefdde316688a3c8021bd3528c5273b0f4.tar.gz
mpi: Normalize EXPO for mpi_powm.
* mpi/mpi-pow.c (gcry_mpi_powm): Normalize EP. -- Thanks to Dan Fandrich for the report with a reproducible test case. GnuPG-bug-id: 2256 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'mpi')
-rw-r--r--mpi/mpi-pow.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/mpi/mpi-pow.c b/mpi/mpi-pow.c
index 0be153fe..a780ebd1 100644
--- a/mpi/mpi-pow.c
+++ b/mpi/mpi-pow.c
@@ -83,6 +83,7 @@ _gcry_mpi_powm (gcry_mpi_t res,
rp = res->d;
ep = expo->d;
+ MPN_NORMALIZE(ep, esize);
if (!msize)
_gcry_divide_by_zero();
@@ -429,6 +430,9 @@ _gcry_mpi_powm (gcry_mpi_t res,
size = 2 * msize;
msign = mod->sign;
+ ep = expo->d;
+ MPN_NORMALIZE(ep, esize);
+
if (esize * BITS_PER_MPI_LIMB > 512)
W = 5;
else if (esize * BITS_PER_MPI_LIMB > 256)
@@ -445,7 +449,6 @@ _gcry_mpi_powm (gcry_mpi_t res,
bsec = mpi_is_secure(base);
rp = res->d;
- ep = expo->d;
if (!msize)
_gcry_divide_by_zero();