ecp_curves: Reintroduced input checking for
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
diff --git a/library/ecp_curves.c b/library/ecp_curves.c
index 16800aa..1808152 100644
--- a/library/ecp_curves.c
+++ b/library/ecp_curves.c
@@ -5431,6 +5431,13 @@
MBEDTLS_STATIC_TESTABLE
int mbedtls_ecp_mod_p255_raw(mbedtls_mpi_uint *X, size_t X_Limbs)
{
+
+ if (X_Limbs > 2*P255_WIDTH) {
+ X_Limbs = 2*P255_WIDTH;
+ } else if (X_Limbs < P255_WIDTH) {
+ return 0;
+ }
+
mbedtls_mpi_uint *carry = mbedtls_calloc(P255_WIDTH, ciL);
if (carry == NULL) {
return MBEDTLS_ERR_ECP_ALLOC_FAILED;