Remove unnecessary memory operations in p25519 quasireduction

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
This commit is contained in:
Hanno Becker 2022-04-13 06:54:48 +01:00
parent 1772e05fca
commit 0dbf04a9a6

View file

@ -5229,13 +5229,12 @@ static int ecp_mod_p255( mbedtls_mpi *N )
return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA );
/* Split N as N + 2^256 M */ /* Split N as N + 2^256 M */
memset( Mp, 0, sizeof( Mp ) );
memcpy( Mp, NT_p, sizeof( mbedtls_mpi_uint ) * NT_n ); memcpy( Mp, NT_p, sizeof( mbedtls_mpi_uint ) * NT_n );
memset( NT_p, 0, sizeof( mbedtls_mpi_uint ) * NT_n ); memset( NT_p, 0, sizeof( mbedtls_mpi_uint ) * NT_n );
/* N = A0 + 38 * A1 */ /* N = A0 + 38 * A1 */
mbedtls_mpi_core_mla( N->p, N->n, mbedtls_mpi_core_mla( N->p, P255_WIDTH + 1,
Mp, P255_WIDTH, Mp, NT_n,
38 ); 38 );
return( 0 ); return( 0 );