Skip to content

Commit 1dd9546

Browse files
committed
M467: 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 2f8b60d commit 1dd9546

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

connectivity/drivers/mbedtls/TARGET_NUVOTON/TARGET_M460/ecp/crypto_ecc_hw.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,13 @@ int crypto_ecc_run_eccop(const mbedtls_ecp_group *grp,
181181
}
182182

183183
/* NOTE: Engine doesn't support P + Q when P and Q are the same. Workaround by 2*P */
184-
if (mbedtls_ecp_point_cmp(P, Q) == 0) {
185-
return crypto_ecc_run_eccop(grp, R, NULL, P, NULL, NULL, ECCOP_POINT_DOUBLE, blinding);
184+
if (eccop == ECCOP_POINT_ADD) {
185+
if (P == NULL || Q == NULL) {
186+
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
187+
}
188+
if (mbedtls_ecp_point_cmp(P, Q) == 0) {
189+
return crypto_ecc_run_eccop(grp, R, NULL, P, NULL, NULL, ECCOP_POINT_DOUBLE, blinding);
190+
}
186191
}
187192

188193
/* Acquire ownership of ECC accelerator */

0 commit comments

Comments
 (0)