From 42acf1292dd52e12e059c4f82070b2a7e4d7fc09 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 1 May 2020 17:06:59 +0300 Subject: [PATCH] DPP2: Add Protocol Version attribute to network introduction messages This can be used to determine whether to try to negotiate PFS (only available with version 2 or higher). Signed-off-by: Jouni Malinen --- src/ap/dpp_hostapd.c | 15 +++++++++++++-- wpa_supplicant/dpp_supplicant.c | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/ap/dpp_hostapd.c b/src/ap/dpp_hostapd.c index c86f01ba7..77518cbdf 100644 --- a/src/ap/dpp_hostapd.c +++ b/src/ap/dpp_hostapd.c @@ -1206,9 +1206,13 @@ static void hostapd_dpp_send_peer_disc_resp(struct hostapd_data *hapd, enum dpp_status_error status) { struct wpabuf *msg; + size_t len; - msg = dpp_alloc_msg(DPP_PA_PEER_DISCOVERY_RESP, - 5 + 5 + 4 + os_strlen(hapd->conf->dpp_connector)); + len = 5 + 5 + 4 + os_strlen(hapd->conf->dpp_connector); +#ifdef CONFIG_DPP2 + len += 5; +#endif /* CONFIG_DPP2 */ + msg = dpp_alloc_msg(DPP_PA_PEER_DISCOVERY_RESP, len); if (!msg) return; @@ -1281,6 +1285,13 @@ skip_status: skip_connector: #endif /* CONFIG_TESTING_OPTIONS */ +#ifdef CONFIG_DPP2 + /* Protocol Version */ + wpabuf_put_le16(msg, DPP_ATTR_PROTOCOL_VERSION); + wpabuf_put_le16(msg, 1); + wpabuf_put_u8(msg, 2); +#endif /* CONFIG_DPP2 */ + wpa_printf(MSG_DEBUG, "DPP: Send Peer Discovery Response to " MACSTR " status=%d", MAC2STR(src), status); wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_TX "dst=" MACSTR diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c index 291b96b75..b8fd95bee 100644 --- a/wpa_supplicant/dpp_supplicant.c +++ b/wpa_supplicant/dpp_supplicant.c @@ -2474,6 +2474,7 @@ int wpas_dpp_check_connect(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, unsigned int wait_time; const u8 *rsn; struct wpa_ie_data ied; + size_t len; if (!(ssid->key_mgmt & WPA_KEY_MGMT_DPP) || !bss) return 0; /* Not using DPP AKM - continue */ @@ -2507,8 +2508,11 @@ int wpas_dpp_check_connect(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, "DPP: Starting network introduction protocol to derive PMKSA for " MACSTR, MAC2STR(bss->bssid)); - msg = dpp_alloc_msg(DPP_PA_PEER_DISCOVERY_REQ, - 5 + 4 + os_strlen(ssid->dpp_connector)); + len = 5 + 4 + os_strlen(ssid->dpp_connector); +#ifdef CONFIG_DPP2 + len += 5; +#endif /* CONFIG_DPP2 */ + msg = dpp_alloc_msg(DPP_PA_PEER_DISCOVERY_REQ, len); if (!msg) return -1; @@ -2563,6 +2567,13 @@ skip_trans_id: skip_connector: #endif /* CONFIG_TESTING_OPTIONS */ +#ifdef CONFIG_DPP2 + /* Protocol Version */ + wpabuf_put_le16(msg, DPP_ATTR_PROTOCOL_VERSION); + wpabuf_put_le16(msg, 1); + wpabuf_put_u8(msg, 2); +#endif /* CONFIG_DPP2 */ + /* TODO: Timeout on AP response */ wait_time = wpa_s->max_remain_on_chan; if (wait_time > 2000)