diff --git a/components/mbedtls/port/ecc/ecc_alt.c b/components/mbedtls/port/ecc/ecc_alt.c index ef0b76fe05..4ffa065c24 100644 --- a/components/mbedtls/port/ecc/ecc_alt.c +++ b/components/mbedtls/port/ecc/ecc_alt.c @@ -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));