Merge pull request #15313 from OpenNuvoton/nuvoton_m487_fix_null_mpi_cmp

M487: Fix mbedtls_ecp_point_cmp() call with null argument
pull/15322/head
Martin Kojtal 2022-08-03 13:07:19 +01:00 committed by GitHub
commit e6e5083e65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -503,8 +503,13 @@ 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 */
if (mbedtls_ecp_point_cmp(P, Q) == 0) {
return internal_run_eccop(grp, R, NULL, P, NULL, NULL, ECCOP_POINT_DOUBLE);
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 internal_run_eccop(grp, R, NULL, P, NULL, NULL, ECCOP_POINT_DOUBLE);
}
}
int ret;