commit | 2a8d655664bbb1cb77850eac7153713b25eed9b8 | [log] [tgz] |
---|---|---|
author | Hanno Becker <hanno.becker@arm.com> | Tue Apr 18 09:07:45 2017 +0100 |
committer | Hanno Becker <hanno.becker@arm.com> | Thu May 11 11:23:48 2017 +0100 |
tree | df5384e7e7902b7ad5cc5aa6c33ff317fe3ec5f2 | |
parent | 63a48d10e94557cb1e226c37face768c5d149f76 [diff] [blame] |
Correct sign in modular exponentiation algorithm. The modular exponentiation function handled the sign incorrectly. This commit fixes this and a test case which should have caught it.
diff --git a/library/bignum.c b/library/bignum.c index 199b4f2..f0fabd6 100644 --- a/library/bignum.c +++ b/library/bignum.c
@@ -1785,7 +1785,7 @@ */ mpi_montred( X, N, mm, &T ); - if( neg ) + if( neg && E->n != 0 && ( E->p[0] & 1 ) != 0 ) { X->s = -1; MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( X, N, X ) );