Safeguard against calling p255 reduction with single-width MPI

(In this case, there's nothing to do anyway since we only do a
quasi-reduction to N+1 limbs)

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
This commit is contained in:
Hanno Becker 2022-04-11 07:35:58 +01:00
parent 25bb732ea7
commit 6454993e2e

View file

@ -5223,7 +5223,7 @@ static int ecp_mod_p255( mbedtls_mpi *N )
/* Helper references for top part of N */
mbedtls_mpi_uint * const NT_p = N->p + P255_WIDTH;
unsigned const NT_n = N->n - P255_WIDTH;
if( NT_n > P255_WIDTH )
if( NT_n == 0 || NT_n > P255_WIDTH )
return( 0 );
/* Split N as N + 2^256 M */