From fe9dbc2b1d11fcd06aafbe215cf4d37af94e2b22 Mon Sep 17 00:00:00 2001 From: Kapil Gupta Date: Wed, 16 Jul 2025 12:10:43 +0530 Subject: [PATCH] fix(esp_wifi): skip call to esp_fast_psk() when hardware SHA is not supported --- .../esp_supplicant/src/crypto/crypto_mbedtls.c | 10 ++-------- .../wpa_supplicant/test_apps/main/test_fast_pbkdf2.c | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/components/wpa_supplicant/esp_supplicant/src/crypto/crypto_mbedtls.c b/components/wpa_supplicant/esp_supplicant/src/crypto/crypto_mbedtls.c index 1b16c900b2..b5f3e65061 100644 --- a/components/wpa_supplicant/esp_supplicant/src/crypto/crypto_mbedtls.c +++ b/components/wpa_supplicant/esp_supplicant/src/crypto/crypto_mbedtls.c @@ -788,7 +788,7 @@ int pbkdf2_sha1(const char *passphrase, const u8 *ssid, size_t ssid_len, /* For ESP32: Using pbkdf2_hmac_sha1() because esp_fast_psk() utilizes hardware, * but for ESP32, the SHA1 hardware implementation is slower than the software implementation. */ -#if CONFIG_IDF_TARGET_ESP32 +#if defined(CONFIG_IDF_TARGET_ESP32) || !defined(CONFIG_SOC_SHA_SUPPORTED) fastpbkdf2_hmac_sha1((const u8 *) passphrase, os_strlen(passphrase), ssid, ssid_len, iterations, buf, buflen); return 0; @@ -799,13 +799,7 @@ int pbkdf2_sha1(const char *passphrase, const u8 *ssid, size_t ssid_len, int ret = mbedtls_pkcs5_pbkdf2_hmac_ext(MBEDTLS_MD_SHA1, (const u8 *) passphrase, os_strlen(passphrase), ssid, ssid_len, iterations, buflen, buf); - if (ret != 0) { - ret = -1; - goto cleanup; - } - -cleanup: - return ret; + return ret == 0 ? 0 : -1; #endif } #endif /* defined(CONFIG_MBEDTLS_SHA1_C) || defined(CONFIG_MBEDTLS_HARDWARE_SHA) */ diff --git a/components/wpa_supplicant/test_apps/main/test_fast_pbkdf2.c b/components/wpa_supplicant/test_apps/main/test_fast_pbkdf2.c index 0bedd60ab4..15b89010f0 100644 --- a/components/wpa_supplicant/test_apps/main/test_fast_pbkdf2.c +++ b/components/wpa_supplicant/test_apps/main/test_fast_pbkdf2.c @@ -12,7 +12,7 @@ #include "test_wpa_supplicant_common.h" #define PMK_LEN 32 -#define NUM_ITERATIONS 15 +#define NUM_ITERATIONS 5 #define MIN_PASSPHARSE_LEN 8 void fastpbkdf2_hmac_sha1(const uint8_t *pw, size_t npw,