Skip to content

Commit e6e5083

Browse files
authored
Merge pull request #15313 from OpenNuvoton/nuvoton_m487_fix_null_mpi_cmp
M487: Fix mbedtls_ecp_point_cmp() call with null argument
2 parents 91b793c + 127b5aa commit e6e5083

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)