Merge branch 'bugfix/supplicant_crypto_code_correction_v6.0' into 'release/v6.0'

fix(wpa_supplicant): Correct some functions in crypto porting layer (v6.0)

See merge request espressif/esp-idf!50874
This commit is contained in:
Jiang Jiang Jian
2026-07-22 16:26:33 +08:00

View File

@@ -487,8 +487,8 @@ int crypto_ec_get_affine_coordinates(struct crypto_ec *e, struct crypto_ec_point
int ret = -1;
mbedtls_ecp_point *point = (mbedtls_ecp_point *)pt;
if (!mbedtls_ecp_is_zero(point) && (mbedtls_mpi_cmp_int(&point->MBEDTLS_PRIVATE(Z), 1) == 0)) {
// Affine coordinates mean that z should be 1,
if (!mbedtls_ecp_is_zero(point) && (mbedtls_mpi_cmp_int(&point->MBEDTLS_PRIVATE(Z), 1) != 0)) {
// For non-zero points, affine coordinates mean Z should be 1,
wpa_printf(MSG_ERROR, "Z coordinate is neither 0 or 1");
return -1;
}
@@ -2370,8 +2370,7 @@ int crypto_ecdsa_get_sign(unsigned char *hash,
return -1;
}
size_t key_size = hash_len / 2;
unsigned char signature[128]; // Max for P-521
unsigned char signature[PSA_SIGNATURE_MAX_SIZE];
size_t signature_length = 0;
psa_status_t status = psa_sign_hash(wrapper->key_id, PSA_ALG_DETERMINISTIC_ECDSA(PSA_ALG_SHA_256), hash, hash_len, signature, sizeof(signature), &signature_length);
@@ -2380,6 +2379,13 @@ int crypto_ecdsa_get_sign(unsigned char *hash,
return -1;
}
if (signature_length == 0 || (signature_length % 2) != 0) {
wpa_printf(MSG_ERROR, "Invalid signature length: %zu", signature_length);
return -1;
}
size_t key_size = signature_length / 2;
// Extract r component
int ret = mbedtls_mpi_read_binary((mbedtls_mpi *)r, signature, key_size);
if (ret != 0) {