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 8b9082c..efc1a51 100644
--- a/library/bignum.c
+++ b/library/bignum.c
@@ -1790,7 +1790,7 @@
*/
MBEDTLS_MPI_CHK( 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 ) );