From 88d32a8aaf5758f882864995fad92999f4a69801 Mon Sep 17 00:00:00 2001 From: Li Jingyi Date: Tue, 21 Jul 2020 18:54:56 +0800 Subject: [PATCH] feat(wpa_supplicant): sync makefile with idf --- components/wpa_supplicant/CMakeLists.txt | 121 ++++++++++++++++++-- components/wpa_supplicant/Kconfig | 44 ++++++- components/wpa_supplicant/component.mk | 35 ++++-- components/wpa_supplicant/test/component.mk | 6 + 4 files changed, 190 insertions(+), 16 deletions(-) diff --git a/components/wpa_supplicant/CMakeLists.txt b/components/wpa_supplicant/CMakeLists.txt index e1a801a1..2d07296d 100644 --- a/components/wpa_supplicant/CMakeLists.txt +++ b/components/wpa_supplicant/CMakeLists.txt @@ -1,16 +1,118 @@ +set(srcs "port/os_xtensa.c" + "src/ap/ap_config.c" + "src/ap/ieee802_1x.c" + "src/ap/wpa_auth.c" + "src/ap/wpa_auth_ie.c" + "src/common/sae.c" + "src/common/wpa_common.c" + "src/common/dpp.c" + "src/crypto/aes-ctr.c" + "src/crypto/aes-siv.c" + "src/crypto/sha256-kdf.c" + "src/crypto/aes-cbc.c" + "src/crypto/aes-ccm.c" + "src/crypto/aes-internal-dec.c" + "src/crypto/aes-internal-enc.c" + "src/crypto/aes-internal.c" + "src/crypto/aes-omac1.c" + "src/crypto/aes-unwrap.c" + "src/crypto/aes-wrap.c" + "src/crypto/aes-omac1.c" + "src/crypto/bignum.c" + "src/crypto/ccmp.c" + "src/crypto/crypto_mbedtls.c" + "src/crypto/crypto_mbedtls-bignum.c" + "src/crypto/crypto_mbedtls-ec.c" + "src/crypto/crypto_ops.c" + "src/crypto/crypto_internal-cipher.c" + "src/crypto/crypto_internal-modexp.c" + "src/crypto/crypto_internal-rsa.c" + "src/crypto/crypto_mbedtls-rsa.c" + "src/crypto/crypto_internal.c" + "src/crypto/des-internal.c" + "src/crypto/dh_group5.c" + "src/crypto/dh_groups.c" + "src/crypto/md4-internal.c" + "src/crypto/md5-internal.c" + "src/crypto/md5.c" + "src/crypto/ms_funcs.c" + "src/crypto/rc4.c" + "src/crypto/sha1-internal.c" + "src/crypto/sha1-pbkdf2.c" + "src/crypto/sha1.c" + "src/crypto/sha256-internal.c" + "src/crypto/sha256.c" + "src/crypto/sha1-tlsprf.c" + "src/crypto/sha256-tlsprf.c" + "src/crypto/sha384-tlsprf.c" + "src/crypto/sha256-prf.c" + "src/eap_peer/chap.c" + "src/eap_peer/eap.c" + "src/eap_peer/eap_common.c" + "src/eap_peer/eap_mschapv2.c" + "src/eap_peer/eap_peap.c" + "src/eap_peer/eap_peap_common.c" + "src/eap_peer/eap_tls.c" + "src/eap_peer/eap_tls_common.c" + "src/eap_peer/eap_ttls.c" + "src/eap_peer/mschapv2.c" + "src/esp_supplicant/esp_wpa2.c" + "src/esp_supplicant/esp_wpa_main.c" + "src/esp_supplicant/esp_wpas_glue.c" + "src/esp_supplicant/esp_wpa3.c" + "src/rsn_supp/pmksa_cache.c" + "src/rsn_supp/wpa.c" + "src/rsn_supp/wpa_ie.c" + "src/utils/base64.c" + "src/utils/common.c" + "src/utils/ext_password.c" + "src/utils/uuid.c" + "src/utils/wpabuf.c" + "src/utils/wpa_debug.c" + "src/utils/json.c" + "src/wps/wps.c" + "src/wps/wps_attr_build.c" + "src/wps/wps_attr_parse.c" + "src/wps/wps_attr_process.c" + "src/wps/wps_common.c" + "src/wps/wps_dev_attr.c" + "src/wps/wps_enrollee.c" + "src/wps/wps_registrar.c" + "src/wps/wps_validate.c") -set(COMPONENT_SRCDIRS "port" "port/esp_supplicant" "src/ap" "src/common" "src/crypto" "src/eap_peer" "src/fast_crypto" "src/rsn_supp" "src/tls" "src/utils" "src/wps") -set(COMPONENT_ADD_INCLUDEDIRS "port" "port/include" "src") -set(COMPONENT_PRIV_REQUIRES "mbedtls" "freertos" "heap" "newlib") +if(CONFIG_WPA_MBEDTLS_CRYPTO) + set(tls_src "src/crypto/tls_mbedtls.c") +else() + set(tls_src + "src/tls/asn1.c" + "src/tls/bignum.c" + "src/tls/pkcs1.c" + "src/tls/pkcs5.c" + "src/tls/pkcs8.c" + "src/tls/rsa.c" + "src/tls/tls_internal.c" + "src/tls/tlsv1_client.c" + "src/tls/tlsv1_client_read.c" + "src/tls/tlsv1_client_write.c" + "src/tls/tlsv1_common.c" + "src/tls/tlsv1_cred.c" + "src/tls/tlsv1_record.c" + "src/tls/tlsv1_server.c" + "src/tls/tlsv1_server_read.c" + "src/tls/tlsv1_server_write.c" + "src/tls/x509v3.c" + ) +endif() +idf_component_register(SRCS "${srcs}" + INCLUDE_DIRS include port/include include/esp_supplicant + PRIV_INCLUDE_DIRS src + PRIV_REQUIRES mbedtls freertos heap newlib) -register_component() - -target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-strict-aliasing -Wno-unused-value -Wno-empty-body) +target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-strict-aliasing) target_compile_definitions(${COMPONENT_LIB} PRIVATE __ets__ - EMBEDDED_SUPP - ESPRESSIF_USE + ESP_SUPPLICANT IEEE8021X_EAPOL EAP_PEER_METHOD EAP_MSCHAPv2 @@ -21,8 +123,11 @@ target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_WPS2 CONFIG_WPS_PIN USE_WPS_TASK + ESPRESSIF_USE ESP8266_WORKAROUND CONFIG_ECC CONFIG_IEEE80211W CONFIG_WPA3_SAE + CONFIG_SHA256 + CONFIG_DPP ) diff --git a/components/wpa_supplicant/Kconfig b/components/wpa_supplicant/Kconfig index d3b29afb..0057d40c 100644 --- a/components/wpa_supplicant/Kconfig +++ b/components/wpa_supplicant/Kconfig @@ -1,4 +1,4 @@ -menu "wpa_supplicant" +menu "Supplicant" config LTM_FAST bool "Use faster div, esptmod, sqr, montgomery multiplication algorithm" @@ -8,4 +8,46 @@ config LTM_FAST montgomery multiplication algorithm. Enable this option will cost about 3K ROM more than disable this option. + config WPA_MBEDTLS_CRYPTO + bool "Use MbedTLS crypto API's" + default y + help + Select this option to use MbedTLS crypto API's which utilize hardware acceleration. + + config WPA_DEBUG_PRINT + bool "Print debug messages from WPA Supplicant" + default n + help + Select this option to print logging information from WPA supplicant, + this includes handshake information and key hex dumps depending + on the project logging level. + + Enabling this could increase the build size ~60kb + depending on the project logging level. + + config WPA_TESTING_OPTIONS + bool "Add DPP testing code" + default n + help + Select this to enable unity test for DPP. + + config WPA_WPS_WARS + bool "Add WPS Inter operatability Fixes" + default n + help + Select this option to enable WPS related IOT fixes with + different APs. This option fixes IOT related issues with + APs which do not follow some of the standards of WPS-2.0 + specification. These do not include any of the security + related bypassing, just simple configuration corrections. + + Current fixes under this flag. + 1. Allow NULL-padded WPS attributes: Some APs keep NULL-padding + at the end of some variable length WPS Attributes. + This is not as par the WPS2.0 specs, but to avoid interop issues, + ignore the padding by reducing the attribute length by 1. + 2. Bypass WPS-Config method validation: Some APs set display/pbc + button bit without setting virtual/phycial display/button bit which + will cause M2 validation fail, bypassing WPS-Config method validation. + endmenu diff --git a/components/wpa_supplicant/component.mk b/components/wpa_supplicant/component.mk index ffe0599a..af2369cf 100644 --- a/components/wpa_supplicant/component.mk +++ b/components/wpa_supplicant/component.mk @@ -1,8 +1,29 @@ -COMPONENT_ADD_INCLUDEDIRS := port/include port -COMPONENT_PRIV_INCLUDEDIRS := src -COMPONENT_SRCDIRS := port port/esp_supplicant src/ap src/common src/crypto src/eap_peer src/fast_crypto src/rsn_supp \ - src/tls src/utils src/wps +# supplicant make file -CFLAGS += -DEMBEDDED_SUPP -D__ets__ -DESPRESSIF_USE -DIEEE8021X_EAPOL -DEAP_PEER_METHOD -DEAP_TLS -DEAP_TTLS -DEAP_PEAP -DEAP_MSCHAPv2 \ - -DUSE_WPA2_TASK -DCONFIG_WPS2 -DCONFIG_WPS_PIN -DUSE_WPS_TASK -DESP8266_WORKAROUND -Wno-unused-but-set-variable -Wno-empty-body -Wno-unused-value \ - -DCONFIG_ECC -DCONFIG_WPA3_SAE -DCONFIG_IEEE80211W +COMPONENT_PRIV_INCLUDEDIRS := src +COMPONENT_SRCDIRS := port src/ap src/common src/crypto src/eap_peer src/fast_crypto src/rsn_supp src/tls src/utils src/esp_supplicant src/wps +COMPONENT_ADD_INCLUDEDIRS := include port/include include/esp_supplicant + +ifeq ($(CONFIG_WPA_MBEDTLS_CRYPTO), y) + COMPONENT_OBJEXCLUDE := src/tls/asn1.o \ + src/tls/bignum.o \ + src/tls/pkcs1.o \ + src/tls/pkcs5.o \ + src/tls/pkcs8.o \ + src/tls/rsa.o \ + src/tls/tls_internal.o \ + src/tls/tlsv1_client.o \ + src/tls/tlsv1_client_read.o \ + src/tls/tlsv1_client_write.o \ + src/tls/tlsv1_common.o \ + src/tls/tlsv1_cred.o \ + src/tls/tlsv1_record.o \ + src/tls/tlsv1_server.o \ + src/tls/tlsv1_server_read.o \ + src/tls/tlsv1_server_write.o \ + src/tls/x509v3.o +else + COMPONENT_OBJEXCLUDE := src/crypto/tls_mbedtls.o +endif + +CFLAGS += -DCONFIG_DPP -DCONFIG_WPA3_SAE -DCONFIG_IEEE80211W -DESP_SUPPLICANT -DIEEE8021X_EAPOL -DEAP_PEER_METHOD -DEAP_TLS -DEAP_TTLS -DEAP_PEAP -DEAP_MSCHAPv2 -DUSE_WPA2_TASK -DCONFIG_WPS2 -DCONFIG_WPS_PIN -DUSE_WPS_TASK -DESPRESSIF_USE -DESP8266_WORKAROUND -DCONFIG_ECC -D__ets__ -Wno-strict-aliasing diff --git a/components/wpa_supplicant/test/component.mk b/components/wpa_supplicant/test/component.mk index 5dd172bd..9feb1cfc 100644 --- a/components/wpa_supplicant/test/component.mk +++ b/components/wpa_supplicant/test/component.mk @@ -2,4 +2,10 @@ #Component Makefile # +COMPONENT_PRIV_INCLUDEDIRS := ../src +COMPONENT_SRCDIRS := . + COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive + +CFLAGS+= -DCONFIG_WPA3_SAE +CFLAGS+= -DCONFIG_DPP