From patchwork Sun Jan 28 12:45:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Otcheretianski X-Patchwork-Id: 866805 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ffovOX3i"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zTnsJ1rT6z9s0g for ; Sun, 28 Jan 2018 20:48:52 +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=HALzGZLgvLojCKP1X8dCLRrWJ2RGHkPfDwVt82WGNj4=; b=ffovOX3ij7mephfxUtBKl4cJKM 2vu9gPBRVcz5P6XS1eVjunj8ZASBpd7rXAfxssuWcuWp8sNiusVkxghKsgn9TlE9fU7+yQW+Cny8i Fcuvd9AX7sSbeaGW1fAoVOjk+rQuH88diISO3iyQRGV9RsomW4qb1oKcsAyYZbYxnAnXHzD5ieJLV J+5l6v18KmEGLn2YB1dlK0tkZwO+1qqcF0MuEA06fu7mw2luau8XpRvuSzgNC71/drSCTIrth6JF7 rrPf6xngE9/XA2K+Uynv7N6Ue7cc3WJG0Z54xOf4hCi6IlaVfMEuMWqR8vTy8DWG3qfGD2Ma3+6ot rsL7eYqQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1efjZo-0008P2-Ms; Sun, 28 Jan 2018 09:48:40 +0000 Received: from mga05.intel.com ([192.55.52.43]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1efjZb-0008EK-64 for hostap@lists.infradead.org; Sun, 28 Jan 2018 09:48:30 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jan 2018 01:48:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,426,1511856000"; d="scan'208";a="14046306" Received: from unknown (HELO andrei-XPS-12-9Q33.ger.corp.intel.com) ([10.12.217.183]) by orsmga006.jf.intel.com with ESMTP; 28 Jan 2018 01:48:17 -0800 From: Andrei Otcheretianski To: hostap@lists.infradead.org Subject: [PATCH 4/7] nl80211: Add API to set the PMK to the driver Date: Sun, 28 Jan 2018 14:45:34 +0200 Message-Id: <1517143537-7441-5-git-send-email-andrei.otcheretianski@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517143537-7441-1-git-send-email-andrei.otcheretianski@intel.com> References: <1517143537-7441-1-git-send-email-andrei.otcheretianski@intel.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [192.55.52.43 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Avraham Stern MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Avraham Stern Add support for setting the PMK to the driver. This is used for drivers that support 4 Way handshake offload. Signed-off-by: Avraham Stern --- src/drivers/driver_nl80211.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 3267b0e..b67f4a7 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -2781,6 +2781,40 @@ static int issue_key_mgmt_set_key(struct wpa_driver_nl80211_data *drv, } #endif /* CONFIG_DRIVER_NL80211_QCA */ +static int wpa_driver_nl80211_set_pmk(struct wpa_driver_nl80211_data *drv, + const u8 *key, size_t key_len, + const u8 *addr) +{ + struct nl_msg *msg = NULL; + int ret; + + /* + * If the authenticator address is not set, assume it is + * the current BSSID. + */ + if (!addr && drv->associated) + addr = drv->bssid; + else if (!addr) + return -1; + + msg = nl80211_drv_msg(drv, 0, NL80211_CMD_SET_PMK); + if (!msg || + nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr) || + nla_put(msg, NL80211_ATTR_PMK, key_len, key)) { + nl80211_nlmsg_clear(msg); + nlmsg_free(msg); + return -ENOBUFS; + } + + ret = send_and_recv_msgs(drv, msg, NULL, (void *) -1); + if (ret) { + wpa_printf(MSG_DEBUG, + "nl80211: Set PMK failed: ret=%d (%s)", + ret, strerror(-ret)); + } + + return ret; +} static int wpa_driver_nl80211_set_key(const char *ifname, struct i802_bss *bss, enum wpa_alg alg, const u8 *addr, @@ -2820,6 +2854,10 @@ static int wpa_driver_nl80211_set_key(const char *ifname, struct i802_bss *bss, } #endif /* CONFIG_DRIVER_NL80211_QCA */ + if (alg == WPA_ALG_PMK && + (drv->capa.flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE)) + return wpa_driver_nl80211_set_pmk(drv, key, key_len, addr); + if (alg == WPA_ALG_NONE) { msg = nl80211_ifindex_msg(drv, ifindex, 0, NL80211_CMD_DEL_KEY); if (!msg)