Skip to content

Commit 127b5aa

Browse files
committed
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
1 parent 91b793c commit 127b5aa

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

connectivity/drivers/mbedtls/TARGET_NUVOTON/TARGET_M480/ecp/ecp_internal_alt.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,13 @@ NU_STATIC int internal_run_eccop(const mbedtls_ecp_group *grp,
503503
}
504504

505505
/* NOTE: Engine doesn't support P + Q when P and Q are the same. Workaround by 2*P */
506-
if (mbedtls_ecp_point_cmp(P, Q) == 0) {
507-
return internal_run_eccop(grp, R, NULL, P, NULL, NULL, ECCOP_POINT_DOUBLE);
506+
if (eccop == ECCOP_POINT_ADD) {
507+
if (P == NULL || Q == NULL) {
508+
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
509+
}
510+
if (mbedtls_ecp_point_cmp(P, Q) == 0) {
511+
return internal_run_eccop(grp, R, NULL, P, NULL, NULL, ECCOP_POINT_DOUBLE);
512+
}
508513
}
509514

510515
int ret;

0 commit comments

Comments
 (0)