mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-09 15:35:34 +00:00
Fix misplaced initialisation.
If one of the calls to mpi_grow() before setting Apos would fail, then mpi_free( &Apos ) would be executed without Apos being initialised.
This commit is contained in:
parent
b55f578982
commit
7fd620b331
|
@ -1410,6 +1410,7 @@ int mpi_exp_mod( mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR )
|
||||||
*/
|
*/
|
||||||
mpi_montg_init( &mm, N );
|
mpi_montg_init( &mm, N );
|
||||||
mpi_init( &RR ); mpi_init( &T );
|
mpi_init( &RR ); mpi_init( &T );
|
||||||
|
mpi_init( &Apos );
|
||||||
memset( W, 0, sizeof( W ) );
|
memset( W, 0, sizeof( W ) );
|
||||||
|
|
||||||
i = mpi_msb( E );
|
i = mpi_msb( E );
|
||||||
|
@ -1429,8 +1430,6 @@ int mpi_exp_mod( mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR )
|
||||||
* Compensate for negative A (and correct at the end)
|
* Compensate for negative A (and correct at the end)
|
||||||
*/
|
*/
|
||||||
neg = ( A->s == -1 );
|
neg = ( A->s == -1 );
|
||||||
|
|
||||||
mpi_init( &Apos );
|
|
||||||
if( neg )
|
if( neg )
|
||||||
{
|
{
|
||||||
MPI_CHK( mpi_copy( &Apos, A ) );
|
MPI_CHK( mpi_copy( &Apos, A ) );
|
||||||
|
|
Loading…
Reference in a new issue