mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-21 21:36:21 +01:00
Abort modular inversion when modulus is one.
The modular inversion function hangs when provided with the modulus 1. This commit refuses this modulus with a BAD_INPUT error code. It also adds a test for this case.
This commit is contained in:
parent
a4af1c47d2
commit
4bcb4914c5
3 changed files with 6 additions and 3 deletions
|
|
@ -1893,7 +1893,7 @@ int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi
|
|||
int ret;
|
||||
mbedtls_mpi G, TA, TU, U1, U2, TB, TV, V1, V2;
|
||||
|
||||
if( mbedtls_mpi_cmp_int( N, 0 ) <= 0 )
|
||||
if( mbedtls_mpi_cmp_int( N, 1 ) <= 0 )
|
||||
return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
|
||||
|
||||
mbedtls_mpi_init( &TA ); mbedtls_mpi_init( &TU ); mbedtls_mpi_init( &U1 ); mbedtls_mpi_init( &U2 );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue