From fda4fa2eba4bad5b6ee6a211e1496024b802999e Mon Sep 17 00:00:00 2001 From: Shreyas Sheth Date: Fri, 17 Jul 2026 13:54:53 +0530 Subject: [PATCH] fix(esp_wifi): Backport dpp and other fixes 1) Fix crash while connecting to dpp akm 2) Fix phy ref cnt for power management for offchannel_tx 3) Introduced a variable to indicate dpp ap for scan results 4) Introduced WIFI_AUTH_UNKNOWN for ap with misconfigured security parameter --- .../esp_wifi/include/esp_wifi_types_generic.h | 9 ++- components/esp_wifi/lib | 2 +- .../esp_supplicant/include/esp_dpp.h | 4 +- .../esp_supplicant/src/esp_dpp.c | 71 ++++++++++++++----- .../esp_supplicant/src/esp_dpp_i.h | 1 + .../esp_supplicant/src/esp_wifi_driver.h | 1 + .../esp_supplicant/src/esp_wpa_main.c | 13 +++- components/wpa_supplicant/port/include/os.h | 2 +- components/wpa_supplicant/src/common/defs.h | 2 +- components/wpa_supplicant/src/common/dpp.c | 40 ++++------- .../wpa_supplicant/src/common/wpa_common.c | 4 +- components/wpa_supplicant/src/rsn_supp/wpa.c | 9 ++- 12 files changed, 101 insertions(+), 57 deletions(-) diff --git a/components/esp_wifi/include/esp_wifi_types_generic.h b/components/esp_wifi/include/esp_wifi_types_generic.h index 551ecb3a260..4a2b2734664 100644 --- a/components/esp_wifi/include/esp_wifi_types_generic.h +++ b/components/esp_wifi/include/esp_wifi_types_generic.h @@ -43,9 +43,11 @@ typedef enum { #define WIFI_OFFCHAN_TX_REQ 1 /**< Request off-channel transmission */ #define WIFI_OFFCHAN_TX_CANCEL 0 /**< Cancel off-channel transmission */ +#define WIFI_OFFCHAN_TX_CONNECTING_REQ 2 /**< Off-channel Tx request during connecting state; not recommended for use by public APIs */ #define WIFI_ROC_REQ 1 /**< Request remain on channel */ #define WIFI_ROC_CANCEL 0 /**< Cancel remain on channel */ +#define WIFI_ROC_CONNECTING_REQ 2 /**< Remain-on-channel request during connecting state; not recommended for use by public APIs */ /** * @brief Wi-Fi country policy @@ -71,6 +73,9 @@ typedef struct { * Strength of authmodes * Personal Networks : OPEN < WEP < WPA_PSK < OWE < WPA2_PSK = WPA_WPA2_PSK < WAPI_PSK < WPA3_PSK = WPA2_WPA3_PSK = DPP * Enterprise Networks : WIFI_AUTH_WPA_ENTERPRISE < WIFI_AUTH_WPA2_ENTERPRISE < WIFI_AUTH_WPA3_ENT_192 + * + * @note WIFI_AUTH_UNKNOWN indicates an Access Point with invalid or unparseable security configuration + * detected during scan parsing. */ typedef enum { WIFI_AUTH_OPEN = 0, /**< Authenticate mode : open */ @@ -91,6 +96,7 @@ typedef enum { WIFI_AUTH_DUMMY1, WIFI_AUTH_DUMMY2, WIFI_AUTH_WPA_ENTERPRISE, /**< Authenticate mode : WPA-Enterprise security */ + WIFI_AUTH_UNKNOWN, /**< Scan parsed authmode: Unknown or invalid security configuration parsed during scan */ WIFI_AUTH_MAX } wifi_auth_mode_t; @@ -303,7 +309,8 @@ typedef struct { uint32_t wps: 1; /**< Bit: 7 flag to identify if WPS is supported or not */ uint32_t ftm_responder: 1; /**< Bit: 8 flag to identify if FTM is supported in responder mode */ uint32_t ftm_initiator: 1; /**< Bit: 9 flag to identify if FTM is supported in initiator mode */ - uint32_t reserved: 22; /**< Bit: 10..31 reserved */ + uint32_t akm_dpp: 1; /**< Bit: 10 flag set when AP supports mixed DPP AKM (e.g., SAE + DPP or WPA2-PSK + DPP) or when AP only supports DPP AKM */ + uint32_t reserved: 21; /**< Bit: 11..31 reserved */ wifi_country_t country; /**< Country information of AP */ wifi_he_ap_info_t he_ap; /**< HE AP info */ uint8_t bandwidth; /**< For AP 20 MHz this value is set to 1. For AP 40 MHz this value is set to 2. diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index eaf499e8621..08e8a20253c 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit eaf499e862117b3926411a9152dab6343b14e8b9 +Subproject commit 08e8a20253cb57ddb8b528282e304c53682a6454 diff --git a/components/wpa_supplicant/esp_supplicant/include/esp_dpp.h b/components/wpa_supplicant/esp_supplicant/include/esp_dpp.h index f37ff0b7339..536921b314d 100644 --- a/components/wpa_supplicant/esp_supplicant/include/esp_dpp.h +++ b/components/wpa_supplicant/esp_supplicant/include/esp_dpp.h @@ -79,7 +79,9 @@ esp_err_t esp_supp_dpp_deinit(void); * Generates Out Of Band Bootstrap information as an Enrollee which can be * used by a DPP Configurator to provision the Enrollee. * - * @param chan_list List of channels device will be available on for listening + * @param chan_list Comma-separated list of channels for listening (must not be NULL). + * A single channel (e.g., "6") is recommended for reliable discovery. + * If using multiple, prefer non-overlapping channels (e.g., "1,6,11"). * @param type Bootstrap method type, only QR Code method is supported for now. * @param key (Optional) 32 byte Raw Private Key for generating a Bootstrapping Public Key * @param info (Optional) Ancilliary Device Information like Serial Number diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c b/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c index 923faa6a19c..0dd8f878689 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_dpp.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -81,7 +81,7 @@ static uint8_t esp_dpp_deinit_auth(void) static void esp_dpp_call_cb(esp_supp_dpp_event_t evt, void *data) { - if (s_dpp_ctx.dpp_auth) { + if (s_dpp_ctx.dpp_auth && evt != ESP_SUPP_DPP_CFG_RECVD) { esp_dpp_deinit_auth(); } s_dpp_ctx.dpp_event_cb(evt, data); @@ -99,7 +99,8 @@ static void esp_dpp_auth_conf_wait_timeout(void *eloop_ctx, void *timeout_ctx) } esp_err_t esp_dpp_send_action_frame(uint8_t *dest_mac, const uint8_t *buf, uint32_t len, - uint8_t channel, uint32_t wait_time_ms) + uint8_t channel, uint32_t wait_time_ms, + uint32_t offchan_type) { wifi_action_tx_req_t *req = os_zalloc(sizeof(*req) + len);; if (!req) { @@ -116,7 +117,7 @@ esp_err_t esp_dpp_send_action_frame(uint8_t *dest_mac, const uint8_t *buf, uint3 wpa_printf(MSG_DEBUG, "DPP: Mgmt Tx - MAC:" MACSTR ", Channel-%d, WaitT-%d", MAC2STR(dest_mac), channel, wait_time_ms); - if (ESP_OK != esp_wifi_action_tx_req(WIFI_OFFCHAN_TX_REQ, channel, + if (ESP_OK != esp_wifi_action_tx_req(offchan_type, channel, wait_time_ms, req)) { wpa_printf(MSG_ERROR, "DPP: Failed to perform offchannel operation"); esp_dpp_call_cb(ESP_SUPP_DPP_FAIL, (void *)ESP_ERR_DPP_TX_FAILURE); @@ -165,17 +166,30 @@ static void esp_dpp_rx_auth_req(struct action_rx_param *rx_param, uint8_t *dpp_d goto fail; } if (s_dpp_ctx.dpp_auth) { - wpa_printf(MSG_DEBUG, "DPP: Already in DPP authentication exchange - ignore new one"); - return; + if (s_dpp_ctx.dpp_auth->auth_success || !s_dpp_ctx.dpp_auth->waiting_auth_conf) { + wpa_printf(MSG_INFO, "DPP: Cleaning up old completed DPP auth context for new exchange"); + eloop_cancel_timeout(esp_dpp_auth_conf_wait_timeout, NULL, NULL); + dpp_auth_deinit(s_dpp_ctx.dpp_auth); + s_dpp_ctx.dpp_auth = NULL; + } else { + wpa_printf(MSG_DEBUG, "DPP: Already in DPP authentication exchange - ignore new one"); + return; + } } s_dpp_ctx.dpp_auth = dpp_auth_req_rx(NULL, DPP_CAPAB_ENROLLEE, 0, NULL, own_bi, rx_param->channel, (const u8 *)&rx_param->action_frm->u.public_action.v, dpp_data, len); + if (!s_dpp_ctx.dpp_auth) { + wpa_printf(MSG_ERROR, "DPP: Failed to process Authentication Request"); + rc = ESP_ERR_DPP_FAILURE; + goto fail; + } os_memcpy(s_dpp_ctx.dpp_auth->peer_mac_addr, rx_param->sa, ETH_ALEN); wpa_printf(MSG_DEBUG, "DPP: Sending authentication response."); esp_dpp_send_action_frame(rx_param->sa, wpabuf_head(s_dpp_ctx.dpp_auth->resp_msg), wpabuf_len(s_dpp_ctx.dpp_auth->resp_msg), - rx_param->channel, OFFCHAN_TX_WAIT_TIME); + s_dpp_ctx.dpp_auth->curr_chan, OFFCHAN_TX_WAIT_TIME, + WIFI_OFFCHAN_TX_REQ); eloop_cancel_timeout(esp_dpp_auth_conf_wait_timeout, NULL, NULL); eloop_register_timeout(ESP_DPP_AUTH_TIMEOUT_SECS, 0, esp_dpp_auth_conf_wait_timeout, NULL, NULL); @@ -201,7 +215,8 @@ static void gas_query_req_tx(struct dpp_authentication *auth) MAC2STR(auth->peer_mac_addr), auth->curr_chan); esp_dpp_send_action_frame(auth->peer_mac_addr, wpabuf_head(buf), wpabuf_len(buf), - auth->curr_chan, OFFCHAN_TX_WAIT_TIME); + auth->curr_chan, OFFCHAN_TX_WAIT_TIME, + WIFI_OFFCHAN_TX_REQ); } static int esp_dpp_handle_config_obj(struct dpp_authentication *auth, @@ -214,13 +229,24 @@ static int esp_dpp_handle_config_obj(struct dpp_authentication *auth, os_memcpy(wifi_cfg->sta.ssid, conf->ssid, conf->ssid_len); } - if (dpp_akm_legacy(conf->akm)) { + if (dpp_akm_legacy(conf->akm) || dpp_akm_ver2(conf->akm)) { if (conf->passphrase[0]) os_memcpy(wifi_cfg->sta.password, conf->passphrase, sizeof(wifi_cfg->sta.password)); - if (conf->akm == DPP_AKM_PSK_SAE) { - wifi_cfg->sta.pmf_cfg.required = true; - } + } + + if (dpp_akm_sae(conf->akm) || dpp_akm_dpp(conf->akm)) { + wifi_cfg->sta.pmf_cfg.capable = true; + wifi_cfg->sta.pmf_cfg.required = true; + } + + if (dpp_akm_dpp(conf->akm)) { + wifi_cfg->sta.threshold.authmode = WIFI_AUTH_DPP; + esp_wifi_sta_notify_dpp_config_set_internal(true); + } else if (dpp_akm_sae(conf->akm)) { + wifi_cfg->sta.threshold.authmode = WIFI_AUTH_WPA3_PSK; + } else if (dpp_akm_psk(conf->akm)) { + wifi_cfg->sta.threshold.authmode = WIFI_AUTH_WPA2_PSK; } if (conf->connector) { @@ -380,10 +406,12 @@ static esp_err_t esp_dpp_rx_peer_disc_resp(struct action_rx_param *rx_param) os_get_reltime(&rnow); entry->expiration = rnow.sec + seconds; entry->reauth_time = rnow.sec + seconds; - entry->network_ctx = auth; + entry->network_ctx = sm->network_ctx; pmksa_cache_add_entry(sm->pmksa, entry); + entry = NULL; + wpa_printf(MSG_INFO, "peer=" MACSTR " status=%u", MAC2STR(rx_param->sa), status[0]); break; } @@ -396,7 +424,10 @@ static esp_err_t esp_dpp_rx_peer_disc_resp(struct action_rx_param *rx_param) wpa_printf(MSG_DEBUG, "DPP: Try connection after successful network introduction"); - dpp_connect(rx_param->sa, true); + if (dpp_connect(rx_param->sa, true) != 0) { + wpa_printf(MSG_ERROR, "DPP: Failed to connect after network introduction"); + goto fail; + } return ESP_OK; fail: os_memset(&intro, 0, sizeof(intro)); @@ -443,7 +474,7 @@ static void gas_query_resp_rx(struct action_rx_param *rx_param) uint8_t *pos = rx_param->action_frm->u.public_action.v.pa_gas_resp.data; uint8_t *resp = &pos[10]; /* first byte of DPP attributes */ size_t vendor_len = rx_param->vendor_data_len; - int i, res; + int res; /* Basic structural checks on the Advertisement Protocol payload */ if (!(pos[1] == WLAN_EID_VENDOR_SPECIFIC && pos[2] == 5 && @@ -461,8 +492,8 @@ static void gas_query_resp_rx(struct action_rx_param *rx_param) goto fail; } - for (i = 0; i < auth->num_conf_obj; i++) { - res = esp_dpp_handle_config_obj(auth, &auth->conf_obj[i]); + if (auth->num_conf_obj > 0) { + res = esp_dpp_handle_config_obj(auth, &auth->conf_obj[0]); if (res < 0) { wpa_printf(MSG_INFO, "DPP: Configuration parsing failed"); goto fail; @@ -979,12 +1010,16 @@ esp_err_t esp_dpp_start_net_intro_protocol(uint8_t *bssid) { struct dpp_authentication *auth = s_dpp_ctx.dpp_auth; struct wpabuf *buf; + if (!auth) { + wpa_printf(MSG_ERROR, "DPP: No authentication context for network introduction"); + return ESP_ERR_INVALID_ARG; + } for (int i = 0; i < auth->num_conf_obj; i++) { os_memcpy(auth->peer_mac_addr, bssid, ETH_ALEN); buf = dpp_build_peer_disc_req(auth, &auth->conf_obj[i]); if (buf) { - if (esp_dpp_send_action_frame(bssid, wpabuf_head(buf), wpabuf_len(buf), auth->curr_chan, OFFCHAN_TX_WAIT_TIME) != ESP_OK) { + if (esp_dpp_send_action_frame(bssid, wpabuf_head(buf), wpabuf_len(buf), auth->curr_chan, OFFCHAN_TX_WAIT_TIME, WIFI_OFFCHAN_TX_CONNECTING_REQ) != ESP_OK) { wpabuf_free(buf); return ESP_FAIL; } diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_dpp_i.h b/components/wpa_supplicant/esp_supplicant/src/esp_dpp_i.h index d3dbc95c371..dfcd3d09288 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_dpp_i.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_dpp_i.h @@ -53,6 +53,7 @@ struct esp_dpp_context_t { struct dpp_global *dpp_global; wifi_config_t wifi_cfg; int id; + bool peer_disc_resp_received; }; int esp_supp_rx_action(uint8_t *hdr, uint8_t *payload, size_t len, uint8_t channel); diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h b/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h index 9c2c6d8a109..6c703dc8cd2 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h @@ -296,6 +296,7 @@ uint8_t esp_wifi_sta_get_config_sae_pk_internal(void); void esp_wifi_sta_disable_sae_pk_internal(void); void esp_wifi_sta_disable_wpa2_authmode_internal(void); void esp_wifi_sta_disable_owe_trans_internal(void); +void esp_wifi_sta_notify_dpp_config_set_internal(bool configured); uint8_t esp_wifi_ap_get_max_sta_conn(void); uint8_t esp_wifi_get_config_sae_pwe_h2e_internal(uint8_t ifx); bool esp_wifi_ap_notify_node_sae_auth_done(uint8_t *mac); diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c b/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c index ce668b2c023..88d3ddb3a21 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c @@ -262,7 +262,7 @@ int wpa_sta_connect(uint8_t *bssid) #ifdef CONFIG_DPP struct wpa_sm *sm = &gWpaSm; - if (sm->key_mgmt == WPA_KEY_MGMT_DPP) { + if (wpa_key_mgmt_dpp(sm->key_mgmt)) { ret = dpp_connect(bssid, false); } else #endif @@ -522,10 +522,18 @@ int esp_supplicant_init(void) esp_wifi_register_owe_cb(wpa_cb); #endif /* CONFIG_OWE_STA */ - eloop_init(); + if (eloop_init() != 0) { + wpa_printf(MSG_ERROR, "Failed to initialize eloop"); + os_free(wpa_cb); + wpa_cb = NULL; + return ESP_FAIL; + } + ret = esp_supplicant_common_init(wpa_cb); if (ret != 0) { + os_free(wpa_cb); + wpa_cb = NULL; return ret; } @@ -543,6 +551,7 @@ int esp_supplicant_deinit(void) esp_supplicant_common_deinit(); esp_supplicant_unset_all_appie(); eloop_destroy(); + /* wpa_cb is freed by esp_wifi_unregister_wpa_cb_internal() */ wpa_cb = NULL; #if CONFIG_ESP_WIFI_WAPI_PSK esp_wifi_internal_wapi_deinit(); diff --git a/components/wpa_supplicant/port/include/os.h b/components/wpa_supplicant/port/include/os.h index 3ed465b3aeb..b01622d10f0 100644 --- a/components/wpa_supplicant/port/include/os.h +++ b/components/wpa_supplicant/port/include/os.h @@ -352,7 +352,7 @@ extern const wifi_osi_funcs_t *wifi_funcs; #define os_mutex_lock(a) wifi_funcs->_mutex_lock((a)) #define os_mutex_unlock(a) wifi_funcs->_mutex_unlock((a)) #define os_recursive_mutex_create() wifi_funcs->_recursive_mutex_create() -#define os_mutex_create() wifi_funcs->_mutex_create(); +#define os_mutex_create() wifi_funcs->_mutex_create() #define os_mutex_delete(a) wifi_funcs->_mutex_delete(a) #define os_queue_create(a, b) wifi_funcs->_queue_create((a), (b)) diff --git a/components/wpa_supplicant/src/common/defs.h b/components/wpa_supplicant/src/common/defs.h index 543f1bbd6b5..0427d980cd7 100644 --- a/components/wpa_supplicant/src/common/defs.h +++ b/components/wpa_supplicant/src/common/defs.h @@ -124,7 +124,7 @@ static inline int wpa_key_mgmt_owe(int akm) static inline int wpa_key_mgmt_dpp(int akm) { - return akm == WPA_KEY_MGMT_DPP; + return !!(akm & WPA_KEY_MGMT_DPP); } static inline int wpa_key_mgmt_wpa(int akm) diff --git a/components/wpa_supplicant/src/common/dpp.c b/components/wpa_supplicant/src/common/dpp.c index 64665b7a95b..0ac0d044b33 100644 --- a/components/wpa_supplicant/src/common/dpp.c +++ b/components/wpa_supplicant/src/common/dpp.c @@ -1117,7 +1117,7 @@ struct dpp_authentication * dpp_auth_init(void *msg_ctx, { struct dpp_authentication *auth; size_t nonce_len; - size_t secret_len; + size_t secret_len = 0; struct wpabuf *pi = NULL; const u8 *r_pubkey_hash, *i_pubkey_hash; #ifdef CONFIG_TESTING_OPTIONS @@ -1475,7 +1475,7 @@ static void dpp_auth_success(struct dpp_authentication *auth) static int dpp_auth_build_resp_ok(struct dpp_authentication *auth) { size_t nonce_len; - size_t secret_len; + size_t secret_len = 0; struct wpabuf *msg, *pr = NULL; u8 r_auth[4 + DPP_MAX_HASH_LEN]; u8 wrapped_r_auth[4 + DPP_MAX_HASH_LEN + AES_BLOCK_SIZE], *w_r_auth; @@ -1540,6 +1540,7 @@ static int dpp_auth_build_resp_ok(struct dpp_authentication *auth) if (dpp_ecdh(auth->own_protocol_key, auth->peer_protocol_key, auth->Nx, &secret_len) < 0) goto fail; + auth->secret_len = secret_len; wpa_hexdump_key(MSG_DEBUG, "DPP: ECDH shared secret (N.x)", auth->Nx, auth->secret_len); @@ -1727,7 +1728,7 @@ dpp_auth_req_rx(void *msg_ctx, u8 dpp_allowed_roles, int qr_mutual, size_t attr_len) { struct crypto_ec_key *pi = NULL; - size_t secret_len; + size_t secret_len = 0; const u8 *addr[2]; size_t len[2]; u8 *unwrapped = NULL; @@ -1737,6 +1738,8 @@ dpp_auth_req_rx(void *msg_ctx, u8 dpp_allowed_roles, int qr_mutual, const u8 *i_nonce; const u8 *i_capab; const u8 *i_bootstrap; + const u8 *channel; + u16 channel_len; u16 wrapped_data_len; u16 i_proto_len; u16 i_nonce_len; @@ -1781,37 +1784,19 @@ dpp_auth_req_rx(void *msg_ctx, u8 dpp_allowed_roles, int qr_mutual, auth->peer_version = 1; /* default to the first version */ -#if 0 channel = dpp_get_attr(attr_start, attr_len, DPP_ATTR_CHANNEL, &channel_len); if (channel) { - //int neg_freq; - if (channel_len < 2) { dpp_auth_fail(auth, "Too short Channel attribute"); goto fail; } - neg_freq = ieee80211_chan_to_freq(NULL, channel[0], channel[1]); wpa_printf(MSG_DEBUG, - "DPP: Initiator requested different channel for negotiation: op_class=%u channel=%u --> freq=%d", - channel[0], channel[1], neg_freq); - if (neg_freq < 0) { - dpp_auth_fail(auth, - "Unsupported Channel attribute value"); - goto fail; - } - - if (auth->curr_freq != (unsigned int) neg_freq) { - wpa_printf(MSG_DEBUG, - "DPP: Changing negotiation channel from %u MHz to %u MHz", - freq, neg_freq); - auth->curr_freq = neg_freq; - } - /* rename it to chan */ - auth->curr_chan = *channel; + "DPP: Initiator requested different channel for negotiation: op_class=%u channel=%u", + channel[0], channel[1]); + auth->curr_chan = channel[1]; } -#endif i_proto = dpp_get_attr(attr_start, attr_len, DPP_ATTR_I_PROTOCOL_KEY, &i_proto_len); @@ -2297,7 +2282,7 @@ dpp_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr, const u8 *attr_start, size_t attr_len) { struct crypto_ec_key *pr; - size_t secret_len; + size_t secret_len = 0; const u8 *addr[2]; size_t len[2]; u8 *unwrapped = NULL, *unwrapped2 = NULL; @@ -2432,6 +2417,7 @@ dpp_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr, dpp_auth_fail(auth, "Failed to derive ECDH shared secret"); goto fail; } + auth->secret_len = secret_len; crypto_ec_key_deinit(auth->peer_protocol_key); auth->peer_protocol_key = pr; pr = NULL; @@ -3432,7 +3418,7 @@ skip_groups: if (!hash) { goto fail; } - if (dpp_get_config_obj_hash(signed1, signed1_len, signed2, signed1_len, hash, curve->hash_len) < 0) + if (dpp_get_config_obj_hash(signed1, signed1_len, signed2, signed2_len, hash, curve->hash_len) < 0) goto fail; r = crypto_bignum_init(); @@ -4861,7 +4847,7 @@ dpp_peer_intro(struct dpp_introduction *intro, const char *own_connector, struct wpabuf *own_key_pub = NULL; const struct dpp_curve_params *curve, *own_curve; struct dpp_signed_connector_info info; - size_t Nx_len; + size_t Nx_len = 0; u8 Nx[DPP_MAX_SHARED_SECRET_LEN]; os_memset(intro, 0, sizeof(*intro)); diff --git a/components/wpa_supplicant/src/common/wpa_common.c b/components/wpa_supplicant/src/common/wpa_common.c index 6f9485760ba..17d07157de5 100644 --- a/components/wpa_supplicant/src/common/wpa_common.c +++ b/components/wpa_supplicant/src/common/wpa_common.c @@ -864,7 +864,7 @@ int wpa_pmk_r1_to_ptk(const u8 *pmk_r1, const u8 *snonce, const u8 *anonce, int wpa_use_akm_defined(int akmp){ return akmp == WPA_KEY_MGMT_OSEN || akmp == WPA_KEY_MGMT_OWE || - akmp == WPA_KEY_MGMT_DPP || + wpa_key_mgmt_dpp(akmp) || wpa_key_mgmt_sae(akmp) || wpa_key_mgmt_suite_b(akmp); } @@ -882,7 +882,7 @@ int wpa_use_aes_key_wrap(int akmp) { return akmp == WPA_KEY_MGMT_OSEN || akmp == WPA_KEY_MGMT_OWE || - akmp == WPA_KEY_MGMT_DPP || + wpa_key_mgmt_dpp(akmp) || wpa_key_mgmt_ft(akmp) || wpa_key_mgmt_sha256(akmp) || wpa_key_mgmt_sae(akmp) || diff --git a/components/wpa_supplicant/src/rsn_supp/wpa.c b/components/wpa_supplicant/src/rsn_supp/wpa.c index d6ccf3c5a73..b602750682e 100644 --- a/components/wpa_supplicant/src/rsn_supp/wpa.c +++ b/components/wpa_supplicant/src/rsn_supp/wpa.c @@ -857,7 +857,7 @@ void wpa_supplicant_key_neg_complete(struct wpa_sm *sm, sm, addr, MLME_SETPROTECTION_PROTECT_TYPE_RX_TX, MLME_SETPROTECTION_KEY_TYPE_PAIRWISE); - if (wpa_key_mgmt_wpa_psk(sm->key_mgmt) || sm->key_mgmt == WPA_KEY_MGMT_OWE || sm->key_mgmt == WPA_KEY_MGMT_DPP) + if (wpa_key_mgmt_wpa_psk(sm->key_mgmt) || sm->key_mgmt == WPA_KEY_MGMT_OWE || wpa_key_mgmt_dpp(sm->key_mgmt)) eapol_sm_notify_eap_success(TRUE); /* * Start preauthentication after a short wait to avoid a @@ -2349,6 +2349,9 @@ int wpa_set_bss(char *macddr, char * bssid, u8 pairwise_cipher, u8 group_cipher, (os_memcmp(sm->ssid, ssid, ssid_len) != 0)) { use_pmk_cache = false; } + if (wpa_key_mgmt_dpp(sm->key_mgmt)) { + use_pmk_cache = true; + } sm->pairwise_cipher = BIT(pairwise_cipher); sm->group_cipher = BIT(group_cipher); sm->renew_snonce = 1; @@ -2488,13 +2491,13 @@ wpa_set_passphrase(char * passphrase, u8 *ssid, size_t ssid_len) if (sm->key_mgmt == WPA_KEY_MGMT_SAE || sm->key_mgmt == WPA_KEY_MGMT_OWE || sm->key_mgmt == WPA_KEY_MGMT_SAE_EXT_KEY || - sm->key_mgmt == WPA_KEY_MGMT_DPP) + wpa_key_mgmt_dpp(sm->key_mgmt)) return; /* This is really SLOW, so just re cacl while reset param */ if (esp_wifi_sta_get_reset_nvs_pmk_internal() != 0) { // check it's psk - if (strlen((char *)esp_wifi_sta_get_prof_password_internal()) == 64) { + if (os_strlen((char *)esp_wifi_sta_get_prof_password_internal()) == 64) { if (hexstr2bin((char *)esp_wifi_sta_get_prof_password_internal(), esp_wifi_sta_get_ap_info_prof_pmk_internal(), PMK_LEN) != 0) return;