From 1f9a988f1f1d799d7959cfc535006b31142ab807 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 27 Aug 2022 00:50:05 +0300 Subject: [PATCH] DPP3: Do not initiate PKEX for PB if no configuration is available Reorder PKEX initiation function to send out the PKEX Exchange Request frame at the end after all possible error cases have been checked. This prevents Enrollee from seeing a PKEX frame when the session is about to fail. Signed-off-by: Jouni Malinen --- src/ap/dpp_hostapd.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ap/dpp_hostapd.c b/src/ap/dpp_hostapd.c index 232b5fbbc..32ddb3b21 100644 --- a/src/ap/dpp_hostapd.c +++ b/src/ap/dpp_hostapd.c @@ -2439,13 +2439,6 @@ static void hostapd_dpp_pb_pkex_init(struct hostapd_data *hapd, hapd->dpp_pkex = pkex; msg = hapd->dpp_pkex->exchange_req; - wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR - " freq=%u type=%d", MAC2STR(src), freq, - DPP_PA_PKEX_EXCHANGE_REQ); - hostapd_drv_send_action(hapd, pkex->freq, 0, src, - wpabuf_head(msg), wpabuf_len(msg)); - pkex->exch_req_wait_time = 2000; - pkex->exch_req_tries = 1; if (ifaces->dpp_pb_cmd) { /* Use the externally provided configuration */ @@ -2458,7 +2451,7 @@ static void hostapd_dpp_pb_pkex_init(struct hostapd_data *hapd, } os_snprintf(hapd->dpp_pkex_auth_cmd, len, " own=%d %s", hapd->dpp_pkex_bi->id, ifaces->dpp_pb_cmd); - return; + goto send_frame; } /* Build config based on the current AP configuration */ @@ -2545,6 +2538,15 @@ static void hostapd_dpp_pb_pkex_init(struct hostapd_data *hapd, hostapd_dpp_push_button_stop(hapd); return; } + +send_frame: + wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR + " freq=%u type=%d", MAC2STR(src), freq, + DPP_PA_PKEX_EXCHANGE_REQ); + hostapd_drv_send_action(hapd, pkex->freq, 0, src, + wpabuf_head(msg), wpabuf_len(msg)); + pkex->exch_req_wait_time = 2000; + pkex->exch_req_tries = 1; }