M487: Fix mbedtls_ecp_point_cmp() call with null argument

Guard from null argument passed to mbedtls_ecp_point_cmp() in ECC H/W port
pull/15313/head
Chun-Chieh Li 2022-07-26 09:23:37 +08:00
parent 91b793c4fd
commit 127b5aa023
1 changed files with 7 additions and 2 deletions

View File

@ -503,9 +503,14 @@ NU_STATIC int internal_run_eccop(const mbedtls_ecp_group *grp,
} }
/* NOTE: Engine doesn't support P + Q when P and Q are the same. Workaround by 2*P */ /* NOTE: Engine doesn't support P + Q when P and Q are the same. Workaround by 2*P */
if (eccop == ECCOP_POINT_ADD) {
if (P == NULL || Q == NULL) {
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
}
if (mbedtls_ecp_point_cmp(P, Q) == 0) { if (mbedtls_ecp_point_cmp(P, Q) == 0) {
return internal_run_eccop(grp, R, NULL, P, NULL, NULL, ECCOP_POINT_DOUBLE); return internal_run_eccop(grp, R, NULL, P, NULL, NULL, ECCOP_POINT_DOUBLE);
} }
}
int ret; int ret;
bool ecc_done; bool ecc_done;