Fail gracefully upon unexpectedly large input to p25519 reduction

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
This commit is contained in:
Hanno Becker 2022-04-12 22:18:36 +01:00
parent bb04cb992f
commit 127fcabb21

View file

@ -5225,6 +5225,8 @@ static int ecp_mod_p255( mbedtls_mpi *N )
const size_t NT_n = N->n - P255_WIDTH;
if( N->n <= P255_WIDTH )
return( 0 );
if( NT_n > P255_WIDTH )
return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA );
/* Split N as N + 2^256 M */
memset( Mp, 0, sizeof( Mp ) );