From patchwork Mon Feb 24 09:14:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 1242931 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=Rhkn2kK3; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Qxs14rdqz9sPk for ; Mon, 24 Feb 2020 20:41:09 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=/GQgDz/6dYBHtgvgncvRxuJwfznxvToABx7Q4tY2rKw=; b=Rhkn2kK3JLAYvBOILepHKULlxg tXARrMPenXf26YVMHUiaJdBPISFA+Tw8Nn4ngCjC1okl9D50D5rZUugP5K2kKbmmCXSlmgzGLeNFv WKDWG+juQkC21ib0vqIx8P7UM0aJrnxpsc3MqAplBGJn6Lp7Jy3aLjfdm4OWUKhmP42edsQvPjZhK 2yvNSCtdfeWmPkDj+HoqSWnne5inZvXe1RYxZ6j92mQ6w2O52JhrgrQbJ0SlaHDwbajQtCjnKfVA9 qOgluNWU3TdPRNEgDDwogfC4CToq3r5ETuHfwXLBDzWq5JlxBxQ+MT9bf7yca4fHWdoXxo/A7of9T v710msZQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6AEX-0002H0-T0; Mon, 24 Feb 2020 09:41:01 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j69p9-0006C4-GY for hostap@lists.infradead.org; Mon, 24 Feb 2020 09:14:49 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2020 01:14:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,479,1574150400"; d="scan'208";a="225914104" Received: from jed01681.jer.intel.com ([10.12.190.127]) by orsmga007.jf.intel.com with ESMTP; 24 Feb 2020 01:14:42 -0800 From: Ilan Peer To: hostap@lists.infradead.org Subject: [PATCH 01/12] driver_nl80211: Register for SAE AUTH frames more strictly Date: Mon, 24 Feb 2020 11:14:26 +0200 Message-Id: <20200224091437.15212-2-ilan.peer@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200224091437.15212-1-ilan.peer@intel.com> References: <20200224091437.15212-1-ilan.peer@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200224_011447_903382_DA5AF799 X-CRM114-Status: GOOD ( 11.62 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [192.55.52.93 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrei Otcheretianski MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Andrei Otcheretianski If the driver requires external SAE authentication, it would result in registration for all authentication frames, so even non SAE auth frames might be forwarded to user space instead of being handled internally. Fix this by using more strict match pattern, limiting the registration to the SAE authentication algorithm only. Signed-off-by: Andrei Otcheretianski --- src/drivers/driver_nl80211.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 659f6584d4..438fc16252 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -2182,6 +2182,7 @@ static int nl80211_init_connect_handle(struct i802_bss *bss) static int nl80211_mgmt_subscribe_non_ap(struct i802_bss *bss) { struct wpa_driver_nl80211_data *drv = bss->drv; + u16 type = (WLAN_FC_TYPE_MGMT << 2) | (WLAN_FC_STYPE_AUTH << 4); int ret = 0; if (nl80211_alloc_mgmt_handle(bss)) @@ -2189,14 +2190,14 @@ static int nl80211_mgmt_subscribe_non_ap(struct i802_bss *bss) wpa_printf(MSG_DEBUG, "nl80211: Subscribe to mgmt frames with non-AP " "handle %p", bss->nl_mgmt); - if (drv->nlmode == NL80211_IFTYPE_ADHOC || - ((drv->capa.flags & WPA_DRIVER_FLAGS_SAE) && - !(drv->capa.flags & WPA_DRIVER_FLAGS_SME))) { - u16 type = (WLAN_FC_TYPE_MGMT << 2) | (WLAN_FC_STYPE_AUTH << 4); - + if (drv->nlmode == NL80211_IFTYPE_ADHOC) /* register for any AUTH message */ nl80211_register_frame(bss, bss->nl_mgmt, type, NULL, 0); - } + else if ((drv->capa.flags & WPA_DRIVER_FLAGS_SAE) && + !(drv->capa.flags & WPA_DRIVER_FLAGS_SME)) + /* register for SAE AUTH frames */ + nl80211_register_frame(bss, bss->nl_mgmt, type, + (u8 *) "\x03\x00", 2); #ifdef CONFIG_INTERWORKING /* QoS Map Configure */ From patchwork Mon Feb 24 09:14:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 1242929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=Ggf0Zir9; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Qxrl0FQHz9sPk for ; Mon, 24 Feb 2020 20:40:55 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=GWnaLsOBPIjoD88QzRPF6+MhNKU2xo+tLLfi60jr3Xo=; b=Ggf0Zir9qwrM7Ts3EW7y5tQfC1 CwsqInrZWD5X7W0HKK8gfwIF7EXhkWFKad1JJH3dcRJMtVkD4+ZY6Oya9gicl8HY9hfAatHO/P0Xp 1f2HXFby/CMPGJe3xWjIGuMulTmwfo2C6m4+m5Eg42n/MFkUfW725hmKqwHpfGZDD/gPCVDW8GbYp dhiQioEURCx1BQn1M7mw4HS51GQCBLdwdmzYag+YMt/Fz6vgFvvCCyz61suJGZBQGoW6DYPnxMDN2 dMMuE8IuvHqApAlZMduYL3IhdjHkdJYwVPh4UiRct9lBeHsYnnAD37/sAYsg3orPWX92rWGtxpi4L 1BKAGo0g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6AEL-00025c-EH; Mon, 24 Feb 2020 09:40:49 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j69p9-0006At-Bm for hostap@lists.infradead.org; Mon, 24 Feb 2020 09:14:49 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2020 01:14:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,479,1574150400"; d="scan'208";a="225914111" Received: from jed01681.jer.intel.com ([10.12.190.127]) by orsmga007.jf.intel.com with ESMTP; 24 Feb 2020 01:14:43 -0800 From: Ilan Peer To: hostap@lists.infradead.org Subject: [PATCH 02/12] driver: Extend send_mlme() with wait option Date: Mon, 24 Feb 2020 11:14:27 +0200 Message-Id: <20200224091437.15212-3-ilan.peer@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200224091437.15212-1-ilan.peer@intel.com> References: <20200224091437.15212-1-ilan.peer@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200224_011447_452487_387D9419 X-CRM114-Status: GOOD ( 14.07 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [192.55.52.93 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ilan Peer MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org PASN authentication can be performed while a station interface is connected to an AP. To allow sending PASN frames while connected, extend the send_mlme() driver callback to also allow a wait option. Update the relevant drivers and wpa_supplicant accordingly. Hostapd calls for send_mlme() are left unchanged, since the wait option is not required there. Signed-off-by: Ilan Peer --- src/ap/ap_drv_ops.c | 2 +- src/drivers/driver.h | 4 +++- src/drivers/driver_hostap.c | 6 +++--- src/drivers/driver_nl80211.c | 4 ++-- wpa_supplicant/driver_i.h | 4 ++-- wpa_supplicant/ibss_rsn.c | 2 +- wpa_supplicant/p2p_supplicant.c | 2 +- wpa_supplicant/sme.c | 4 ++-- 8 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c index c217d9b245..0f5e829ffb 100644 --- a/src/ap/ap_drv_ops.c +++ b/src/ap/ap_drv_ops.c @@ -714,7 +714,7 @@ int hostapd_drv_send_mlme(struct hostapd_data *hapd, if (!hapd->driver || !hapd->driver->send_mlme || !hapd->drv_priv) return 0; return hapd->driver->send_mlme(hapd->drv_priv, msg, len, noack, 0, - csa_offs, csa_offs_len, no_encrypt); + csa_offs, csa_offs_len, no_encrypt, 0); } diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 48dd3fe525..fcd50ca12a 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -2713,11 +2713,13 @@ struct wpa_driver_ops { * @csa_offs_len: Number of elements in csa_offs * @no_encrypt: Do not encrypt frame even if appropriate key exists * (used only for testing purposes) + * @wait: Time to wait off-channel for a response (in ms), or zero * Returns: 0 on success, -1 on failure */ int (*send_mlme)(void *priv, const u8 *data, size_t data_len, int noack, unsigned int freq, const u16 *csa_offs, - size_t csa_offs_len, int no_encrypt); + size_t csa_offs_len, int no_encrypt, + unsigned int wait); /** * update_ft_ies - Update FT (IEEE 802.11r) IEs diff --git a/src/drivers/driver_hostap.c b/src/drivers/driver_hostap.c index cfc52c7f3a..f827d21913 100644 --- a/src/drivers/driver_hostap.c +++ b/src/drivers/driver_hostap.c @@ -264,7 +264,7 @@ static int hostap_init_sockets(struct hostap_driver_data *drv, u8 *own_addr) static int hostap_send_mlme(void *priv, const u8 *msg, size_t len, int noack, unsigned int freq, const u16 *csa_offs, size_t csa_offs_len, - int no_encrypt) + int no_encrypt, unsigned int wait_time_ms) { struct hostap_driver_data *drv = priv; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) msg; @@ -313,7 +313,7 @@ static int hostap_send_eapol(void *priv, const u8 *addr, const u8 *data, pos += 2; memcpy(pos, data, data_len); - res = hostap_send_mlme(drv, (u8 *) hdr, len, 0, 0, NULL, 0, 0); + res = hostap_send_mlme(drv, (u8 *) hdr, len, 0, 0, NULL, 0, 0, 0); if (res < 0) { wpa_printf(MSG_ERROR, "hostap_send_eapol - packet len: %lu - " "failed: %d (%s)", @@ -1173,7 +1173,7 @@ static void wpa_driver_hostap_poll_client(void *priv, const u8 *own_addr, os_memcpy(hdr.IEEE80211_BSSID_FROMDS, own_addr, ETH_ALEN); os_memcpy(hdr.IEEE80211_SA_FROMDS, own_addr, ETH_ALEN); - hostap_send_mlme(priv, (u8 *) &hdr, sizeof(hdr), 0, 0, NULL, 0, 0); + hostap_send_mlme(priv, (u8 *)&hdr, sizeof(hdr), 0, 0, NULL, 0, 0, 0); } diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 438fc16252..58b1265fe6 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -8843,11 +8843,11 @@ static int driver_nl80211_send_mlme(void *priv, const u8 *data, size_t data_len, int noack, unsigned int freq, const u16 *csa_offs, size_t csa_offs_len, - int no_encrypt) + int no_encrypt, unsigned int wait) { struct i802_bss *bss = priv; return wpa_driver_nl80211_send_mlme(bss, data, data_len, noack, - freq, 0, 0, 0, csa_offs, + freq, 0, 0, wait, csa_offs, csa_offs_len, no_encrypt); } diff --git a/wpa_supplicant/driver_i.h b/wpa_supplicant/driver_i.h index 45b62bdea2..d3fb587079 100644 --- a/wpa_supplicant/driver_i.h +++ b/wpa_supplicant/driver_i.h @@ -312,12 +312,12 @@ static inline int wpa_drv_set_country(struct wpa_supplicant *wpa_s, static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s, const u8 *data, size_t data_len, int noack, - unsigned int freq) + unsigned int freq, unsigned int wait) { if (wpa_s->driver->send_mlme) return wpa_s->driver->send_mlme(wpa_s->drv_priv, data, data_len, noack, - freq, NULL, 0, 0); + freq, NULL, 0, 0, wait); return -1; } diff --git a/wpa_supplicant/ibss_rsn.c b/wpa_supplicant/ibss_rsn.c index ea909a91c8..02e63904c5 100644 --- a/wpa_supplicant/ibss_rsn.c +++ b/wpa_supplicant/ibss_rsn.c @@ -520,7 +520,7 @@ static int ibss_rsn_send_auth(struct ibss_rsn *ibss_rsn, const u8 *da, int seq) wpa_printf(MSG_DEBUG, "RSN: IBSS TX Auth frame (SEQ %d) to " MACSTR, seq, MAC2STR(da)); - return wpa_drv_send_mlme(wpa_s, (u8 *) &auth, auth_length, 0, 0); + return wpa_drv_send_mlme(wpa_s, (u8 *) &auth, auth_length, 0, 0, 0); } diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 41d50f3979..e86c082b36 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -2691,7 +2691,7 @@ static int wpas_send_probe_resp(void *ctx, const struct wpabuf *buf, { struct wpa_supplicant *wpa_s = ctx; return wpa_drv_send_mlme(wpa_s, wpabuf_head(buf), wpabuf_len(buf), 1, - freq); + freq, 0); } diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index 81151a7fb7..6bec3ad930 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -1015,7 +1015,7 @@ static int sme_external_auth_send_sae_commit(struct wpa_supplicant *wpa_s, bssid, 1, wpa_s->sme.seq_num, use_pt ? WLAN_STATUS_SAE_HASH_TO_ELEMENT : WLAN_STATUS_SUCCESS); - wpa_drv_send_mlme(wpa_s, wpabuf_head(buf), wpabuf_len(buf), 1, 0); + wpa_drv_send_mlme(wpa_s, wpabuf_head(buf), wpabuf_len(buf), 1, 0, 0); wpabuf_free(resp); wpabuf_free(buf); @@ -1085,7 +1085,7 @@ static void sme_external_auth_send_sae_confirm(struct wpa_supplicant *wpa_s, sme_external_auth_build_buf(buf, resp, wpa_s->own_addr, da, 2, wpa_s->sme.seq_num, WLAN_STATUS_SUCCESS); - wpa_drv_send_mlme(wpa_s, wpabuf_head(buf), wpabuf_len(buf), 1, 0); + wpa_drv_send_mlme(wpa_s, wpabuf_head(buf), wpabuf_len(buf), 1, 0, 0); wpabuf_free(resp); wpabuf_free(buf); } From patchwork Mon Feb 24 09:14:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 1242928 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=kK9BKs2M; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48QxrW60d2z9sPk for ; Mon, 24 Feb 2020 20:40:43 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Qah3RAzvj251sZd0T6mAX3DV+SSlWT28SDUQP6bdjPo=; b=kK9BKs2M71umM53a1oWZ60sAmJ i7mLo0NyU0iKnu+c3ggFm7FvlPKbnCkWvTSQg9W4xUrv/dKNycA7a1iUb14Pmi1c97IE/LbGuqIpD gMmfOAKXKC2rd4zGyMTVX7AK8N7PtihgsVlz1Ic5goL7JNXcRtjZOFgbePutBzs0fPGTNTXOQLCRn D17ihVTWOa0ArbBnyFNLUyT1lXfoQZXcpvMpPLhAca4RlMm8WL0kyfyENQtx/ERPaBWJCrj8LEdtR i4thloe2mUAbjb8GxWt0z6wY+Pc3Y//XtQuF1ndpFIOxna34XiHIEShgcWrF0KyPxDkOBswy9/sUm y3b9Jf9w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6AE8-0001ur-Bm; Mon, 24 Feb 2020 09:40:36 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j69pA-0006Cf-2i for hostap@lists.infradead.org; Mon, 24 Feb 2020 09:14:50 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2020 01:14:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,479,1574150400"; d="scan'208";a="225914122" Received: from jed01681.jer.intel.com ([10.12.190.127]) by orsmga007.jf.intel.com with ESMTP; 24 Feb 2020 01:14:45 -0800 From: Ilan Peer To: hostap@lists.infradead.org Subject: [PATCH 03/12] nl80211: Allow off-channel of authentication frames in send_mlme() Date: Mon, 24 Feb 2020 11:14:28 +0200 Message-Id: <20200224091437.15212-4-ilan.peer@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200224091437.15212-1-ilan.peer@intel.com> References: <20200224091437.15212-1-ilan.peer@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200224_011448_177710_8EE9A519 X-CRM114-Status: UNSURE ( 9.46 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [192.55.52.93 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ilan Peer MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org As part of the support needed for PASN. Signed-off-by: Ilan Peer --- src/drivers/driver_nl80211.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 58b1265fe6..6d5284e0ef 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -3737,6 +3737,14 @@ static int wpa_driver_nl80211_send_mlme(struct i802_bss *bss, const u8 *data, MAC2STR(mgmt->da), noack, freq, no_cck, offchanok, wait_time, no_encrypt, fc, fc2str(fc), drv->nlmode); + if (is_sta_interface(drv->nlmode) && + WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT && + WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_AUTH) { + return nl80211_send_frame_cmd(bss, freq, wait_time, + data, data_len, use_cookie, 1, noack, + 1, csa_offs, csa_offs_len); + } + if ((is_sta_interface(drv->nlmode) || drv->nlmode == NL80211_IFTYPE_P2P_DEVICE) && WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT && From patchwork Mon Feb 24 09:14:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 1242933 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=LEmbtQa0; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48QxsR1WxQz9sRQ for ; Mon, 24 Feb 2020 20:41:31 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=6fe01VAmz9KUXPHm1H8+KxqpxuGcsjiVLgKttkxN5Wc=; b=LEmbtQa0j2ySZ5Dtg3/cKOnR0y BJ7YtKOoPtwAJFqCG4lbueV01acudv9NsiMV2Sv8fUiP0QDH/EwjX4sfBk83JvyLTMJ/pNmxiMjD5 4J520w+R8kxPxXhjZtxDzWRPGXBbZcgbsmupXFfDqsGiS845BzGy1nZpx7RBaqXpZySjc9i10X4P9 SAweTxeoQtXKCJnrljMEN3cv3enSy5/nKp4dr0TVLDKCfmMWo5jC/jFI3rwLgLDh2LiLMunezyRPE fUu8g9L/5xbqAC2AE1juy/DN4T+sXKAXF8XBERWxwXcMvc3HSZsKos+PDGJcsRAUEiX0HgEeZMZC5 /73hjCAg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6AEu-0002bX-Cm; Mon, 24 Feb 2020 09:41:24 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j69pC-0006C4-C9 for hostap@lists.infradead.org; Mon, 24 Feb 2020 09:14:52 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2020 01:14:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,479,1574150400"; d="scan'208";a="225914128" Received: from jed01681.jer.intel.com ([10.12.190.127]) by orsmga007.jf.intel.com with ESMTP; 24 Feb 2020 01:14:46 -0800 From: Ilan Peer To: hostap@lists.infradead.org Subject: [PATCH 04/12] nl80211: Allow Tx status for authentication frames Date: Mon, 24 Feb 2020 11:14:29 +0200 Message-Id: <20200224091437.15212-5-ilan.peer@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200224091437.15212-1-ilan.peer@intel.com> References: <20200224091437.15212-1-ilan.peer@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200224_011450_668582_5E8A7AF3 X-CRM114-Status: GOOD ( 12.10 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [192.55.52.93 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ilan Peer MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org To support PASN authentication flow, where authentication frames are sent by the wpa_supplicant using send_mlme() callback, modify the logic in driver_nl80211 to also send EVENT_TX_STATUS for authentication frames. Signed-off-by: Ilan Peer --- src/drivers/driver_nl80211_event.c | 39 ++++++++++++++++++------------ 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c index 8327644fb1..ec2b643a7e 100644 --- a/src/drivers/driver_nl80211_event.c +++ b/src/drivers/driver_nl80211_event.c @@ -683,29 +683,36 @@ static void mlme_event_mgmt_tx_status(struct wpa_driver_nl80211_data *drv, size_t len, struct nlattr *ack) { union wpa_event_data event; - const struct ieee80211_hdr *hdr; - u16 fc; + const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *)frame; + u16 fc = le_to_host16(hdr->frame_control); wpa_printf(MSG_DEBUG, "nl80211: Frame TX status event"); + + if (WLAN_FC_GET_TYPE(fc) != WLAN_FC_TYPE_MGMT) + return; + if (!is_ap_interface(drv->nlmode)) { - u64 cookie_val; + if (WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_ACTION) { + u64 cookie_val; - if (!cookie) - return; + if (!cookie) + return; - cookie_val = nla_get_u64(cookie); - wpa_printf(MSG_DEBUG, - "nl80211: Frame TX status: cookie=0x%llx%s (ack=%d)", - (long long unsigned int) cookie_val, - cookie_val == drv->send_frame_cookie ? - " (match)" : " (unknown)", ack != NULL); - if (cookie_val != drv->send_frame_cookie) - return; + cookie_val = nla_get_u64(cookie); + wpa_printf(MSG_DEBUG, + "nl80211: Frame TX status: cookie=0x%llx%s (ack=%d)", + (long long unsigned int) cookie_val, + cookie_val == drv->send_frame_cookie ? + " (match)" : " (unknown)", ack != NULL); + if (cookie_val != drv->send_frame_cookie) + return; + } else if (WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_AUTH) { + wpa_printf(MSG_DEBUG, + "nl80211: Auth TX status: ack=%d", + !!ack); + } } - hdr = (const struct ieee80211_hdr *) frame; - fc = le_to_host16(hdr->frame_control); - os_memset(&event, 0, sizeof(event)); event.tx_status.type = WLAN_FC_GET_TYPE(fc); event.tx_status.stype = WLAN_FC_GET_STYPE(fc); From patchwork Mon Feb 24 09:14:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 1242932 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=lgER/4/F; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48QxsF2HH7z9sR4 for ; Mon, 24 Feb 2020 20:41:21 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=0g86tTjXd9eZ15tduLVSKyQJwx6DYAoSGwpV59bVCPI=; b=lgER/4/FMJjuGsZG38llcDQtwr RwkdWi2tRCSZZ4hKKnhwL4XTqLD6FVKZDwTD9lZo6BXfo63FiSbK2NMvIwr+edLiLyucOAdvXn6uT 1kSEPoMO5LzdGEhZ3vxyq/EVfVc5U66SP9AAi4j4KizhqfUfF7V8JMP7KDoP30pWeL8zakNHC5GB7 rBt9nkVjx/zdclChhCnZFcvoDkXMJ9TX85e3472gXN+iRQjXv52Rm0hv3KAVvdIus3usuvvBG9oJH 5FLHiujBkYFh53snjukuTAJXUFHI63tLVLzBCDLz0DLFp8YOdoHRYiT9le6vT7aDBeB5vHdITNapI BPcObCXw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6AEm-0002SF-2K; Mon, 24 Feb 2020 09:41:16 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j69pC-0006At-08 for hostap@lists.infradead.org; Mon, 24 Feb 2020 09:14:51 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2020 01:14:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,479,1574150400"; d="scan'208";a="225914134" Received: from jed01681.jer.intel.com ([10.12.190.127]) by orsmga007.jf.intel.com with ESMTP; 24 Feb 2020 01:14:47 -0800 From: Ilan Peer To: hostap@lists.infradead.org Subject: [PATCH 05/12] nl80211: Always register for Rx authentication frames with PASN Date: Mon, 24 Feb 2020 11:14:30 +0200 Message-Id: <20200224091437.15212-6-ilan.peer@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200224091437.15212-1-ilan.peer@intel.com> References: <20200224091437.15212-1-ilan.peer@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200224_011450_093368_6A58F0BF X-CRM114-Status: GOOD ( 10.49 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [192.55.52.93 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ilan Peer MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Register a filter that only requests PASN authentication frames to be passed to user space. Signed-off-by: Ilan Peer --- src/drivers/driver_nl80211.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 6d5284e0ef..f630884a94 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -2199,6 +2199,22 @@ static int nl80211_mgmt_subscribe_non_ap(struct i802_bss *bss) nl80211_register_frame(bss, bss->nl_mgmt, type, (u8 *) "\x03\x00", 2); +#ifdef CONFIG_PASN + wpa_printf(MSG_DEBUG, "nl80211: Subscribe PASN authentication frames"); + + /* + * TODO: the PASN authentication identifier was not defined yet in the + * specification, for now using 0x07, as defined in other places in the + * code. + */ + if (drv->capa.flags & WPA_DRIVER_FLAGS_SME) + if (nl80211_register_frame(bss, bss->nl_mgmt, + (WLAN_FC_TYPE_MGMT << 2) | + (WLAN_FC_STYPE_AUTH << 4), + (u8 *)"\x07\x00", 2)) + ret = -1; +#endif /* CONFIG_PASN */ + #ifdef CONFIG_INTERWORKING /* QoS Map Configure */ if (nl80211_register_action_frame(bss, (u8 *) "\x01\x04", 2) < 0) From patchwork Mon Feb 24 09:14:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 1242934 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=twz6LExh; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Qxsc2YQCz9sPk for ; Mon, 24 Feb 2020 20:41:40 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=3iFDucvRnJxMLRlMe+j1fXdtCkQ7aMzsZqC/T9NzdQg=; b=twz6LExhi+JoKNR9Yy70aCBWco bQnluXt1bWMSLNO7490lNbDOfhHOcDf9V3xplWEc7Tm27KmKLqxExwy+OARydg6xGe7V7Ewnfe7by 6f9IN23dnXgvxDmaAduBlCIe8/vVXjqxpjLro8LnkQ5fN1XCvLylhMF/7xZUOEk2Y3OSAt//9zHnk VuhbJ0ur9ei+ZaN/Y8RY1L6HAcN1mSF9B1i1VMBv8tqZHplvlkblVtn/NQxERay04iKwpmDJTemAz VzxH1/cEBxhmDkrKrUKZiY9Q8yLcptafq7RB7e8Q9W/89Oepx1hAQsp0xtHUwtAafxxjyJw8EH9HG oo3jlvYQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6AF4-0002n5-LA; Mon, 24 Feb 2020 09:41:34 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j69pC-0006Cf-La for hostap@lists.infradead.org; Mon, 24 Feb 2020 09:14:53 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2020 01:14:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,479,1574150400"; d="scan'208";a="225914138" Received: from jed01681.jer.intel.com ([10.12.190.127]) by orsmga007.jf.intel.com with ESMTP; 24 Feb 2020 01:14:49 -0800 From: Ilan Peer To: hostap@lists.infradead.org Subject: [PATCH 06/12] crypto: Add a function to get the ECDH prime len Date: Mon, 24 Feb 2020 11:14:31 +0200 Message-Id: <20200224091437.15212-7-ilan.peer@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200224091437.15212-1-ilan.peer@intel.com> References: <20200224091437.15212-1-ilan.peer@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200224_011450_796847_2BA0A2E9 X-CRM114-Status: UNSURE ( 9.96 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [192.55.52.93 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ilan Peer MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: Ilan Peer --- src/crypto/crypto.h | 1 + src/crypto/crypto_openssl.c | 4 ++++ src/crypto/crypto_wolfssl.c | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h index 440da03029..7c7515f6bc 100644 --- a/src/crypto/crypto.h +++ b/src/crypto/crypto.h @@ -916,5 +916,6 @@ struct wpabuf * crypto_ecdh_get_pubkey(struct crypto_ecdh *ecdh, int inc_y); struct wpabuf * crypto_ecdh_set_peerkey(struct crypto_ecdh *ecdh, int inc_y, const u8 *key, size_t len); void crypto_ecdh_deinit(struct crypto_ecdh *ecdh); +size_t crypto_ecdh_prime_len(struct crypto_ecdh *ecdh); #endif /* CRYPTO_H */ diff --git a/src/crypto/crypto_openssl.c b/src/crypto/crypto_openssl.c index 783b293e9b..53ef8f7271 100644 --- a/src/crypto/crypto_openssl.c +++ b/src/crypto/crypto_openssl.c @@ -2168,4 +2168,8 @@ void crypto_ecdh_deinit(struct crypto_ecdh *ecdh) } } +size_t crypto_ecdh_prime_len(struct crypto_ecdh *ecdh) +{ + return crypto_ec_prime_len(ecdh->ec); +} #endif /* CONFIG_ECC */ diff --git a/src/crypto/crypto_wolfssl.c b/src/crypto/crypto_wolfssl.c index 85ce565bdf..77b74bcb00 100644 --- a/src/crypto/crypto_wolfssl.c +++ b/src/crypto/crypto_wolfssl.c @@ -1834,4 +1834,8 @@ fail: goto done; } +size_t crypto_ecdh_prime_len(struct crypto_ecdh *ecdh) +{ + return crypto_ec_prime_len(ecdh->ec); +} #endif /* CONFIG_ECC */ From patchwork Mon Feb 24 09:14:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 1242935 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=PK5LZhpe; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Qxsw0LSSz9sPk for ; Mon, 24 Feb 2020 20:41:56 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ENRH6kOurdC4UYojV8/C3MUDhDzI8jW82CIjp30aSd0=; b=PK5LZhpeCgTlNsV1YT36JRH+vT CA3BSgPYXpc9kQUPcOgSWRF9ct0h7OagyPJzqG4joXtevnhi4WS9KwNem0WEKGaNJ3guL3Fc+GV2Q Ah2IUg5GTKE9sdZSZnHTX/Hld0ib2PlJyRJwHrq4gvRt0/94Dc8dYgyYuAs4YSDhlenCXuP/pfO+l AbnpNMZooRI/Oiojf41LqSTAwQU3/ma/krqB4XXnZNypAPBhLs0JtBRrghaBwQYtaTrqZTIlimVYi ZRv5UNis8Rm1+98i85Ojk01hSKwLTP2W52QKZWIEOIPpFSzIH7b7mIs5Gw12Pp+LDzIGfpgARrC6K 3/9v9zJw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6AFI-0002z9-I5; Mon, 24 Feb 2020 09:41:48 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j69pE-0006At-8S for hostap@lists.infradead.org; Mon, 24 Feb 2020 09:14:55 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2020 01:14:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,479,1574150400"; d="scan'208";a="225914150" Received: from jed01681.jer.intel.com ([10.12.190.127]) by orsmga007.jf.intel.com with ESMTP; 24 Feb 2020 01:14:50 -0800 From: Ilan Peer To: hostap@lists.infradead.org Subject: [PATCH 07/12] WPA: Rename FILS wrapped data Date: Mon, 24 Feb 2020 11:14:32 +0200 Message-Id: <20200224091437.15212-8-ilan.peer@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200224091437.15212-1-ilan.peer@intel.com> References: <20200224091437.15212-1-ilan.peer@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200224_011452_480102_3BD071B0 X-CRM114-Status: GOOD ( 13.87 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [192.55.52.93 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ilan Peer MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Draft P802.11az_D2.0 renamed the FILS wrapped data element, removing the FILS prefix. Change the code accordingly. Signed-off-by: Ilan Peer --- src/ap/ieee802_11.c | 16 ++++++++-------- src/common/ieee802_11_common.c | 6 +++--- src/common/ieee802_11_common.h | 4 ++-- src/common/ieee802_11_defs.h | 2 +- src/rsn_supp/wpa.c | 12 ++++++------ 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index 03810de4e3..26b5a06ed2 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -1817,10 +1817,10 @@ void handle_auth_fils(struct hostapd_data *hapd, struct sta_info *sta, os_memcpy(sta->fils_session, elems.fils_session, FILS_SESSION_LEN); /* FILS Wrapped Data */ - if (elems.fils_wrapped_data) { + if (elems.wrapped_data) { wpa_hexdump(MSG_DEBUG, "FILS: Wrapped Data", - elems.fils_wrapped_data, - elems.fils_wrapped_data_len); + elems.wrapped_data, + elems.wrapped_data_len); if (!pmksa) { #ifndef CONFIG_NO_RADIUS if (!sta->eapol_sm) { @@ -1830,8 +1830,8 @@ void handle_auth_fils(struct hostapd_data *hapd, struct sta_info *sta, wpa_printf(MSG_DEBUG, "FILS: Forward EAP-Initiate/Re-auth to authentication server"); ieee802_1x_encapsulate_radius( - hapd, sta, elems.fils_wrapped_data, - elems.fils_wrapped_data_len); + hapd, sta, elems.wrapped_data, + elems.wrapped_data_len); sta->fils_pending_cb = cb; wpa_printf(MSG_DEBUG, "FILS: Will send Authentication frame once the response from authentication server is available"); @@ -1840,8 +1840,8 @@ void handle_auth_fils(struct hostapd_data *hapd, struct sta_info *sta, * to maintain a copy of the EAP-Initiate/Reauth * message. */ if (fils_pmkid_erp(wpa_auth_sta_key_mgmt(sta->wpa_sm), - elems.fils_wrapped_data, - elems.fils_wrapped_data_len, + elems.wrapped_data, + elems.wrapped_data_len, sta->fils_erp_pmkid) == 0) sta->fils_erp_pmkid_set = 1; return; @@ -1989,7 +1989,7 @@ prepare_auth_resp_fils(struct hostapd_data *hapd, wpabuf_put_u8(data, WLAN_EID_EXTENSION); /* Element ID */ wpabuf_put_u8(data, 1 + wpabuf_len(erp_resp)); /* Length */ /* Element ID Extension */ - wpabuf_put_u8(data, WLAN_EID_EXT_FILS_WRAPPED_DATA); + wpabuf_put_u8(data, WLAN_EID_EXT_WRAPPED_DATA); wpabuf_put_buf(data, erp_resp); if (fils_rmsk_to_pmk(wpa_auth_sta_key_mgmt(sta->wpa_sm), diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c index 36005d75fe..679170d492 100644 --- a/src/common/ieee802_11_common.c +++ b/src/common/ieee802_11_common.c @@ -245,9 +245,9 @@ static int ieee802_11_parse_extension(const u8 *pos, size_t elen, elems->key_delivery = pos; elems->key_delivery_len = elen; break; - case WLAN_EID_EXT_FILS_WRAPPED_DATA: - elems->fils_wrapped_data = pos; - elems->fils_wrapped_data_len = elen; + case WLAN_EID_EXT_WRAPPED_DATA: + elems->wrapped_data = pos; + elems->wrapped_data_len = elen; break; case WLAN_EID_EXT_FILS_PUBLIC_KEY: if (elen < 1) diff --git a/src/common/ieee802_11_common.h b/src/common/ieee802_11_common.h index d133169695..bb2793d084 100644 --- a/src/common/ieee802_11_common.h +++ b/src/common/ieee802_11_common.h @@ -85,7 +85,7 @@ struct ieee802_11_elems { const u8 *fils_hlp; const u8 *fils_ip_addr_assign; const u8 *key_delivery; - const u8 *fils_wrapped_data; + const u8 *wrapped_data; const u8 *fils_pk; const u8 *fils_nonce; const u8 *owe_dh; @@ -138,7 +138,7 @@ struct ieee802_11_elems { u8 fils_hlp_len; u8 fils_ip_addr_assign_len; u8 key_delivery_len; - u8 fils_wrapped_data_len; + u8 wrapped_data_len; u8 fils_pk_len; u8 owe_dh_len; u8 power_capab_len; diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h index a78ed0a122..7c51574b58 100644 --- a/src/common/ieee802_11_defs.h +++ b/src/common/ieee802_11_defs.h @@ -458,7 +458,7 @@ #define WLAN_EID_EXT_FILS_HLP_CONTAINER 5 #define WLAN_EID_EXT_FILS_IP_ADDR_ASSIGN 6 #define WLAN_EID_EXT_KEY_DELIVERY 7 -#define WLAN_EID_EXT_FILS_WRAPPED_DATA 8 +#define WLAN_EID_EXT_WRAPPED_DATA 8 #define WLAN_EID_EXT_FTM_SYNC_INFO 9 #define WLAN_EID_EXT_EXTENDED_REQUEST 10 #define WLAN_EID_EXT_ESTIMATED_SERVICE_PARAMS 11 diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c index 263e2108a0..2887bdf34e 100644 --- a/src/rsn_supp/wpa.c +++ b/src/rsn_supp/wpa.c @@ -3873,7 +3873,7 @@ struct wpabuf * fils_build_auth(struct wpa_sm *sm, int dh_group, const u8 *md) wpabuf_put_u8(buf, WLAN_EID_EXTENSION); /* Element ID */ wpabuf_put_u8(buf, 1 + wpabuf_len(erp_msg)); /* Length */ /* Element ID Extension */ - wpabuf_put_u8(buf, WLAN_EID_EXT_FILS_WRAPPED_DATA); + wpabuf_put_u8(buf, WLAN_EID_EXT_WRAPPED_DATA); wpabuf_put_buf(buf, erp_msg); /* Calculate pending PMKID here so that we do not need to * maintain a copy of the EAP-Initiate/Reauth message. */ @@ -4079,15 +4079,15 @@ int fils_process_auth(struct wpa_sm *sm, const u8 *bssid, const u8 *data, } /* FILS Wrapped Data */ - if (!sm->cur_pmksa && elems.fils_wrapped_data) { + if (!sm->cur_pmksa && elems.wrapped_data) { u8 rmsk[ERP_MAX_KEY_LEN]; size_t rmsk_len; wpa_hexdump(MSG_DEBUG, "FILS: Wrapped Data", - elems.fils_wrapped_data, - elems.fils_wrapped_data_len); - eapol_sm_process_erp_finish(sm->eapol, elems.fils_wrapped_data, - elems.fils_wrapped_data_len); + elems.wrapped_data, + elems.wrapped_data_len); + eapol_sm_process_erp_finish(sm->eapol, elems.wrapped_data, + elems.wrapped_data_len); if (eapol_sm_failed(sm->eapol)) goto fail; From patchwork Mon Feb 24 09:14:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 1242939 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=fKwxpznd; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48QxtF2hT3z9sRh for ; Mon, 24 Feb 2020 20:42:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=vI9+jXseAjzz79FAFKLLncPUkRbWacEbtsdr61oS+9U=; b=fKwxpznd4R4DuQIZSCAVi0SsDG Il2pOFRongOntwSNIT1pPp7NYcitjyHXAAkXoEFRs2F+vS75/ic+buCxj3iUFpfc/2VMOUBOxZtQE sQOPVzxW9n9gyEqlB05QEQUmkNqEfya48eQRCtZwbhBI003O8qxOcA3Yg/aRchxZz3edrQiUysmSL I607GLNZ5AWwHWAXdYzb5yufkG8c7KoqHCjGiTdk8DwsmvyJXYD4C0rGntPlwPEH+UnwiGyk2sRf4 4ivvwj4nqokmhcga9PjtLuvkFk2Bx03vFw00A5aGEWvR4RgJlikHsPxQkP3XhBoZf/oOUUyufwFM6 nudwN/9w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6AFa-0003L0-0k; Mon, 24 Feb 2020 09:42:06 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j69pG-0006Hb-Kp for hostap@lists.infradead.org; Mon, 24 Feb 2020 09:15:00 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2020 01:14:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,479,1574150400"; d="scan'208";a="225914164" Received: from jed01681.jer.intel.com ([10.12.190.127]) by orsmga007.jf.intel.com with ESMTP; 24 Feb 2020 01:14:51 -0800 From: Ilan Peer To: hostap@lists.infradead.org Subject: [PATCH 08/12] common: Add support for element defragmentation Date: Mon, 24 Feb 2020 11:14:33 +0200 Message-Id: <20200224091437.15212-9-ilan.peer@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200224091437.15212-1-ilan.peer@intel.com> References: <20200224091437.15212-1-ilan.peer@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200224_011454_813987_A566D2FD X-CRM114-Status: GOOD ( 17.06 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [192.55.52.93 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ilan Peer MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add support for element defragmentation as defined in Draft P802.11REVmd_2.2 section 10.29.11. Signed-off-by: Ilan Peer --- src/common/ieee802_11_common.c | 115 ++++++++++++++++++++++++++++++++- src/common/ieee802_11_common.h | 24 +++++++ 2 files changed, 138 insertions(+), 1 deletion(-) diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c index 679170d492..213f6a8553 100644 --- a/src/common/ieee802_11_common.c +++ b/src/common/ieee802_11_common.c @@ -206,6 +206,8 @@ static int ieee802_11_parse_extension(const u8 *pos, size_t elen, ext_id = *pos++; elen--; + elems->frag_ies.last_eid_ext = 0; + switch (ext_id) { case WLAN_EID_EXT_ASSOC_DELAY_INFO: if (elen != 1) @@ -295,6 +297,8 @@ static int ieee802_11_parse_extension(const u8 *pos, size_t elen, return -1; } + if (elen == 254) + elems->frag_ies.last_eid_ext = ext_id; return 0; } @@ -516,7 +520,34 @@ ParseRes ieee802_11_parse_elems(const u8 *start, size_t len, elems->dils_len = elen; break; case WLAN_EID_FRAGMENT: - /* TODO */ + if (elems->frag_ies.n_frags >= + MAX_NUM_FRAG_IES_SUPPORTED) { + wpa_printf(MSG_MSGDUMP, + "Too many frags. Skip"); + break; + } + + /* + * Note: while EID == 0 is a valid ID (SSID IE), it + * should not be fragmented. + */ + if (!elems->frag_ies.last_eid) { + wpa_printf(MSG_MSGDUMP, + "Fragment without a valid IE. Skip"); + break; + } + + elems->frag_ies.frags[elems->frag_ies.n_frags].ie = pos; + elems->frag_ies.frags[elems->frag_ies.n_frags].ie_len = + elen; + + elems->frag_ies.frags[elems->frag_ies.n_frags].eid = + elems->frag_ies.last_eid; + + elems->frag_ies.frags[elems->frag_ies.n_frags].eid_ext = + elems->frag_ies.last_eid_ext; + + elems->frag_ies.n_frags++; break; case WLAN_EID_EXTENSION: if (ieee802_11_parse_extension(pos, elen, elems, @@ -532,6 +563,12 @@ ParseRes ieee802_11_parse_elems(const u8 *start, size_t len, id, elen); break; } + + if (id != WLAN_EID_FRAGMENT && elen == 255) + elems->frag_ies.last_eid = id; + + if (id == WLAN_EID_EXTENSION && !elems->frag_ies.last_eid_ext) + elems->frag_ies.last_eid = 0; } if (!for_each_element_completed(elem, start, len)) { @@ -2391,3 +2428,79 @@ int op_class_to_ch_width(u8 op_class) } return CHANWIDTH_USE_HT; } + + +struct wpabuf *ieee802_11_defrag_data(struct ieee802_11_elems *elems, + u8 eid, u8 eid_ext, + const u8 *data, u8 len) +{ + struct wpabuf *buf; + u32 i; + + if (!elems || !data || !len) + return NULL; + + buf = wpabuf_alloc(len); + if (!buf) + return NULL; + + wpabuf_put_data(buf, data, len); + + for (i = 0; i < elems->frag_ies.n_frags; i++) { + int ret; + + if (elems->frag_ies.frags[i].eid != eid || + elems->frag_ies.frags[i].eid_ext != eid_ext) + continue; + + ret = wpabuf_resize(&buf, elems->frag_ies.frags[i].ie_len); + if (ret < 0) { + wpabuf_free(buf); + return NULL; + } + + /* Copy only the fragment data (without the EID and length) */ + wpabuf_put_data(buf, elems->frag_ies.frags[i].ie, + elems->frag_ies.frags[i].ie_len); + } + + return buf; +} + + +struct wpabuf *ieee802_11_defrag(struct ieee802_11_elems *elems, + u8 eid, u8 eid_ext) +{ + const u8 *data; + u8 len; + + /* + * TODO: Defragmentation mechanism can be supported for all IEs. For now + * handle only those that are used (or use ieee802_11_defrag_data()). + */ + switch (eid) { + case WLAN_EID_EXTENSION: + switch (eid_ext) { + case WLAN_EID_EXT_FILS_HLP_CONTAINER: + data = elems->fils_hlp; + len = elems->fils_hlp_len; + break; + case WLAN_EID_EXT_WRAPPED_DATA: + data = elems->wrapped_data; + len = elems->wrapped_data_len; + break; + default: + wpa_printf(MSG_DEBUG, + "Defragmentation not supported. eid_ext=%u", + eid_ext); + return NULL; + } + break; + default: + wpa_printf(MSG_DEBUG, + "Defragmentation not supported. eid=%u", eid); + return NULL; + } + + return ieee802_11_defrag_data(elems, eid, eid_ext, data, len); +} diff --git a/src/common/ieee802_11_common.h b/src/common/ieee802_11_common.h index bb2793d084..ed22d53698 100644 --- a/src/common/ieee802_11_common.h +++ b/src/common/ieee802_11_common.h @@ -21,6 +21,7 @@ struct element { struct hostapd_hw_modes; #define MAX_NOF_MB_IES_SUPPORTED 5 +#define MAX_NUM_FRAG_IES_SUPPORTED 3 struct mb_ies_info { struct { @@ -30,6 +31,21 @@ struct mb_ies_info { u8 nof_ies; }; +struct frag_ies_info { + struct { + u8 eid; + u8 eid_ext; + const u8 *ie; + u8 ie_len; + } frags[MAX_NUM_FRAG_IES_SUPPORTED]; + + u8 n_frags; + + /* the last parsed element ID and element extension ID */ + u8 last_eid; + u8 last_eid_ext; +}; + /* Parsed Information Elements */ struct ieee802_11_elems { const u8 *ssid; @@ -151,6 +167,7 @@ struct ieee802_11_elems { u8 short_ssid_list_len; struct mb_ies_info mb_ies; + struct frag_ies_info frag_ies; }; typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes; @@ -293,4 +310,11 @@ void hostapd_encode_edmg_chan(int edmg_enable, u8 edmg_channel, int ieee802_edmg_is_allowed(struct ieee80211_edmg_config allowed, struct ieee80211_edmg_config requested); +struct wpabuf *ieee802_11_defrag_data(struct ieee802_11_elems *elems, + u8 eid, u8 eid_ext, + const u8 *data, u8 len); + +struct wpabuf *ieee802_11_defrag(struct ieee802_11_elems *elems, + u8 eid, u8 eid_ext); + #endif /* IEEE802_11_COMMON_H */ From patchwork Mon Feb 24 09:14:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 1242936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=t6MWgWxW; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Qxt06v6Bz9sPk for ; Mon, 24 Feb 2020 20:42:00 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Tu7TAvEnfdKyYZ6UibbpcDvyp0j1qLuG4qdXd56evtQ=; b=t6MWgWxWanZgAmc92xkqbRkLN3 P3MWHfHm4r7F3l3grBld00DktPVt2Yjb0ZdOIb68KpjRa7VgCpp150SJZRF8KmvRnboY84NgAHgY/ sEcIrV7DZIeUO/jSkoborKaine7+/9LjRh9DuL1lWBSLReARNq9YHpcudh6RgXOn2EPmwKLSVlc5Y NRiyZj6rs5PeT5MjPMhKn87yUdrEEIlU/wwhWzhW5eeJtSXsbIMK7t6GvIywXjdrxzxoCnXWhfb29 xCUwHdEuJ0JxxNLRq8owHoDCcnWJvbToGvVzB4Tm6KiJTvh2ryJ2C6xscmrWsnd4X+QgM5mGYAZ4E JSZY0YRw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6AFQ-00038k-EK; Mon, 24 Feb 2020 09:41:56 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j69pG-0006Hh-T3 for hostap@lists.infradead.org; Mon, 24 Feb 2020 09:14:58 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2020 01:14:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,479,1574150400"; d="scan'208";a="225914172" Received: from jed01681.jer.intel.com ([10.12.190.127]) by orsmga007.jf.intel.com with ESMTP; 24 Feb 2020 01:14:53 -0800 From: Ilan Peer To: hostap@lists.infradead.org Subject: [PATCH 09/12] common: Allow WPA_CIPHER_GTK_NOT_USED in RSNE parsing Date: Mon, 24 Feb 2020 11:14:34 +0200 Message-Id: <20200224091437.15212-10-ilan.peer@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200224091437.15212-1-ilan.peer@intel.com> References: <20200224091437.15212-1-ilan.peer@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200224_011455_016167_2CD87367 X-CRM114-Status: GOOD ( 11.21 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [192.55.52.93 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ilan Peer MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org PASN authentication requires that group management cipher suite would be set to 00-0F-AC:7 in the RSN IE, so allow this value when parsing and validating the RSN IE. Signed-off-by: Ilan Peer --- src/common/wpa_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/wpa_common.c b/src/common/wpa_common.c index 6cb9180ee8..bd79575d0f 100644 --- a/src/common/wpa_common.c +++ b/src/common/wpa_common.c @@ -1369,7 +1369,8 @@ int wpa_parse_wpa_ie_rsn(const u8 *rsn_ie, size_t rsn_ie_len, if (left >= 4) { data->mgmt_group_cipher = rsn_selector_to_bitfield(pos); - if (!wpa_cipher_valid_mgmt_group(data->mgmt_group_cipher)) { + if (data->mgmt_group_cipher != WPA_CIPHER_GTK_NOT_USED && + !wpa_cipher_valid_mgmt_group(data->mgmt_group_cipher)) { wpa_printf(MSG_DEBUG, "%s: Unsupported management group cipher 0x%x (%08x)", __func__, data->mgmt_group_cipher, From patchwork Mon Feb 24 09:14:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 1242942 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=Fxcnr+Ea; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48QxtM5Nrnz9sPk for ; Mon, 24 Feb 2020 20:42:19 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=QntEIHytO5UQJHqMT60GdT84CYgQCqOx0hSRktwYVvc=; b=Fxcnr+EaVl/71WT2zNDXXlExp0 zkTx1QHo/G0HrYP1kJYZOagbXEIGM036geR0ho5Ozu3TngzgKYBUEPmoHKPBfuU1zBo4Grc334sRh jjCgOlj/vSQmlD/zryOrA+W3A4P8UgaXfiOOwKZU85QEqT68cZjyr8nhmp+RMsO3cgKV6CbY4i2Dq Kh/HWy6axKn3umVJ5mQOze8N4H4f2XxB7VRX1p31voWQtjQ3sW6In/BunHIFFMDY1rVkGmtkWIfUN zX2VYItU4EHeZ2r6c2pqXlH715AgvHTceC6BVSJuSGfOjg/86ytSY3UQKpyU0+H3XEd8ds8otHtA0 sEsATRcw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6AFi-0003Sz-79; Mon, 24 Feb 2020 09:42:14 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j69pI-0006At-9g for hostap@lists.infradead.org; Mon, 24 Feb 2020 09:15:09 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2020 01:14:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,479,1574150400"; d="scan'208";a="225914179" Received: from jed01681.jer.intel.com ([10.12.190.127]) by orsmga007.jf.intel.com with ESMTP; 24 Feb 2020 01:14:54 -0800 From: Ilan Peer To: hostap@lists.infradead.org Subject: [PATCH 10/12] WPA: Extend the wpa_pmk_to_ptk() function to also derive HLTK Date: Mon, 24 Feb 2020 11:14:35 +0200 Message-Id: <20200224091437.15212-11-ilan.peer@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200224091437.15212-1-ilan.peer@intel.com> References: <20200224091437.15212-1-ilan.peer@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200224_011456_452740_DF178213 X-CRM114-Status: GOOD ( 21.07 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [192.55.52.93 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ilan Peer MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Extend the wpa_pmk_to_ptk() to also derive High Level Transient Key (HLTK), which can later be used for for secure LTF measurements. Update the wpa_supplicant and hostapd configuration and the corresponding WPA and WPA Auth state machine, to allow enabling of HLTK derivation. Signed-off-by: Ilan Peer --- hostapd/config_file.c | 6 ++++++ src/ap/ap_config.h | 10 ++++++++++ src/ap/wpa_auth.c | 3 ++- src/ap/wpa_auth.h | 6 ++++++ src/ap/wpa_auth_glue.c | 5 +++++ src/common/wpa_common.c | 23 ++++++++++++++++++++--- src/common/wpa_common.h | 5 ++++- src/rsn_supp/wpa.c | 5 ++++- src/rsn_supp/wpa.h | 1 + src/rsn_supp/wpa_i.h | 6 ++++++ wlantest/rx_eapol.c | 2 +- wpa_supplicant/config.c | 5 +++++ wpa_supplicant/config.h | 10 ++++++++++ wpa_supplicant/wpas_glue.c | 5 +++++ 14 files changed, 85 insertions(+), 7 deletions(-) diff --git a/hostapd/config_file.c b/hostapd/config_file.c index 6dde59a5a7..83fdacf42b 100644 --- a/hostapd/config_file.c +++ b/hostapd/config_file.c @@ -4550,6 +4550,12 @@ static int hostapd_config_fill(struct hostapd_config *conf, } bss->mka_psk_set |= MKA_PSK_SET_CKN; #endif /* CONFIG_MACSEC */ +#ifdef CONFIG_PASN +#ifdef CONFIG_TESTING_OPTIONS + } else if (os_strcmp(buf, "force_hltk_derivation") == 0) { + bss->force_hltk_derivation = atoi(pos); +#endif /* CONFIG_TESTING_OPTIONS */ +#endif /* CONFIG_PASN */ } else { wpa_printf(MSG_ERROR, "Line %d: unknown configuration item '%s'", diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h index b6e11f25f5..5a60785c20 100644 --- a/src/ap/ap_config.h +++ b/src/ap/ap_config.h @@ -840,6 +840,16 @@ struct hostapd_bss_config { */ u8 mka_psk_set; #endif /* CONFIG_MACSEC */ + +#ifdef CONFIG_PASN +#ifdef CONFIG_TESTING_OPTIONS + /* + * Normally, HLTK should be derived iff both sides support secure LTF. + * Allow forcing HLTK derivation for testing purposes + */ + int force_hltk_derivation; +#endif /* CONFIG_TESTING_OPTIONS */ +#endif /* CONFIG_PASN */ }; /** diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c index e67c344988..88c3c5aede 100644 --- a/src/ap/wpa_auth.c +++ b/src/ap/wpa_auth.c @@ -2289,7 +2289,8 @@ static int wpa_derive_ptk(struct wpa_state_machine *sm, const u8 *snonce, akmp = WPA_KEY_MGMT_PSK_SHA256; return wpa_pmk_to_ptk(pmk, pmk_len, "Pairwise key expansion", sm->wpa_auth->addr, sm->addr, sm->ANonce, snonce, - ptk, akmp, sm->pairwise, z, z_len); + ptk, akmp, sm->pairwise, z, z_len, + sm->wpa_auth->conf.hltk ? WPA_HLTK_MAX_LEN : 0); } diff --git a/src/ap/wpa_auth.h b/src/ap/wpa_auth.h index 1f7ba4899d..9c5de83e30 100644 --- a/src/ap/wpa_auth.h +++ b/src/ap/wpa_auth.h @@ -240,6 +240,12 @@ struct wpa_auth_config { #endif /* CONFIG_FILS */ int sae_pwe; int owe_ptk_workaround; + + /* + * If set Higher Layer Transient Key should be derived as part of PMK to + * PTK derivation. + */ + int hltk; }; typedef enum { diff --git a/src/ap/wpa_auth_glue.c b/src/ap/wpa_auth_glue.c index 82e82a7d2c..2d0299be00 100644 --- a/src/ap/wpa_auth_glue.c +++ b/src/ap/wpa_auth_glue.c @@ -166,6 +166,11 @@ static void hostapd_wpa_auth_conf(struct hostapd_bss_config *conf, #ifdef CONFIG_OWE wconf->owe_ptk_workaround = conf->owe_ptk_workaround; #endif /* CONFIG_OWE */ +#ifdef CONFIG_PASN +#ifdef CONFIG_TESTING_OPTIONS + wconf->hltk = conf->force_hltk_derivation; +#endif /* CONFIG_TESTING_OPTIONS */ +#endif /* CONFIG_PASN */ } diff --git a/src/common/wpa_common.c b/src/common/wpa_common.c index bd79575d0f..844bb343eb 100644 --- a/src/common/wpa_common.c +++ b/src/common/wpa_common.c @@ -333,6 +333,7 @@ int wpa_eapol_key_mic(const u8 *key, size_t key_len, int akmp, int ver, * @ptk: Buffer for pairwise transient key * @akmp: Negotiated AKM * @cipher: Negotiated pairwise cipher + * @hltk_len: the length in octets that should be derived for HTLK * Returns: 0 on success, -1 on failure * * IEEE Std 802.11i-2004 - 8.5.1.2 Pairwise key hierarchy @@ -348,12 +349,13 @@ int wpa_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const char *label, const u8 *addr1, const u8 *addr2, const u8 *nonce1, const u8 *nonce2, struct wpa_ptk *ptk, int akmp, int cipher, - const u8 *z, size_t z_len) + const u8 *z, size_t z_len, size_t hltk_len) { #define MAX_Z_LEN 66 /* with NIST P-521 */ u8 data[2 * ETH_ALEN + 2 * WPA_NONCE_LEN + MAX_Z_LEN]; size_t data_len = 2 * ETH_ALEN + 2 * WPA_NONCE_LEN; - u8 tmp[WPA_KCK_MAX_LEN + WPA_KEK_MAX_LEN + WPA_TK_MAX_LEN]; + u8 tmp[WPA_KCK_MAX_LEN + WPA_KEK_MAX_LEN + WPA_TK_MAX_LEN + + WPA_HLTK_MAX_LEN]; size_t ptk_len; if (pmk_len == 0) { @@ -387,16 +389,24 @@ int wpa_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const char *label, data_len += z_len; } + if (hltk_len > WPA_HLTK_MAX_LEN) { + wpa_printf(MSG_ERROR, + "WPA: HLTK len=%zu exceeds max supported len", + hltk_len); + return -1; + } + ptk->kck_len = wpa_kck_len(akmp, pmk_len); ptk->kek_len = wpa_kek_len(akmp, pmk_len); ptk->tk_len = wpa_cipher_key_len(cipher); + ptk->hltk_len = hltk_len; if (ptk->tk_len == 0) { wpa_printf(MSG_ERROR, "WPA: Unsupported cipher (0x%x) used in PTK derivation", cipher); return -1; } - ptk_len = ptk->kck_len + ptk->kek_len + ptk->tk_len; + ptk_len = ptk->kck_len + ptk->kek_len + ptk->tk_len + ptk->hltk_len; if (wpa_key_mgmt_sha384(akmp)) { #if defined(CONFIG_SUITEB192) || defined(CONFIG_FILS) @@ -479,6 +489,13 @@ int wpa_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const char *label, os_memcpy(ptk->tk, tmp + ptk->kck_len + ptk->kek_len, ptk->tk_len); wpa_hexdump_key(MSG_DEBUG, "WPA: TK", ptk->tk, ptk->tk_len); + if (hltk_len) { + os_memcpy(ptk->hltk, tmp + ptk->kck_len + ptk->kek_len + + ptk->tk_len, ptk->hltk_len); + wpa_hexdump_key(MSG_DEBUG, "WPA: HLTK", + ptk->hltk, ptk->hltk_len); + } + ptk->kek2_len = 0; ptk->kck2_len = 0; diff --git a/src/common/wpa_common.h b/src/common/wpa_common.h index 7850c878ef..99ec57bb38 100644 --- a/src/common/wpa_common.h +++ b/src/common/wpa_common.h @@ -199,6 +199,7 @@ struct wpa_eapol_key { #define WPA_KCK_MAX_LEN 32 #define WPA_KEK_MAX_LEN 64 #define WPA_TK_MAX_LEN 32 +#define WPA_HLTK_MAX_LEN 32 #define FILS_ICK_MAX_LEN 48 #define FILS_FT_MAX_LEN 48 @@ -212,11 +213,13 @@ struct wpa_ptk { u8 tk[WPA_TK_MAX_LEN]; /* Temporal Key (TK) */ u8 kck2[WPA_KCK_MAX_LEN]; /* FT reasoc Key Confirmation Key (KCK2) */ u8 kek2[WPA_KEK_MAX_LEN]; /* FT reassoc Key Encryption Key (KEK2) */ + u8 hltk[WPA_HLTK_MAX_LEN]; /* HL Temporal Key */ size_t kck_len; size_t kek_len; size_t tk_len; size_t kck2_len; size_t kek2_len; + size_t hltk_len; int installed; /* 1 if key has already been installed to driver */ }; @@ -356,7 +359,7 @@ int wpa_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const char *label, const u8 *addr1, const u8 *addr2, const u8 *nonce1, const u8 *nonce2, struct wpa_ptk *ptk, int akmp, int cipher, - const u8 *z, size_t z_len); + const u8 *z, size_t z_len, size_t hltk_len); int fils_rmsk_to_pmk(int akmp, const u8 *rmsk, size_t rmsk_len, const u8 *snonce, const u8 *anonce, const u8 *dh_ss, size_t dh_ss_len, u8 *pmk, size_t *pmk_len); diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c index 2887bdf34e..6841bcf0a7 100644 --- a/src/rsn_supp/wpa.c +++ b/src/rsn_supp/wpa.c @@ -604,7 +604,8 @@ static int wpa_derive_ptk(struct wpa_sm *sm, const unsigned char *src_addr, return wpa_pmk_to_ptk(sm->pmk, sm->pmk_len, "Pairwise key expansion", sm->own_addr, sm->bssid, sm->snonce, key->key_nonce, ptk, akmp, - sm->pairwise_cipher, z, z_len); + sm->pairwise_cipher, z, z_len, + sm->hltk ? WPA_HLTK_MAX_LEN : 0); } @@ -3030,6 +3031,7 @@ void wpa_sm_set_config(struct wpa_sm *sm, struct rsn_supp_config *config) sm->p2p = config->p2p; sm->wpa_rsc_relaxation = config->wpa_rsc_relaxation; sm->owe_ptk_workaround = config->owe_ptk_workaround; + sm->hltk = config->hltk; #ifdef CONFIG_FILS if (config->fils_cache_id) { sm->fils_cache_id_set = 1; @@ -3052,6 +3054,7 @@ void wpa_sm_set_config(struct wpa_sm *sm, struct rsn_supp_config *config) sm->wpa_rsc_relaxation = 0; sm->owe_ptk_workaround = 0; sm->beacon_prot = 0; + sm->hltk = 0; } } diff --git a/src/rsn_supp/wpa.h b/src/rsn_supp/wpa.h index 0bd14495ae..b9c3cb53f7 100644 --- a/src/rsn_supp/wpa.h +++ b/src/rsn_supp/wpa.h @@ -119,6 +119,7 @@ struct rsn_supp_config { int owe_ptk_workaround; const u8 *fils_cache_id; int beacon_prot; + int hltk; }; #ifndef CONFIG_NO_WPA diff --git a/src/rsn_supp/wpa_i.h b/src/rsn_supp/wpa_i.h index 7af678dcd9..f06dbd6ba4 100644 --- a/src/rsn_supp/wpa_i.h +++ b/src/rsn_supp/wpa_i.h @@ -69,6 +69,12 @@ struct wpa_sm { int owe_ptk_workaround; int beacon_prot; + /* + * If set Higher Layer Transient Key should be derived as part of PMK to + * PTK derivation. + */ + int hltk; + u8 own_addr[ETH_ALEN]; const char *ifname; const char *bridge_ifname; diff --git a/wlantest/rx_eapol.c b/wlantest/rx_eapol.c index e4fe7e23eb..0a75a89dbc 100644 --- a/wlantest/rx_eapol.c +++ b/wlantest/rx_eapol.c @@ -132,7 +132,7 @@ static int try_pmk(struct wlantest *wt, struct wlantest_bss *bss, "Pairwise key expansion", bss->bssid, sta->addr, sta->anonce, sta->snonce, &ptk, sta->key_mgmt, - sta->pairwise_cipher, NULL, 0) < 0 || + sta->pairwise_cipher, NULL, 0, 0) < 0 || check_mic(ptk.kck, ptk.kck_len, sta->key_mgmt, ver, data, len) < 0) { return -1; diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index 938165465d..0234c4fce2 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -5052,6 +5052,11 @@ static const struct global_parse_data global_fields[] = { #ifdef CONFIG_WNM { INT_RANGE(disable_btm, 0, 1), CFG_CHANGED_DISABLE_BTM }, #endif /* CONFIG_WNM */ +#ifdef CONFIG_PASN +#ifdef CONFIG_TESTING_OPTIONS + { INT_RANGE(force_hltk_derivation, 0, 1), 0 }, +#endif /* CONFIG_TESTING_OPTIONS */ +#endif /* CONFIG_PASN */ }; #undef FUNC diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h index b3c779233f..c067f6ca35 100644 --- a/wpa_supplicant/config.h +++ b/wpa_supplicant/config.h @@ -1570,6 +1570,16 @@ struct wpa_config { * By default BSS transition management is enabled */ int disable_btm; + +#ifdef CONFIG_PASN +#ifdef CONFIG_TESTING_OPTIONS + /* + * Normally, HLTK should be derived iff both sides support secure LTF. + * Allow forcing HLTK derivation for testing purposes + */ + int force_hltk_derivation; +#endif /* CONFIG_TESTING_OPTIONS */ +#endif /* CONFIG_PASN*/ }; diff --git a/wpa_supplicant/wpas_glue.c b/wpa_supplicant/wpas_glue.c index 5ddefce082..29257b9873 100644 --- a/wpa_supplicant/wpas_glue.c +++ b/wpa_supplicant/wpas_glue.c @@ -1334,5 +1334,10 @@ void wpa_supplicant_rsn_supp_set_config(struct wpa_supplicant *wpa_s, #endif /* CONFIG_FILS */ conf.beacon_prot = ssid->beacon_prot; } +#ifdef CONFIG_PASN +#ifdef CONFIG_TESTING_OPTIONS + conf.hltk = wpa_s->conf->force_hltk_derivation; +#endif /* CONFIG_TESTING_OPTIONS */ +#endif /* CONFIG_PASN*/ wpa_sm_set_config(wpa_s->wpa, ssid ? &conf : NULL); } From patchwork Mon Feb 24 09:14:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 1242943 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=ncQrqRXt; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48QxtY5H4wz9sPk for ; Mon, 24 Feb 2020 20:42:29 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=qVXJeVebLDxW2WThTSYp2sJX5lsi5gphFvgnOxCvFts=; b=ncQrqRXta7Z0RTL9ph/TtR3pxL IBC/oLSVQMzjENoBp6LzUt/wiF1DIjnvJU43bhVTEgY6Ke6I9FZ9Gx8Ut45GSHoWlvLzLKYy/yvEx +LXzZP4hlajN0SFCdL5SCVEcsy9SCCP25PaSlS53gC6om1ZgCdUBOZDsQXWy32y+Pt5Jlwr+sq+gx PMnSzdkY9JjT9UTDHyo+lsCXTjXqZKiu54gAmmPsZSMMppO0KrLOadK9IEcdtd4s8ipPKUiizwXVV mFOqd5zb7V4qn+DNjpB3L/jr1pI3Yy2Sv02/Up+7dQ7ZIKgiNi/EVYyjKh2scEJ4NFTHuU2Rh57Hk MXI2azdQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6AFp-0003eC-Or; Mon, 24 Feb 2020 09:42:21 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j69pK-0006Hh-Ky for hostap@lists.infradead.org; Mon, 24 Feb 2020 09:15:15 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2020 01:14:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,479,1574150400"; d="scan'208";a="225914185" Received: from jed01681.jer.intel.com ([10.12.190.127]) by orsmga007.jf.intel.com with ESMTP; 24 Feb 2020 01:14:56 -0800 From: Ilan Peer To: hostap@lists.infradead.org Subject: [PATCH 11/12] FT: Extend the wpa_pmk_r1_to_ptk() function to also derive HLTK Date: Mon, 24 Feb 2020 11:14:36 +0200 Message-Id: <20200224091437.15212-12-ilan.peer@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200224091437.15212-1-ilan.peer@intel.com> References: <20200224091437.15212-1-ilan.peer@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200224_011458_760091_BEC0F913 X-CRM114-Status: GOOD ( 14.54 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [192.55.52.93 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ilan Peer MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Extend the wpa_pmk_r1_to_ptk() to also derive High Level Transient Key (HLTK), which can later be used for secure LTF measurements. Signed-off-by: Ilan Peer --- src/ap/wpa_auth.c | 4 +++- src/ap/wpa_auth_ft.c | 7 +++++-- src/common/wpa_common.c | 23 ++++++++++++++++++++--- src/common/wpa_common.h | 3 ++- src/rsn_supp/wpa_ft.c | 6 ++++-- wlantest/rx_eapol.c | 2 +- wlantest/rx_mgmt.c | 4 ++-- 7 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c index 88c3c5aede..d77c0b02f6 100644 --- a/src/ap/wpa_auth.c +++ b/src/ap/wpa_auth.c @@ -2271,7 +2271,9 @@ static int wpa_derive_ptk(struct wpa_state_machine *sm, const u8 *snonce, sm->pmk_r1_name, ptk, ptk_name, sm->wpa_key_mgmt, - sm->pairwise); + sm->pairwise, + sm->wpa_auth->conf.hltk ? + WPA_HLTK_MAX_LEN : 0); } return wpa_auth_derive_ptk_ft(sm, ptk); } diff --git a/src/ap/wpa_auth_ft.c b/src/ap/wpa_auth_ft.c index c0b462558f..fd654ecd0f 100644 --- a/src/ap/wpa_auth_ft.c +++ b/src/ap/wpa_auth_ft.c @@ -2151,7 +2151,8 @@ int wpa_auth_derive_ptk_ft(struct wpa_state_machine *sm, struct wpa_ptk *ptk) return wpa_pmk_r1_to_ptk(pmk_r1, pmk_r1_len, sm->SNonce, sm->ANonce, sm->addr, sm->wpa_auth->addr, sm->pmk_r1_name, - ptk, ptk_name, sm->wpa_key_mgmt, sm->pairwise); + ptk, ptk_name, sm->wpa_key_mgmt, sm->pairwise, + 0); } @@ -3090,7 +3091,9 @@ pmk_r1_derived: if (wpa_pmk_r1_to_ptk(pmk_r1, pmk_r1_len, sm->SNonce, sm->ANonce, sm->addr, sm->wpa_auth->addr, pmk_r1_name, &sm->PTK, ptk_name, sm->wpa_key_mgmt, - pairwise) < 0) + pairwise, + sm->wpa_auth->conf.hltk ? + WPA_HLTK_MAX_LEN : 0) < 0) return WLAN_STATUS_UNSPECIFIED_FAILURE; sm->pairwise = pairwise; diff --git a/src/common/wpa_common.c b/src/common/wpa_common.c index 844bb343eb..24cfcaba50 100644 --- a/src/common/wpa_common.c +++ b/src/common/wpa_common.c @@ -1740,16 +1740,25 @@ int wpa_pmk_r1_to_ptk(const u8 *pmk_r1, size_t pmk_r1_len, const u8 *snonce, const u8 *anonce, const u8 *sta_addr, const u8 *bssid, const u8 *pmk_r1_name, - struct wpa_ptk *ptk, u8 *ptk_name, int akmp, int cipher) + struct wpa_ptk *ptk, u8 *ptk_name, int akmp, int cipher, + size_t hltk_len) { u8 buf[2 * WPA_NONCE_LEN + 2 * ETH_ALEN]; u8 *pos, hash[32]; const u8 *addr[6]; size_t len[6]; - u8 tmp[2 * WPA_KCK_MAX_LEN + 2 * WPA_KEK_MAX_LEN + WPA_TK_MAX_LEN]; + u8 tmp[2 * WPA_KCK_MAX_LEN + 2 * WPA_KEK_MAX_LEN + WPA_TK_MAX_LEN + + WPA_HLTK_MAX_LEN]; size_t ptk_len, offset; int use_sha384 = wpa_key_mgmt_sha384(akmp); + if (hltk_len > WPA_HLTK_MAX_LEN) { + wpa_printf(MSG_ERROR, + "FT: HLTK len=%zu exceeds max supported len", + hltk_len); + return -1; + } + /* * PTK = KDF-PTKLen(PMK-R1, "FT-PTK", SNonce || ANonce || * BSSID || STA-ADDR) @@ -1776,8 +1785,9 @@ int wpa_pmk_r1_to_ptk(const u8 *pmk_r1, size_t pmk_r1_len, ptk->kek_len = wpa_kek_len(akmp, PMK_LEN); ptk->kek2_len = wpa_kek2_len(akmp); ptk->tk_len = wpa_cipher_key_len(cipher); + ptk->hltk_len = hltk_len; ptk_len = ptk->kck_len + ptk->kek_len + ptk->tk_len + - ptk->kck2_len + ptk->kek2_len; + ptk->kck2_len + ptk->kek2_len + ptk->hltk_len; #ifdef CONFIG_SHA384 if (use_sha384) { @@ -1836,6 +1846,9 @@ int wpa_pmk_r1_to_ptk(const u8 *pmk_r1, size_t pmk_r1_len, os_memcpy(ptk->kck2, tmp + offset, ptk->kck2_len); offset += ptk->kck2_len; os_memcpy(ptk->kek2, tmp + offset, ptk->kek2_len); + offset += ptk->kek2_len; + os_memcpy(ptk->hltk, tmp + offset, ptk->hltk_len); + offset += ptk->hltk_len; wpa_hexdump_key(MSG_DEBUG, "FT: KCK", ptk->kck, ptk->kck_len); wpa_hexdump_key(MSG_DEBUG, "FT: KEK", ptk->kek, ptk->kek_len); @@ -1845,6 +1858,10 @@ int wpa_pmk_r1_to_ptk(const u8 *pmk_r1, size_t pmk_r1_len, if (ptk->kek2_len) wpa_hexdump_key(MSG_DEBUG, "FT: KEK2", ptk->kek2, ptk->kek2_len); + if (ptk->hltk_len) + wpa_hexdump_key(MSG_DEBUG, "FT: HLTK", + ptk->hltk, ptk->hltk_len); + wpa_hexdump_key(MSG_DEBUG, "FT: TK", ptk->tk, ptk->tk_len); wpa_hexdump(MSG_DEBUG, "FT: PTKName", ptk_name, WPA_PMK_NAME_LEN); diff --git a/src/common/wpa_common.h b/src/common/wpa_common.h index 99ec57bb38..3815584964 100644 --- a/src/common/wpa_common.h +++ b/src/common/wpa_common.h @@ -400,7 +400,8 @@ int wpa_derive_pmk_r1(const u8 *pmk_r0, size_t pmk_r0_len, int wpa_pmk_r1_to_ptk(const u8 *pmk_r1, size_t pmk_r1_len, const u8 *snonce, const u8 *anonce, const u8 *sta_addr, const u8 *bssid, const u8 *pmk_r1_name, - struct wpa_ptk *ptk, u8 *ptk_name, int akmp, int cipher); + struct wpa_ptk *ptk, u8 *ptk_name, int akmp, int cipher, + size_t hltk_len); #endif /* CONFIG_IEEE80211R */ struct wpa_ie_data { diff --git a/src/rsn_supp/wpa_ft.c b/src/rsn_supp/wpa_ft.c index 046bdfd169..42b85147df 100644 --- a/src/rsn_supp/wpa_ft.c +++ b/src/rsn_supp/wpa_ft.c @@ -63,7 +63,8 @@ int wpa_derive_ptk_ft(struct wpa_sm *sm, const unsigned char *src_addr, WPA_PMK_NAME_LEN); return wpa_pmk_r1_to_ptk(sm->pmk_r1, sm->pmk_r1_len, sm->snonce, anonce, sm->own_addr, sm->bssid, sm->pmk_r1_name, ptk, - ptk_name, sm->key_mgmt, sm->pairwise_cipher); + ptk_name, sm->key_mgmt, sm->pairwise_cipher, + sm->hltk ? WPA_HLTK_MAX_LEN : 0); } @@ -633,7 +634,8 @@ int wpa_ft_process_response(struct wpa_sm *sm, const u8 *ies, size_t ies_len, if (wpa_pmk_r1_to_ptk(sm->pmk_r1, sm->pmk_r1_len, sm->snonce, anonce, sm->own_addr, bssid, sm->pmk_r1_name, &sm->ptk, ptk_name, sm->key_mgmt, - sm->pairwise_cipher) < 0) + sm->pairwise_cipher, + sm->hltk ? WPA_HLTK_MAX_LEN : 0) < 0) return -1; if (wpa_key_mgmt_fils(sm->key_mgmt)) { diff --git a/wlantest/rx_eapol.c b/wlantest/rx_eapol.c index 0a75a89dbc..3f85c14333 100644 --- a/wlantest/rx_eapol.c +++ b/wlantest/rx_eapol.c @@ -124,7 +124,7 @@ static int try_pmk(struct wlantest *wt, struct wlantest_bss *bss, sta->addr, bss->bssid, pmk_r1_name, &ptk, ptk_name, sta->key_mgmt, - sta->pairwise_cipher) < 0 || + sta->pairwise_cipher, 0) < 0 || check_mic(ptk.kck, ptk.kck_len, sta->key_mgmt, ver, data, len) < 0) return -1; diff --git a/wlantest/rx_mgmt.c b/wlantest/rx_mgmt.c index 92762b8f04..6729371508 100644 --- a/wlantest/rx_mgmt.c +++ b/wlantest/rx_mgmt.c @@ -290,7 +290,7 @@ static void process_ft_auth(struct wlantest *wt, struct wlantest_bss *bss, wpa_pmk_r1_to_ptk(pmk_r1, PMK_LEN, parse.fte_snonce, parse.fte_anonce, sta->addr, bss->bssid, pmk_r1_name, &ptk, ptk_name, sta->key_mgmt, - sta->pairwise_cipher) < 0) + sta->pairwise_cipher, 0) < 0) return; add_note(wt, MSG_DEBUG, "Derived new PTK"); @@ -1173,7 +1173,7 @@ static void rx_mgmt_action_ft_response(struct wlantest *wt, wpa_pmk_r1_to_ptk(pmk_r1, PMK_LEN, parse.fte_snonce, parse.fte_anonce, new_sta->addr, bss->bssid, pmk_r1_name, &ptk, ptk_name, new_sta->key_mgmt, - new_sta->pairwise_cipher) < 0) + new_sta->pairwise_cipher, 0) < 0) return; add_note(wt, MSG_DEBUG, "Derived new PTK"); From patchwork Mon Feb 24 09:14:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 1242944 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=MCB15XNX; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Qxtj2knNz9sPk for ; Mon, 24 Feb 2020 20:42:37 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=cNH5KvnySwn3FlO4bfxGmupjhtJI/ZsZAZCvuc9iuRg=; b=MCB15XNXVg/6Ux1wdu3wCoigln RHGq6Rk7OHH6Fd8silMQ7GUEIehKSAdkbAlyZb9mdU6ASw70CPF9pS1fvcfIDJIWicdrcDlSWchi6 F8UjM0V7b498m3RPTbZG5QPtjmVaoNJ+7ubGLy07i2JqeOXKt6JJGFd2QndJQjXtvUW0TjJk/Pps+ 02zPh/FdOlb9J2BWH0ihKXvEi0gyVJs5c/3roP4yWhI1MUW+6N0ZXj5pE2d/nSjO6wv2oG/ijcq2K LHrMsFFUhMC5sKS+bQJ219v6iOFOIJss5lYBr7KgBswelbvbHRi64104TCHyRDO6ND7NLlYbzX5s6 Zq/tkTog==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6AFz-0003qq-RA; Mon, 24 Feb 2020 09:42:31 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j69pM-0006Hb-KS for hostap@lists.infradead.org; Mon, 24 Feb 2020 09:15:21 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2020 01:14:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,479,1574150400"; d="scan'208";a="225914191" Received: from jed01681.jer.intel.com ([10.12.190.127]) by orsmga007.jf.intel.com with ESMTP; 24 Feb 2020 01:14:57 -0800 From: Ilan Peer To: hostap@lists.infradead.org Subject: [PATCH 12/12] WPA: Extend the fils_pmk_to_ptk() function to also derive HLTK Date: Mon, 24 Feb 2020 11:14:37 +0200 Message-Id: <20200224091437.15212-13-ilan.peer@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200224091437.15212-1-ilan.peer@intel.com> References: <20200224091437.15212-1-ilan.peer@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200224_011500_725912_70154A48 X-CRM114-Status: GOOD ( 15.10 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [192.55.52.93 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ilan Peer MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Extend the fils_pmk_to_ptk() to also derive High Level Transient Key (HLTK) which can later be used for secure LTF measurements. Signed-off-by: Ilan Peer --- src/ap/wpa_auth.c | 3 ++- src/common/wpa_common.c | 30 ++++++++++++++++++++++++++---- src/common/wpa_common.h | 2 +- src/rsn_supp/wpa.c | 3 ++- wlantest/rx_mgmt.c | 2 +- 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c index d77c0b02f6..52eeedea13 100644 --- a/src/ap/wpa_auth.c +++ b/src/ap/wpa_auth.c @@ -2313,7 +2313,8 @@ int fils_auth_pmk_to_ptk(struct wpa_state_machine *sm, const u8 *pmk, snonce, anonce, dhss, dhss_len, &sm->PTK, ick, &ick_len, sm->wpa_key_mgmt, sm->pairwise, - fils_ft, &fils_ft_len); + fils_ft, &fils_ft_len, + sm->wpa_auth->conf.hltk ? WPA_HLTK_MAX_LEN : 0); if (res < 0) return res; sm->PTK_valid = TRUE; diff --git a/src/common/wpa_common.c b/src/common/wpa_common.c index 24cfcaba50..deae2a35f9 100644 --- a/src/common/wpa_common.c +++ b/src/common/wpa_common.c @@ -584,12 +584,12 @@ int fils_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const u8 *spa, const u8 *aa, const u8 *snonce, const u8 *anonce, const u8 *dhss, size_t dhss_len, struct wpa_ptk *ptk, u8 *ick, size_t *ick_len, int akmp, int cipher, - u8 *fils_ft, size_t *fils_ft_len) + u8 *fils_ft, size_t *fils_ft_len, size_t hltk_len) { u8 *data, *pos; size_t data_len; u8 tmp[FILS_ICK_MAX_LEN + WPA_KEK_MAX_LEN + WPA_TK_MAX_LEN + - FILS_FT_MAX_LEN]; + FILS_FT_MAX_LEN + WPA_HLTK_MAX_LEN]; size_t key_data_len; const char *label = "FILS PTK Derivation"; int ret = -1; @@ -600,6 +600,8 @@ int fils_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const u8 *spa, const u8 *aa, * ICK = L(FILS-Key-Data, 0, ICK_bits) * KEK = L(FILS-Key-Data, ICK_bits, KEK_bits) * TK = L(FILS-Key-Data, ICK_bits + KEK_bits, TK_bits) + * HLTK = L(FILS-Key-Data, ICK_bits + KEK_bits + TK_bits, HLTK_bits) + * * If doing FT initial mobility domain association: * FILS-FT = L(FILS-Key-Data, ICK_bits + KEK_bits + TK_bits, * FILS-FT_bits) @@ -631,6 +633,19 @@ int fils_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const u8 *spa, const u8 *aa, goto err; key_data_len = *ick_len + ptk->kek_len + ptk->tk_len; + if (hltk_len) { + if (hltk_len > WPA_HLTK_MAX_LEN) { + wpa_printf(MSG_ERROR, "FILS: HLTK len=%zu too big", + hltk_len); + goto err; + } + + ptk->hltk_len = hltk_len; + key_data_len += hltk_len; + } else { + ptk->hltk_len = 0; + } + if (fils_ft && fils_ft_len) { if (akmp == WPA_KEY_MGMT_FT_FILS_SHA256) { *fils_ft_len = 32; @@ -673,9 +688,16 @@ int fils_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const u8 *spa, const u8 *aa, os_memcpy(ptk->tk, tmp + *ick_len + ptk->kek_len, ptk->tk_len); wpa_hexdump_key(MSG_DEBUG, "FILS: TK", ptk->tk, ptk->tk_len); + if (ptk->hltk_len) { + os_memcpy(ptk->hltk, tmp + *ick_len + ptk->kek_len + + ptk->tk_len, ptk->hltk_len); + wpa_hexdump_key(MSG_DEBUG, "FILS: HLTK", ptk->hltk, + ptk->hltk_len); + } + if (fils_ft && fils_ft_len) { - os_memcpy(fils_ft, tmp + *ick_len + ptk->kek_len + ptk->tk_len, - *fils_ft_len); + os_memcpy(fils_ft, tmp + *ick_len + ptk->kek_len + ptk->tk_len + + ptk->hltk_len, *fils_ft_len); wpa_hexdump_key(MSG_DEBUG, "FILS: FILS-FT", fils_ft, *fils_ft_len); } diff --git a/src/common/wpa_common.h b/src/common/wpa_common.h index 3815584964..57d47f03eb 100644 --- a/src/common/wpa_common.h +++ b/src/common/wpa_common.h @@ -369,7 +369,7 @@ int fils_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const u8 *spa, const u8 *aa, const u8 *snonce, const u8 *anonce, const u8 *dhss, size_t dhss_len, struct wpa_ptk *ptk, u8 *ick, size_t *ick_len, int akmp, int cipher, - u8 *fils_ft, size_t *fils_ft_len); + u8 *fils_ft, size_t *fils_ft_len, size_t hltk_len); int fils_key_auth_sk(const u8 *ick, size_t ick_len, const u8 *snonce, const u8 *anonce, const u8 *sta_addr, const u8 *bssid, const u8 *g_sta, size_t g_sta_len, diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c index 6841bcf0a7..4a64fbb455 100644 --- a/src/rsn_supp/wpa.c +++ b/src/rsn_supp/wpa.c @@ -4144,7 +4144,8 @@ int fils_process_auth(struct wpa_sm *sm, const u8 *bssid, const u8 *data, dh_ss ? wpabuf_len(dh_ss) : 0, &sm->ptk, ick, &ick_len, sm->key_mgmt, sm->pairwise_cipher, - sm->fils_ft, &sm->fils_ft_len) < 0) { + sm->fils_ft, &sm->fils_ft_len, + sm->hltk ? WPA_HLTK_MAX_LEN : 0) < 0) { wpa_printf(MSG_DEBUG, "FILS: Failed to derive PTK"); goto fail; } diff --git a/wlantest/rx_mgmt.c b/wlantest/rx_mgmt.c index 6729371508..561f6b63c1 100644 --- a/wlantest/rx_mgmt.c +++ b/wlantest/rx_mgmt.c @@ -494,7 +494,7 @@ static int try_rmsk(struct wlantest *wt, struct wlantest_bss *bss, sta->snonce, sta->anonce, NULL, 0, &ptk, ick, &ick_len, sta->key_mgmt, sta->pairwise_cipher, - NULL, NULL) < 0) + NULL, NULL, 0) < 0) return -1; /* Check AES-SIV decryption with the derived key */