diff --git a/library/ecdsa.c b/library/ecdsa.c index f3b3cf26d..835d3de88 100644 --- a/library/ecdsa.c +++ b/library/ecdsa.c @@ -353,7 +353,8 @@ modn: while( mbedtls_mpi_cmp_int( s, 0 ) == 0 ); #if defined(MBEDTLS_ECP_RESTARTABLE) - mbedtls_mpi_copy( r, pr ); + if( rs_ctx != NULL && rs_ctx->sig != NULL ) + mbedtls_mpi_copy( r, pr ); #endif cleanup: diff --git a/library/ecp.c b/library/ecp.c index 6675c475c..a8c367a3d 100644 --- a/library/ecp.c +++ b/library/ecp.c @@ -1804,7 +1804,8 @@ static int ecp_mul_comb_after_precomp( const mbedtls_ecp_group *grp, MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, RR ) ); #if defined(MBEDTLS_ECP_RESTARTABLE) - MBEDTLS_MPI_CHK( mbedtls_ecp_copy( R, RR ) ); + if( rs_ctx != NULL && rs_ctx->rsm != NULL ) + MBEDTLS_MPI_CHK( mbedtls_ecp_copy( R, RR ) ); #endif cleanup: