diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2016-02-25 12:01:10 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2016-02-25 12:01:10 +0900 |
commit | fdfa5bfefdde316688a3c8021bd3528c5273b0f4 (patch) | |
tree | 827d1b6e8bb90400b1c51980f180efd139e015ad /mpi | |
parent | 2b40a16333fa75f1cee85ab901a5aa9cff845a92 (diff) | |
download | libgcrypt-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.c | 5 |
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(); |