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
pull/15337/head
Chun-Chieh Li 2022-07-26 09:40:16 +08:00
parent 2f8b60d501
commit 1dd95465f6
1 changed files with 7 additions and 2 deletions

View File

@ -181,8 +181,13 @@ int crypto_ecc_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 */
if (mbedtls_ecp_point_cmp(P, Q) == 0) {
return crypto_ecc_run_eccop(grp, R, NULL, P, NULL, NULL, ECCOP_POINT_DOUBLE, blinding);
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) {
return crypto_ecc_run_eccop(grp, R, NULL, P, NULL, NULL, ECCOP_POINT_DOUBLE, blinding);
}
}
/* Acquire ownership of ECC accelerator */