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.
This commit is contained in:
parent
b65c2be5f1
commit
a4af1c47d2
2 changed files with 2 additions and 2 deletions
|
@ -1790,7 +1790,7 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi
|
|||
*/
|
||||
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 ) );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue