diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2013-12-04 10:03:57 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2013-12-04 10:31:31 +0900 |
commit | c56080c26186d25dec05f01831494c77d8d07e13 (patch) | |
tree | e2957ceb59382e54d7d438a472782eb519e53933 /mpi | |
parent | 2ff86db2e1b0f6cc22a1ca86037b526c5fa3be51 (diff) | |
download | libgcrypt-c56080c26186d25dec05f01831494c77d8d07e13.tar.gz |
mpi: fix gcry_mpi_powm for negative base.
* mpi/mpi-pow.c (gcry_mpi_powm) [USE_ALGORITHM_SIMPLE_EXPONENTIATION]:
Fix for the case where BASE is negative.
* tests/mpitests.c (test_powm): Add a test case of (-17)^6 mod 19.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'mpi')
-rw-r--r-- | mpi/mpi-pow.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/mpi/mpi-pow.c b/mpi/mpi-pow.c index 469c382a..4bf0233a 100644 --- a/mpi/mpi-pow.c +++ b/mpi/mpi-pow.c @@ -177,7 +177,7 @@ gcry_mpi_powm (gcry_mpi_t res, } MPN_COPY ( rp, bp, bsize ); rsize = bsize; - rsign = bsign; + rsign = 0; /* Main processing. */ { @@ -192,7 +192,7 @@ gcry_mpi_powm (gcry_mpi_t res, xp = xp_marker = mpi_alloc_limb_space( 2 * (msize + 1), msec ); memset( &karactx, 0, sizeof karactx ); - negative_result = (ep[0] & 1) && base->sign; + negative_result = (ep[0] & 1) && bsign; i = esize - 1; e = ep[i]; |