mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-28 00:21:48 +03:00
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:
@ -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 ) );
|
||||
|
Reference in New Issue
Block a user