fix(ecc_alt): adjust null pointer check to fix coverity warning

This commit is contained in:
Mahavir Jain 2024-05-20 12:28:31 +05:30
parent 098abb5993
commit bc2ae212cf

View File

@ -81,6 +81,10 @@ int mbedtls_ecp_check_pubkey( const mbedtls_ecp_group *grp,
int res;
ecc_point_t point;
if (grp == NULL || pt == NULL) {
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
}
if (grp->id != MBEDTLS_ECP_DP_SECP192R1 && grp->id != MBEDTLS_ECP_DP_SECP256R1) {
#if defined(MBEDTLS_ECP_VERIFY_ALT_SOFT_FALLBACK)
return mbedtls_ecp_check_pubkey_soft(grp, pt);
@ -89,13 +93,10 @@ int mbedtls_ecp_check_pubkey( const mbedtls_ecp_group *grp,
#endif
}
if (grp == NULL || pt == NULL) {
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
}
/* Must use affine coordinates */
if( mbedtls_mpi_cmp_int( &pt->MBEDTLS_PRIVATE(Z), 1 ) != 0 )
if (mbedtls_mpi_cmp_int( &pt->MBEDTLS_PRIVATE(Z), 1 ) != 0 ) {
return( MBEDTLS_ERR_ECP_INVALID_KEY );
}
mbedtls_platform_zeroize((void *)&point, sizeof(ecc_point_t));