]> granicus.if.org Git - esp-idf/commitdiff
esp32/wpa_supplicant: fix some bugs introduced by wifi os adapter
authorLiu Zhi Fu <liuzhifu@espressif.com>
Tue, 29 May 2018 12:25:20 +0000 (20:25 +0800)
committerLiu Zhi Fu <liuzhifu@espressif.com>
Thu, 31 May 2018 09:09:40 +0000 (17:09 +0800)
1. Fix the WiFi/BT coexist bug
2. Fix WPA2 enterprise example crash bug
3. Add size and version check for crypto type struct
4. Add MD5 check for crypto type header file

components/esp32/fast_crypto_ops.c
components/esp32/include/esp_wifi_crypto_types.h
components/esp32/include/esp_wifi_internal.h
components/esp32/lib
components/esp32/phy_init.c
components/esp32/test/component.mk
components/esp32/test/test_header_files_md5.c [moved from components/esp32/test/test_os_adapter_md5.c with 52% similarity]
components/wpa_supplicant/include/wpa2/eap_peer/eap_methods.h

index aa0054d707d1cedea7889c2dad54f00ab3768b6b..7e05a7b8c9d459802f2c63b23b544892128c0d16 100644 (file)
@@ -36,6 +36,8 @@
  * we recommend, so as the API in WPS default and WPA2 default.
  */
 const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs = {
+    .size = sizeof(wpa_crypto_funcs_t), 
+    .version = ESP_WIFI_CRYPTO_VERSION,
     .aes_wrap = (esp_aes_wrap_t)fast_aes_wrap,
     .aes_unwrap = (esp_aes_unwrap_t)fast_aes_unwrap,
     .hmac_sha256_vector = (esp_hmac_sha256_vector_t)fast_hmac_sha256_vector,
@@ -58,6 +60,8 @@ const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs = {
 };
 
 const wps_crypto_funcs_t g_wifi_default_wps_crypto_funcs = {
+    .size = sizeof(wps_crypto_funcs_t), 
+    .version = ESP_WIFI_CRYPTO_VERSION,
     .aes_128_encrypt = (esp_aes_128_encrypt_t)fast_aes_128_cbc_encrypt,
     .aes_128_decrypt = (esp_aes_128_decrypt_t)fast_aes_128_cbc_decrypt,
     .crypto_mod_exp = (esp_crypto_mod_exp_t)fast_crypto_mod_exp,
@@ -85,6 +89,8 @@ const wps_crypto_funcs_t g_wifi_default_wps_crypto_funcs = {
  * crypto_hash_finish, so do crypto_cipher.
  */
 const wpa2_crypto_funcs_t g_wifi_default_wpa2_crypto_funcs = {
+    .size = sizeof(wpa2_crypto_funcs_t),
+    .version = ESP_WIFI_CRYPTO_VERSION,
     .crypto_hash_init = (esp_crypto_hash_init_t)fast_crypto_hash_init,
     .crypto_hash_update = (esp_crypto_hash_update_t)fast_crypto_hash_update,
     .crypto_hash_finish = (esp_crypto_hash_finish_t)fast_crypto_hash_finish,
@@ -100,6 +106,8 @@ const wpa2_crypto_funcs_t g_wifi_default_wpa2_crypto_funcs = {
     .eap_peer_blob_deinit = (esp_eap_peer_blob_deinit_t)eap_peer_blob_deinit,
     .eap_peer_config_init = (esp_eap_peer_config_init_t)eap_peer_config_init,
     .eap_peer_config_deinit = (esp_eap_peer_config_deinit_t)eap_peer_config_deinit,
+    .eap_peer_register_methods = (esp_eap_peer_register_methods_t)eap_peer_register_methods,
+    .eap_peer_unregister_methods = (esp_eap_peer_unregister_methods_t)eap_peer_unregister_methods,
     .eap_deinit_prev_method = (esp_eap_deinit_prev_method_t)eap_deinit_prev_method,
     .eap_peer_get_eap_method = (esp_eap_peer_get_eap_method_t)eap_peer_get_eap_method,
     .eap_sm_abort = (esp_eap_sm_abort_t)eap_sm_abort,
index 2e605d870c36988bec8ac39bad33b3540574fa6c..0848f06ac90d5fa216a141fe9f1379e70cf4ad45 100644 (file)
@@ -27,6 +27,8 @@
 extern "C" {
 #endif
 
+#define ESP_WIFI_CRYPTO_VERSION 0x00000001
+
 /*
  * Enumeration for hash operations.
  * When WPA2 is connecting, this enum is used to
@@ -697,6 +699,8 @@ typedef int (*esp_wps_is_selected_pbc_registrar_t)(const void *msg, unsigned cha
   *        hardware.
   */
 typedef struct {
+    uint32_t size;
+    uint32_t version;
     esp_aes_wrap_t aes_wrap;                         /**< station connect function used when send EAPOL frame */
     esp_aes_unwrap_t aes_unwrap;                     /**< station connect function used when decrypt key data */
     esp_hmac_sha256_vector_t hmac_sha256_vector;     /**< station connect function used when check MIC */
@@ -724,6 +728,8 @@ typedef struct {
   *        hardware.
   */
 typedef struct{
+    uint32_t size;
+    uint32_t version;
     esp_aes_128_encrypt_t aes_128_encrypt;          /**< function used to process message when do WPS */
     esp_aes_128_decrypt_t aes_128_decrypt;          /**< function used to process message when do WPS */
     esp_crypto_mod_exp_t crypto_mod_exp;            /**< function used to calculate public key and private key */
@@ -750,6 +756,8 @@ typedef struct{
   *        hardware.
   */
 typedef struct {
+    uint32_t size;
+    uint32_t version;
     esp_crypto_hash_init_t crypto_hash_init;                  /**< function used to initialize a crypto_hash structure when use TLSV1 */
     esp_crypto_hash_update_t crypto_hash_update;              /**< function used to calculate hash data when use TLSV1 */
     esp_crypto_hash_finish_t crypto_hash_finish;              /**< function used to finish the hash calculate when use TLSV1 */
@@ -765,6 +773,8 @@ typedef struct {
     esp_eap_peer_blob_deinit_t eap_peer_blob_deinit;
     esp_eap_peer_config_init_t eap_peer_config_init;
     esp_eap_peer_config_deinit_t eap_peer_config_deinit;
+    esp_eap_peer_register_methods_t eap_peer_register_methods;
+    esp_eap_peer_unregister_methods_t eap_peer_unregister_methods;
     esp_eap_deinit_prev_method_t eap_deinit_prev_method;
     esp_eap_peer_get_eap_method_t eap_peer_get_eap_method;
     esp_eap_sm_abort_t eap_sm_abort;
index 875e5ac04a4f165481a589dfdecdffff3a5eb240..7ddfd69446f669642b8a489405ee6431a11414f7 100644 (file)
@@ -138,6 +138,17 @@ esp_err_t esp_wifi_internal_set_sta_ip(void);
   */
 esp_err_t esp_wifi_internal_osi_funcs_md5_check(const char *md5);
 
+/**
+  * @brief     Check the MD5 values of the crypto types header files in IDF and WiFi library
+  *
+  * @attention 1. It is used for internal CI version check
+  *
+  * @return
+  *     - ESP_OK : succeed
+  *     - ESP_WIFI_INVALID_ARG : MD5 check fail
+  */
+esp_err_t esp_wifi_internal_crypto_funcs_md5_check(const char *md5);
+
 /**
   * @brief     Allocate a chunk of memory for WiFi driver
   *
index 13a07ae99e83c2781c1bfd322e131226c688a4e9..37f7289daf5aacbd4c789f9e01f451f5e3f45f76 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 13a07ae99e83c2781c1bfd322e131226c688a4e9
+Subproject commit 37f7289daf5aacbd4c789f9e01f451f5e3f45f76
index 314f14268308034430569281eb06272e4f63ba3a..d730e01c6b38c9e18af0d708104c7791b309c4d0 100644 (file)
@@ -133,6 +133,8 @@ esp_err_t esp_phy_rf_init(const esp_phy_init_data_t* init_data, esp_phy_calibrat
 extern esp_err_t wifi_osi_funcs_register(wifi_osi_funcs_t *osi_funcs);
             status = wifi_osi_funcs_register(&g_wifi_osi_funcs);
             if(status != ESP_OK) {
+                ESP_LOGE(TAG, "failed to register wifi os adapter, ret(%d)", status);
+                _lock_release(&s_phy_rf_init_lock);
                 return ESP_FAIL;
             }
             coex_bt_high_prio();
index 178dd4cf4df3133593aeeeba3a37222925175d27..592b9b9048d1a9e5a77c03724cb465a13375579a 100644 (file)
@@ -12,6 +12,11 @@ COMPONENT_SRCDIRS := . test_vectors
 WIFI_OS_ADAPTER_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/esp32/include/esp_wifi_os_adapter.h | cut -c 1-7)\"
 CFLAGS+=-DWIFI_OS_ADAPTER_MD5=$(WIFI_OS_ADAPTER_MD5_VAL)
 
+# Calculate MD5 value of header file esp_wifi_crypto_types.h
+WIFI_CRYPTO_MD5_VAL=\"$(shell md5sum $(IDF_PATH)/components/esp32/include/esp_wifi_crypto_types.h | cut -c 1-7)\"
+CFLAGS+=-DWIFI_CRYPTO_MD5=$(WIFI_CRYPTO_MD5_VAL)
+
+
 test_tjpgd.o: test_tjpgd_logo.h
 
 test_tjpgd_logo.h: $(COMPONENT_PATH)/logo.jpg
similarity index 52%
rename from components/esp32/test/test_os_adapter_md5.c
rename to components/esp32/test/test_header_files_md5.c
index 315a386081e6ad29a99ded212f15498948f5a391..009de0ea59e47dfd42d68f8e5b744e26273b9d72 100644 (file)
@@ -5,7 +5,7 @@
 #include "esp_log.h"
 #include "esp_wifi_internal.h"
 
-static const char* TAG = "test_os_adapter_md5";
+static const char* TAG = "test_header_files_md5";
 
 TEST_CASE("wifi os adapter MD5","[wifi]")
 {    
@@ -16,3 +16,13 @@ TEST_CASE("wifi os adapter MD5","[wifi]")
 
     ESP_LOGI(TAG, "test passed...");
 }
+
+TEST_CASE("wifi crypto types MD5","[wifi]")
+{    
+    const char *test_wifi_crypto_funcs_md5 = WIFI_CRYPTO_MD5;
+
+    ESP_LOGI(TAG, "test wifi crypto adapter MD5...");
+    TEST_ESP_OK(esp_wifi_internal_crypto_funcs_md5_check(test_wifi_crypto_funcs_md5));
+
+    ESP_LOGI(TAG, "test passed...");
+}
index 253b2d8a175899e541cb59ac7d2ead267b5c0dae..7d518dec2ceb1c154da2040a575b941a789bf3eb 100644 (file)
@@ -33,4 +33,7 @@ int eap_peer_peap_register(void);
 int eap_peer_ttls_register(void);
 int eap_peer_mschapv2_register(void);
 
+void eap_peer_unregister_methods(void);
+int eap_peer_register_methods(void);
+
 #endif /* EAP_METHODS_H */