Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7F96C61DA4 for ; Tue, 14 Feb 2023 10:08:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232242AbjBNKI1 (ORCPT ); Tue, 14 Feb 2023 05:08:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232207AbjBNKIZ (ORCPT ); Tue, 14 Feb 2023 05:08:25 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2F96DBE8 for ; Tue, 14 Feb 2023 02:08:03 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id o8so14165333pls.11 for ; Tue, 14 Feb 2023 02:08:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=in-reply-to:from:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=9ABlJGEa6mi+HtIqW8oOiyZLtE3TpCDqDg3gm4bCgRQ=; b=GAUAOHkX7oWjo0oGQ8qOlQ5ZK5RexqO8PvMokAJyo1+MughU75y1HMPTVqXc/6OWSp x0B2L4Qd6Bg5gNb2KWQofYLVJVFd0E9tKaHoh+0Ll4IqxwW7JAOKUMJY0jFjYA7IQSPT 5QgOKc101+VnVrEASbZ+Ng7Vvuo6dLAZsryw4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9ABlJGEa6mi+HtIqW8oOiyZLtE3TpCDqDg3gm4bCgRQ=; b=Tpc5Hlsnud2l+etyA9mCPpWC04NI4H/0qp85/tJSPWsAmCbf6bT6VoXmwtTRT0JW6C 17V7MryHJi0Ci2nMyuQ2uUXfP8e3+qiRXCyPRCnF7mwBJc57G61O7Ocze5MbIDSCVvTB AyruOPxXA7Z41GDd1mhollKWLv7YxP6blDXbA4duJQsC6u3T88iTu4BQmQTiDv+xc869 rkosc9O/TTjHHjFlFVyBAXAAUi5rbG+qCu0Zme+ChDgytCRUPoqJyv5ovamAPjVQ8p6V oa6hYfiUE8AMhHyroMNqoynix+ZCqNlma6UeHNWTXYzWv7fmgHz9Ka67OQPd+aIsKRZc J9JQ== X-Gm-Message-State: AO0yUKWvfAWq78N3lWHWIhOkvgzrMv1fk7uXa2RtwuODck7A0xSC/3Li j+Ad43huUxWlg+EauAlWU9o5Mw== X-Google-Smtp-Source: AK7set9JywPOnggdXTn0yp81dKrSXy+5NJedSUDe2cDba3m23mi2JM53uEOvsVjAHvr/0Cix9UrJlA== X-Received: by 2002:a17:903:110c:b0:19a:96f0:a8de with SMTP id n12-20020a170903110c00b0019a96f0a8demr2186968plh.5.1676369281776; Tue, 14 Feb 2023 02:08:01 -0800 (PST) Received: from [10.176.68.61] ([192.19.148.250]) by smtp.gmail.com with ESMTPSA id ix11-20020a170902f80b00b0019926c7757asm5605668plb.289.2023.02.14.02.07.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Feb 2023 02:08:00 -0800 (PST) Message-ID: Date: Tue, 14 Feb 2023 11:07:55 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH] brcmfmac: cfg80211: Use WSEC to set SAE password To: Hector Martin , Arend van Spriel , Franky Lin , Hante Meuleman , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Double Lo Cc: Sven Peter , Alyssa Rosenzweig , Linus Walleij , asahi@lists.linux.dev, linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, SHA-cyfmac-dev-list@infineon.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230214093319.21077-1-marcan@marcan.st> From: Arend van Spriel In-Reply-To: <20230214093319.21077-1-marcan@marcan.st> Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="0000000000009260ee05f4a623c6" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --0000000000009260ee05f4a623c6 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit + Double Lo On 2/14/2023 10:33 AM, Hector Martin wrote: > Using the WSEC command instead of sae_password seems to be the supported > mechanism on newer firmware, and also how the brcmdhd driver does it. The SAE code in brcmfmac was added by Cypress/Infineon. For my BCA devices that did not work, but this change should be verified on Cypress hardware. Regards, Arend > Signed-off-by: Hector Martin > --- > Note: must be applied after: > > [PATCH 06/10] brcmfmac: cfg80211: Pass the PMK in binary instead of hex > > Since that is reviewed and this isn't yet, I expect that will go in > first anyway. > > .../broadcom/brcm80211/brcmfmac/cfg80211.c | 46 ++++++++----------- > .../broadcom/brcm80211/brcmfmac/fwil_types.h | 2 +- > 2 files changed, 20 insertions(+), 28 deletions(-) > > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > index 18e6699d4024..e4690d56e7c3 100644 > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > @@ -1682,52 +1682,44 @@ static u16 brcmf_map_fw_linkdown_reason(const struct brcmf_event_msg *e) > return reason; > } > > -static int brcmf_set_pmk(struct brcmf_if *ifp, const u8 *pmk_data, u16 pmk_len) > +static int brcmf_set_wsec(struct brcmf_if *ifp, const u8 *key, u16 key_len, u16 flags) > { > struct brcmf_pub *drvr = ifp->drvr; > struct brcmf_wsec_pmk_le pmk; > int err; > > + if (key_len > sizeof(pmk.key)) { > + bphy_err(drvr, "key must be less than %zu bytes\n", > + sizeof(pmk.key)); > + return -EINVAL; > + } > + > memset(&pmk, 0, sizeof(pmk)); > > - /* pass pmk directly */ > - pmk.key_len = cpu_to_le16(pmk_len); > - pmk.flags = cpu_to_le16(0); > - memcpy(pmk.key, pmk_data, pmk_len); > + /* pass key material directly */ > + pmk.key_len = cpu_to_le16(key_len); > + pmk.flags = cpu_to_le16(flags); > + memcpy(pmk.key, key, key_len); > > - /* store psk in firmware */ > + /* store key material in firmware */ > err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_WSEC_PMK, > &pmk, sizeof(pmk)); > if (err < 0) > bphy_err(drvr, "failed to change PSK in firmware (len=%u)\n", > - pmk_len); > + key_len); > > return err; > } > > +static int brcmf_set_pmk(struct brcmf_if *ifp, const u8 *pmk_data, u16 pmk_len) > +{ > + return brcmf_set_wsec(ifp, pmk_data, pmk_len, 0); > +} > + > static int brcmf_set_sae_password(struct brcmf_if *ifp, const u8 *pwd_data, > u16 pwd_len) > { > - struct brcmf_pub *drvr = ifp->drvr; > - struct brcmf_wsec_sae_pwd_le sae_pwd; > - int err; > - > - if (pwd_len > BRCMF_WSEC_MAX_SAE_PASSWORD_LEN) { > - bphy_err(drvr, "sae_password must be less than %d\n", > - BRCMF_WSEC_MAX_SAE_PASSWORD_LEN); > - return -EINVAL; > - } > - > - sae_pwd.key_len = cpu_to_le16(pwd_len); > - memcpy(sae_pwd.key, pwd_data, pwd_len); > - > - err = brcmf_fil_iovar_data_set(ifp, "sae_password", &sae_pwd, > - sizeof(sae_pwd)); > - if (err < 0) > - bphy_err(drvr, "failed to set SAE password in firmware (len=%u)\n", > - pwd_len); > - > - return err; > + return brcmf_set_wsec(ifp, pwd_data, pwd_len, BRCMF_WSEC_PASSPHRASE); > } > > static void brcmf_link_down(struct brcmf_cfg80211_vif *vif, u16 reason, > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h > index 792adaf880b4..3ba90878c47d 100644 > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h > @@ -574,7 +574,7 @@ struct brcmf_wsec_key_le { > struct brcmf_wsec_pmk_le { > __le16 key_len; > __le16 flags; > - u8 key[2 * BRCMF_WSEC_MAX_PSK_LEN + 1]; > + u8 key[BRCMF_WSEC_MAX_SAE_PASSWORD_LEN]; > }; > > /** --0000000000009260ee05f4a623c6 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIIQdwYJKoZIhvcNAQcCoIIQaDCCEGQCAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGg gg3OMIIFDTCCA/WgAwIBAgIQeEqpED+lv77edQixNJMdADANBgkqhkiG9w0BAQsFADBMMSAwHgYD VQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UE AxMKR2xvYmFsU2lnbjAeFw0yMDA5MTYwMDAwMDBaFw0yODA5MTYwMDAwMDBaMFsxCzAJBgNVBAYT AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMTEwLwYDVQQDEyhHbG9iYWxTaWduIEdDQyBS MyBQZXJzb25hbFNpZ24gMiBDQSAyMDIwMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA vbCmXCcsbZ/a0fRIQMBxp4gJnnyeneFYpEtNydrZZ+GeKSMdHiDgXD1UnRSIudKo+moQ6YlCOu4t rVWO/EiXfYnK7zeop26ry1RpKtogB7/O115zultAz64ydQYLe+a1e/czkAL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