1set(linker_fragments linker.lf)
2
3if( NOT CONFIG_ESP_WIFI_ENABLED
4    AND NOT CMAKE_BUILD_EARLY_EXPANSION )
5    # This component provides only "esp_supplicant" headers if WiFi not enabled
6    # (implementation supported optionally in a managed component esp_wifi_remote)
7    idf_component_register(INCLUDE_DIRS esp_supplicant/include)
8    return()
9endif()
10
11set(srcs "port/os_xtensa.c"
12    "port/eloop.c"
13    "src/ap/ap_config.c"
14    "src/ap/ieee802_1x.c"
15    "src/ap/wpa_auth.c"
16    "src/ap/wpa_auth_ie.c"
17    "src/ap/pmksa_cache_auth.c"
18    "src/ap/sta_info.c"
19    "src/ap/ieee802_11.c"
20    "src/ap/comeback_token.c"
21    "src/common/sae.c"
22    "src/common/dragonfly.c"
23    "src/common/wpa_common.c"
24    "src/utils/bitfield.c"
25    "src/crypto/aes-siv.c"
26    "src/crypto/sha256-kdf.c"
27    "src/crypto/ccmp.c"
28    "src/crypto/aes-gcm.c"
29    "src/crypto/crypto_ops.c"
30    "src/crypto/dh_group5.c"
31    "src/crypto/dh_groups.c"
32    "src/crypto/ms_funcs.c"
33    "src/crypto/sha1-tlsprf.c"
34    "src/crypto/sha256-tlsprf.c"
35    "src/crypto/sha384-tlsprf.c"
36    "src/crypto/sha256-prf.c"
37    "src/crypto/sha1-prf.c"
38    "src/crypto/sha384-prf.c"
39    "src/crypto/md4-internal.c"
40    "src/crypto/sha1-tprf.c"
41    "src/eap_common/eap_wsc_common.c"
42    "src/common/ieee802_11_common.c"
43    "src/eap_peer/chap.c"
44    "src/eap_peer/eap.c"
45    "src/eap_peer/eap_common.c"
46    "src/eap_peer/eap_mschapv2.c"
47    "src/eap_peer/eap_peap.c"
48    "src/eap_peer/eap_peap_common.c"
49    "src/eap_peer/eap_tls.c"
50    "src/eap_peer/eap_tls_common.c"
51    "src/eap_peer/eap_ttls.c"
52    "src/eap_peer/mschapv2.c"
53    "src/eap_peer/eap_fast.c"
54    "src/eap_peer/eap_fast_common.c"
55    "src/eap_peer/eap_fast_pac.c"
56    "src/rsn_supp/pmksa_cache.c"
57    "src/rsn_supp/wpa.c"
58    "src/rsn_supp/wpa_ie.c"
59    "src/utils/base64.c"
60    "src/utils/common.c"
61    "src/utils/ext_password.c"
62    "src/utils/uuid.c"
63    "src/utils/wpabuf.c"
64    "src/utils/wpa_debug.c"
65    "src/utils/json.c"
66    "src/wps/wps.c"
67    "src/wps/wps_attr_build.c"
68    "src/wps/wps_attr_parse.c"
69    "src/wps/wps_attr_process.c"
70    "src/wps/wps_common.c"
71    "src/wps/wps_dev_attr.c"
72    "src/wps/wps_enrollee.c")
73
74set(esp_srcs "esp_supplicant/src/esp_eap_client.c"
75    "esp_supplicant/src/esp_wpa2_api_port.c"
76    "esp_supplicant/src/esp_wpa_main.c"
77    "esp_supplicant/src/esp_wpas_glue.c"
78    "esp_supplicant/src/esp_common.c"
79    "esp_supplicant/src/esp_wps.c"
80    "esp_supplicant/src/esp_wpa3.c"
81    "esp_supplicant/src/esp_owe.c")
82if(CONFIG_ESP_WIFI_SOFTAP_SUPPORT)
83    set(esp_srcs ${esp_srcs} "esp_supplicant/src/esp_hostap.c")
84endif()
85
86if(CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT)
87    set(tls_src "esp_supplicant/src/crypto/tls_mbedtls.c")
88else()
89    set(tls_src
90    "src/tls/asn1.c"
91    "src/tls/bignum.c"
92    "src/tls/pkcs1.c"
93    "src/tls/pkcs5.c"
94    "src/tls/pkcs8.c"
95    "src/tls/bignum.c"
96    "src/tls/rsa.c"
97    "src/crypto/tls_internal.c"
98    "src/tls/tlsv1_client.c"
99    "src/tls/tlsv1_client_read.c"
100    "src/tls/tlsv1_client_write.c"
101    "src/tls/tlsv1_common.c"
102    "src/tls/tlsv1_cred.c"
103    "src/tls/tlsv1_record.c"
104    "src/tls/tlsv1_client_ocsp.c"
105    "src/tls/x509v3.c")
106endif()
107
108if(CONFIG_ESP_WIFI_MBEDTLS_CRYPTO)
109    set(crypto_src
110    "esp_supplicant/src/crypto/fastpbkdf2.c"
111    "esp_supplicant/src/crypto/crypto_mbedtls.c"
112    "esp_supplicant/src/crypto/crypto_mbedtls-bignum.c"
113    "esp_supplicant/src/crypto/crypto_mbedtls-rsa.c"
114    "esp_supplicant/src/crypto/crypto_mbedtls-ec.c")
115    # Add internal RC4 as RC4 has been removed from mbedtls
116    set(crypto_src ${crypto_src} "src/crypto/rc4.c")
117    if(NOT CONFIG_MBEDTLS_DES_C)
118        set(crypto_src ${crypto_src} "src/crypto/des-internal.c")
119    endif()
120    # Enabling this only for WiFi is probably not a good idea since MbedTLS
121    # uses generic crypto init/update functions for this. That causes
122    # binary size increment since all the other enabled module
123    # functions will also linked in. Even after not using direct MbedTLS APIs
124    # for these, these API are still faster since these all will be using
125    # AES APIs which is using hardware AES blocks.
126    if(NOT CONFIG_MBEDTLS_CMAC_C)
127        set(crypto_src ${crypto_src} "src/crypto/aes-omac1.c")
128    endif()
129    if(NOT CONFIG_MBEDTLS_NIST_KW_C)
130        set(crypto_src ${crypto_src}
131        "src/crypto/aes-wrap.c"
132        "src/crypto/aes-unwrap.c")
133    endif()
134    if(NOT CONFIG_MBEDTLS_NIST_KW_C OR NOT CONFIG_MBEDTLS_CMAC_C OR NOT CONFIG_MBEDTLS_CCM_C)
135        set(crypto_src ${crypto_src} "src/crypto/aes-ccm.c")
136    endif()
137else()
138    set(crypto_src
139    "src/crypto/rc4.c"
140    "src/crypto/aes-ctr.c"
141    "src/crypto/aes-cbc.c"
142    "src/crypto/aes-ccm.c"
143    "src/crypto/aes-internal-dec.c"
144    "src/crypto/aes-internal-enc.c"
145    "src/crypto/aes-internal.c"
146    "src/crypto/aes-omac1.c"
147    "src/crypto/aes-unwrap.c"
148    "src/crypto/aes-wrap.c"
149    "src/crypto/crypto_internal-cipher.c"
150    "src/crypto/crypto_internal-modexp.c"
151    "src/crypto/crypto_internal-rsa.c"
152    "src/crypto/crypto_internal.c"
153    "src/crypto/des-internal.c"
154    "src/crypto/md4-internal.c"
155    "src/crypto/md5-internal.c"
156    "src/crypto/md5.c"
157    "src/crypto/sha1-internal.c"
158    "src/crypto/sha1-pbkdf2.c"
159    "src/crypto/sha1.c"
160    "src/crypto/sha256-internal.c"
161    "src/crypto/sha256.c"
162    "src/crypto/sha384-internal.c"
163    "src/crypto/sha512-internal.c"
164    "src/crypto/sha256.c")
165endif()
166
167if(CONFIG_ESP_WIFI_11KV_SUPPORT OR CONFIG_ESP_WIFI_11R_SUPPORT)
168    set(roaming_src
169    "src/common/ieee802_11_common.c")
170    if(CONFIG_ESP_WIFI_11KV_SUPPORT)
171        set(roaming_src ${roaming_src} "src/common/rrm.c" "src/common/wnm_sta.c")
172    endif()
173    if(CONFIG_ESP_WIFI_11R_SUPPORT)
174        set(roaming_src ${roaming_src} "src/rsn_supp/wpa_ft.c")
175    endif()
176else()
177    set(roaming_src "")
178endif()
179
180if(CONFIG_ESP_WIFI_ENABLE_SAE_PK)
181    set(srcs ${srcs}
182    "src/common/sae_pk.c")
183endif()
184
185if(CONFIG_ESP_WIFI_11KV_SUPPORT OR CONFIG_ESP_WIFI_11R_SUPPORT)
186    set(srcs ${srcs}
187    "src/common/bss.c"
188    "src/common/scan.c"
189    "esp_supplicant/src/esp_scan.c")
190endif()
191
192if(CONFIG_ESP_WIFI_MBO_SUPPORT)
193    set(mbo_src "src/common/mbo.c")
194else()
195    set(mbo_src "")
196endif()
197
198if(CONFIG_ESP_WIFI_DPP_SUPPORT)
199    set(dpp_src "src/common/dpp.c"
200    "esp_supplicant/src/esp_dpp.c")
201else()
202    set(dpp_src "")
203endif()
204
205if(CONFIG_ESP_WIFI_WPS_SOFTAP_REGISTRAR)
206    set(wps_registrar_src
207    "src/ap/wps_hostapd.c"
208    "src/eap_server/eap_server.c"
209    "src/eap_server/eap_server_methods.c"
210    "src/eap_server/eap_server_wsc.c"
211    "src/ap/eap_user_db.c"
212    "src/eapol_auth/eapol_auth_sm.c"
213    "src/eap_server/eap_server_identity.c"
214    "esp_supplicant/src/esp_hostpad_wps.c"
215    "src/wps/wps_registrar.c")
216else()
217    set(wps_registrar_src "")
218endif()
219
220idf_component_register(SRCS "${srcs}" "${esp_srcs}" "${tls_src}" "${roaming_src}"
221                            "${crypto_src}" "${mbo_src}" "${dpp_src}" "${wps_registrar_src}"
222                    INCLUDE_DIRS include port/include esp_supplicant/include
223                    PRIV_INCLUDE_DIRS src src/utils esp_supplicant/src src/crypto
224                    LDFRAGMENTS   ${linker_fragments}
225                    PRIV_REQUIRES mbedtls esp_timer esp_wifi)
226
227target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-strict-aliasing -Wno-write-strings -Werror)
228target_compile_definitions(${COMPONENT_LIB} PRIVATE
229    __ets__
230    ESP_SUPPLICANT
231    IEEE8021X_EAPOL
232    EAP_PEER_METHOD
233    EAP_MSCHAPv2
234    EAP_TTLS
235    EAP_TLS
236    EAP_PEAP
237    USE_WPA2_TASK
238    CONFIG_WPS
239    USE_WPS_TASK
240    ESPRESSIF_USE
241    CONFIG_ECC
242    CONFIG_IEEE80211W
243    CONFIG_SHA256
244    CONFIG_NO_RADIUS
245    CONFIG_FAST_PBKDF2
246    )
247
248if(CONFIG_ESP_WIFI_ENABLE_WPA3_SAE)
249    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_WPA3_SAE)
250endif()
251if(CONFIG_ESP_WIFI_ENABLE_SAE_PK)
252    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_SAE_PK)
253endif()
254if(CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT)
255    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_SAE)
256endif()
257if(CONFIG_ESP_WIFI_WPS_STRICT)
258    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_WPS_STRICT)
259endif()
260if(CONFIG_ESP_WIFI_SUITE_B_192)
261    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_SUITEB192)
262endif()
263if(CONFIG_WPA_SUITE_B)
264    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_SUITEB)
265endif()
266if(CONFIG_ESP_WIFI_GCMP_SUPPORT)
267    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_GCMP)
268endif()
269if(CONFIG_ESP_WIFI_GMAC_SUPPORT)
270    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_GMAC)
271endif()
272if(CONFIG_ESP_WIFI_MBO_SUPPORT)
273    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_MBO)
274endif()
275if(CONFIG_ESP_WIFI_DPP_SUPPORT)
276    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_DPP)
277endif()
278if(CONFIG_ESP_WIFI_11KV_SUPPORT)
279    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_SUPPLICANT_TASK CONFIG_WNM CONFIG_RRM CONFIG_IEEE80211KV)
280endif()
281if(CONFIG_ESP_WIFI_11R_SUPPORT)
282    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_IEEE80211R)
283endif()
284if(CONFIG_ESP_WIFI_TESTING_OPTIONS)
285    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_TESTING_OPTIONS)
286endif()
287if(NOT CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT)
288    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_TLS_INTERNAL_CLIENT
289                CONFIG_TLSV11 CONFIG_TLSV12 EAP_FAST)
290endif()
291if(CONFIG_ESP_WIFI_MBEDTLS_CRYPTO)
292    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_CRYPTO_MBEDTLS)
293else()
294    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_CRYPTO_INTERNAL)
295endif()
296if(CONFIG_ESP_WIFI_WPS_SOFTAP_REGISTRAR)
297    target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_WPS_REGISTRAR)
298endif()
299if(CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA)
300        target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_OWE_STA)
301endif()
302set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY LINK_INTERFACE_MULTIPLICITY 3)
303
304target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
305