mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-18 06:35:35 +03:00
ci(esp_wifi): skip timing test if hw not available
This commit is contained in:
@@ -19,6 +19,13 @@ string(SUBSTRING "${WIFI_SUPPLICANT_MD5}" 0 7 WIFI_SUPPLICANT_MD5)
|
||||
# Steal some private include directories from wpa_supplicant
|
||||
target_include_directories(${COMPONENT_LIB} PRIVATE ${esp_supplicant_dir}/esp_supplicant/src)
|
||||
target_include_directories(${COMPONENT_LIB} PRIVATE ${esp_supplicant_dir}/src)
|
||||
if(CONFIG_MBEDTLS_HARDWARE_SHA)
|
||||
if(NOT CONFIG_SOC_SHA_SUPPORT_PARALLEL_ENG)
|
||||
target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_FAST_PSK)
|
||||
else()
|
||||
target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_FAST_PBKDF2)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_definitions(-DWIFI_SUPPLICANT_MD5=\"${WIFI_SUPPLICANT_MD5}\")
|
||||
add_definitions(-DCONFIG_WPA3_SAE)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
@@ -15,6 +15,11 @@
|
||||
#define NUM_ITERATIONS 5
|
||||
#define MIN_PASSPHARSE_LEN 8
|
||||
|
||||
#ifdef CONFIG_FAST_PSK
|
||||
int esp_fast_psk(const char *password, size_t password_len, const uint8_t *ssid,
|
||||
size_t ssid_len, size_t iterations, uint8_t *output, size_t output_len);
|
||||
#endif
|
||||
|
||||
void fastpbkdf2_hmac_sha1(const uint8_t *pw, size_t npw,
|
||||
const uint8_t *salt, size_t nsalt,
|
||||
uint32_t iterations,
|
||||
@@ -50,9 +55,14 @@ TEST_CASE("Test pbkdf2", "[crypto-pbkdf2]")
|
||||
strlen("espressif2"), 4096, PMK_LEN, expected_pmk);
|
||||
TEST_ASSERT(memcmp(PMK, expected_pmk, PMK_LEN) == 0);
|
||||
|
||||
int64_t total_time_pbkdf2 = 0; // Variable to store total time for pbkdf2_sha1
|
||||
int64_t total_time_pbkdf2 = 0;
|
||||
int64_t total_time_mbedtls = 0;
|
||||
#ifdef CONFIG_FAST_PSK
|
||||
int64_t total_time_fast_psk = 0;
|
||||
#endif
|
||||
#ifdef CONFIG_FAST_PBKDF2
|
||||
int64_t total_time_fast_pbkdf2 = 0;
|
||||
#endif
|
||||
int i;
|
||||
for (i = 0; i < NUM_ITERATIONS; i++) {
|
||||
/* Calculate PMK using random ssid and passphrase and compare */
|
||||
@@ -89,23 +99,34 @@ TEST_CASE("Test pbkdf2", "[crypto-pbkdf2]")
|
||||
}
|
||||
TEST_ASSERT(memcmp(PMK, expected_pmk, PMK_LEN) == 0);
|
||||
|
||||
#if 0
|
||||
#ifdef CONFIG_FAST_PSK
|
||||
start_time = esp_timer_get_time();
|
||||
esp_fast_psk((char *)passphrase, os_strlen((char *)passphrase),
|
||||
ssid, ssid_len, 4096, PMK, PMK_LEN);
|
||||
end_time = esp_timer_get_time();
|
||||
total_time_fast_psk += (end_time - start_time);
|
||||
TEST_ASSERT(memcmp(PMK, expected_pmk, PMK_LEN) == 0);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FAST_PBKDF2
|
||||
start_time = esp_timer_get_time();
|
||||
fastpbkdf2_hmac_sha1((const u8 *)passphrase, os_strlen((char *)passphrase), ssid, ssid_len, 4096, PMK, PMK_LEN);
|
||||
end_time = esp_timer_get_time();
|
||||
total_time_fast_pbkdf2 += (end_time - start_time);
|
||||
TEST_ASSERT(memcmp(PMK, expected_pmk, PMK_LEN) == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Calculate average time for pbkdf2_sha1
|
||||
int64_t avg_time_pbkdf2 = total_time_pbkdf2 / NUM_ITERATIONS;
|
||||
// Calculate average time for mbedtls_pkcs5_pbkdf2_hmac_ext
|
||||
int64_t avg_time_mbedtls = total_time_mbedtls / NUM_ITERATIONS;
|
||||
int64_t avg_time_fast = total_time_fast_pbkdf2 / NUM_ITERATIONS;
|
||||
|
||||
// Log average times
|
||||
ESP_LOGI("Timing", "Average time for pbkdf2_sha1: %lld microseconds", avg_time_pbkdf2);
|
||||
ESP_LOGI("Timing", "Average time for fast_pbkdf2_sha1: %lld microseconds", avg_time_fast);
|
||||
#ifdef CONFIG_FAST_PSK
|
||||
ESP_LOGI("Timing", "Average time for esp_fast_psk: %lld microseconds", total_time_fast_psk / NUM_ITERATIONS);
|
||||
#endif
|
||||
#ifdef CONFIG_FAST_PBKDF2
|
||||
ESP_LOGI("Timing", "Average time for fastpbkdf2_hmac_sha1: %lld microseconds", total_time_fast_pbkdf2 / NUM_ITERATIONS);
|
||||
#endif
|
||||
ESP_LOGI("Timing", "Average time for mbedtls_pkcs5_pbkdf2_hmac_ext: %lld microseconds", avg_time_mbedtls);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user