From patchwork Thu Apr 8 09:06:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilan Peer X-Patchwork-Id: 1463689 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=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=WCxMtK3T; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (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 4FGFlb3zxDz9sWQ for ; Thu, 8 Apr 2021 19:07:39 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=cvNt0nPgO8DpXG8VrAj/Pnob71lKppiF/bSl8P2zMMc=; b=WCxMtK3TJdegqw2k52SrkmbFew pREeabuFlRA8K3wlQEkESBZyCrmJXr8ckmt590nFKhjvOWuZS7WbrniQiVFVLIljgHUG/Wn29uclI jXmLzGBRsqwRRBC5QfG4Y0MCmZUQkzlcUawu9hpgJY4DAcZ0CEsaJjVPPITDpA7dzLw3Da/wYfEkZ hXGyP2JxnUj/3Pn0yfFsjEd1uI7sLAhzM9E/P1EPjnqMrnQx1cNkF6fXl3QOPiRFRC4KnWAeuiOqB WX8NREGNHITNGCCkCSFni/vutV0W8Cq04I+yT5oIkEn7gZJGS2+G4Mkuurp/4abVl8RH9W3V2SEJm 0TV60UhA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUQcl-007Q6F-Qg; Thu, 08 Apr 2021 09:06:53 +0000 Received: from mga09.intel.com ([134.134.136.24]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lUQca-007Q3u-SJ for hostap@lists.infradead.org; Thu, 08 Apr 2021 09:06:43 +0000 IronPort-SDR: bw64JT+XCBe2k42zCiBtaC8mIP3aWkup9ffhH4JZr3HOMXDv57CTRCZZl3uB/wZkrWTe6BmfMF R9QuifxynxyQ== X-IronPort-AV: E=McAfee;i="6000,8403,9947"; a="193609764" X-IronPort-AV: E=Sophos;i="5.82,205,1613462400"; d="scan'208";a="193609764" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2021 02:06:36 -0700 IronPort-SDR: F7O4NAb4uCREIEeRLwPgGm6mJbPLz0vjnsOn1s67olnxD9+xml3iUoevvPatrW0m6OcSy4YxOr nxS1jLYxYVug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,205,1613462400"; d="scan'208";a="441676004" Received: from jed01615.jer.intel.com ([10.12.217.51]) by fmsmga004.fm.intel.com with ESMTP; 08 Apr 2021 02:06:34 -0700 From: Ilan Peer To: hostap@lists.infradead.org Cc: Ilan Peer Subject: [PATCH 1/5] PASN: Derive KDK only when required Date: Thu, 8 Apr 2021 12:06:20 +0300 Message-Id: <20210408090624.9490-1-ilan.peer@intel.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210408_100641_265183_7F03FB7D X-CRM114-Status: GOOD ( 13.06 ) X-Spam-Score: -2.3 (--) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When a PTK derivation is done as part of PASN authentication flow, a KDK derivation should be done iff higher layer protocol is supported by both parties. Fix the code accordingly, so KDK would be derived iff both sides support Secure LTF. Content analysis details: (-2.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [134.134.136.24 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [134.134.136.24 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When a PTK derivation is done as part of PASN authentication flow, a KDK derivation should be done iff higher layer protocol is supported by both parties. Fix the code accordingly, so KDK would be derived iff both sides support Secure LTF. Signed-off-by: Ilan Peer --- src/ap/ieee802_11.c | 15 +++++++++++++-- src/ap/sta_info.h | 1 + wpa_supplicant/pasn_supplicant.c | 15 ++++++++++++++- wpa_supplicant/wpa_supplicant_i.h | 1 + 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index 877d03e3aa..e4dd2b4b3f 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -2646,7 +2646,7 @@ static void pasn_fils_auth_resp(struct hostapd_data *hapd, wpabuf_head(pasn->secret), wpabuf_len(pasn->secret), &sta->pasn->ptk, sta->pasn->akmp, - sta->pasn->cipher, WPA_KDK_MAX_LEN); + sta->pasn->cipher, sta->pasn->kdk_len); if (ret) { wpa_printf(MSG_DEBUG, "PASN: FILS: Failed to derive PTK"); goto fail; @@ -2883,7 +2883,7 @@ pasn_derive_keys(struct hostapd_data *hapd, struct sta_info *sta, ret = pasn_pmk_to_ptk(pmk, pmk_len, sta->addr, hapd->own_addr, wpabuf_head(secret), wpabuf_len(secret), &sta->pasn->ptk, sta->pasn->akmp, - sta->pasn->cipher, WPA_KDK_MAX_LEN); + sta->pasn->cipher, sta->pasn->kdk_len); if (ret) { wpa_printf(MSG_DEBUG, "PASN: Failed to derive PTK"); return -1; @@ -3151,6 +3151,17 @@ static void handle_auth_pasn_1(struct hostapd_data *hapd, struct sta_info *sta, sta->pasn->akmp = rsn_data.key_mgmt; sta->pasn->cipher = rsn_data.pairwise_cipher; + if (hapd->conf->force_kdk_derivation || + ((hapd->iface->drv_flags2 & WPA_DRIVER_FLAGS2_SEC_LTF) && + elems.rsnxe && elems.rsnxe_len >= 2 && + (WPA_GET_LE16(elems.rsnxe) & BIT(WLAN_RSNX_CAPAB_SECURE_LTF)))) { + sta->pasn->kdk_len = WPA_KDK_MAX_LEN; + } else { + sta->pasn->kdk_len = 0; + } + + wpa_printf(MSG_DEBUG, "PASN: kdk_len=%zu", sta->pasn->kdk_len); + if (!elems.pasn_params || !elems.pasn_params_len) { wpa_printf(MSG_DEBUG, "PASN: No PASN Parameters element found"); diff --git a/src/ap/sta_info.h b/src/ap/sta_info.h index efa48e7e3d..27e72f9a01 100644 --- a/src/ap/sta_info.h +++ b/src/ap/sta_info.h @@ -88,6 +88,7 @@ struct pasn_data { u16 group; u8 trans_seq; u8 wrapped_data_format; + size_t kdk_len; u8 hash[SHA384_MAC_LEN]; struct wpa_ptk ptk; diff --git a/wpa_supplicant/pasn_supplicant.c b/wpa_supplicant/pasn_supplicant.c index 53ba21c5a8..c0db686dfe 100644 --- a/wpa_supplicant/pasn_supplicant.c +++ b/wpa_supplicant/pasn_supplicant.c @@ -1052,6 +1052,19 @@ static int wpas_pasn_start(struct wpa_supplicant *wpa_s, const u8 *bssid, pasn->cipher = cipher; pasn->group = group; pasn->freq = freq; + + if (wpa_s->conf->force_kdk_derivation || + (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_SEC_LTF && + beacon_rsnxe && beacon_rsnxe_len >= 4 && + (WPA_GET_LE16(beacon_rsnxe + 2) & + BIT(WLAN_RSNX_CAPAB_SECURE_LTF)))) { + pasn->kdk_len = WPA_KDK_MAX_LEN; + } else { + pasn->kdk_len = 0; + } + + wpa_printf(MSG_DEBUG, "PASN: kdk_len=%zu", pasn->kdk_len); + os_memcpy(pasn->bssid, bssid, ETH_ALEN); wpa_printf(MSG_DEBUG, @@ -1480,7 +1493,7 @@ int wpas_pasn_auth_rx(struct wpa_supplicant *wpa_s, wpa_s->own_addr, pasn->bssid, wpabuf_head(secret), wpabuf_len(secret), &pasn->ptk, pasn->akmp, pasn->cipher, - WPA_KDK_MAX_LEN); + pasn->kdk_len); if (ret) { wpa_printf(MSG_DEBUG, "PASN: Failed to derive PTK"); goto fail; diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 8813ddb710..49007cfc2e 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -539,6 +539,7 @@ struct wpas_pasn { int cipher; u16 group; int freq; + size_t kdk_len; u8 trans_seq; u8 status;