Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3805880ybb; Tue, 31 Mar 2020 12:20:02 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvRhMRC35wQSi8nbtnt2F12aoDAF7epp9F6COZCW89R/JLuWbTFKtoDcsoM4zecgcNoaufh X-Received: by 2002:a9d:560b:: with SMTP id e11mr13139909oti.226.1585682401918; Tue, 31 Mar 2020 12:20:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585682401; cv=none; d=google.com; s=arc-20160816; b=FzluzX189zCDk3RB3xVZNKlhx6ws7dzgrm9Dsa8VuIhC7KXg9PbZzP1EY0i6hC3aGZ uR9rkN1Lt8nbhOfmyU2YPpzydwPdRzwST5aEWg/D4SPK7deX7kxr3NazDBd7HKiZol2Z BT1wxPCXb+kIj0uyPEq4H/zEGWtuHcVmkHNfcZUgnhB7oVHqh6oZXQYlWb6iFBNxMjvw gv06hlrxjq/6RldR/+w4SvMzbF9gKVZGsgJlheWlCDHknngWPmUdA00QbQp/vGmLZZC4 9GQpes/F0OuFYwyHdiuDjVJLchxkOyskW36T5uoPaF8IoP0KfnH1ZA+ZtP1agdF42Wrz 1qmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=y8b+fY+FSOhIQyquVtH2+ZFjRjsJrgUrVeSm/zV2Y8w=; b=So2XGbzGvYJOLMAgHDTEFnTgFk1QN8dQSYkiuKBqv2KQxeuv5udwc31BZQtYu1/mcf iC2R8QfpHXG8JUd5T0OSONwtK2nWKK8ndHltGouW8JtMYdTMa0iMUdXY/muTeoxj0biH DBZ7OtXBLlz8QLSxngwjOtWcXFv+FlrHVaW+RjCmLO1Hty+h2Rpp8KWOyaV/Vp0cQln7 CHynN0DHbO8UTDGuj2BJRz1bX8FZ0qYnF2UFq1jRJDWQaxrpvyxIzpO/0dwTJqWk4Oey l8CngqfJ4IOZAo3DCKAIcttPQFCMgxCGsNYB+Ws2jKHFL998+r85hAboNsAyZLb3Bufj vUXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UIs5M7yg; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t13si5576983otp.249.2020.03.31.12.19.35; Tue, 31 Mar 2020 12:20:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UIs5M7yg; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726315AbgCaTTV (ORCPT + 99 others); Tue, 31 Mar 2020 15:19:21 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:36266 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726295AbgCaTTU (ORCPT ); Tue, 31 Mar 2020 15:19:20 -0400 Received: by mail-lj1-f195.google.com with SMTP id b1so2668042ljp.3 for ; Tue, 31 Mar 2020 12:19:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=y8b+fY+FSOhIQyquVtH2+ZFjRjsJrgUrVeSm/zV2Y8w=; b=UIs5M7ygqRK67Ww+DhfEj7FEK3mJoDmLbYmOG91Q9EJbR0vYOQ1PmOOCLd7CRBeOQT jju06ncbVeDi84TVOt91mVnYvJUt680+AUfAWvjPbzsdaXlHgdWVXnntCowwefgxzn9h l9MuLypriLQ9QwWhZ+zLiOvO8vJnj+LqXJQHATWG/yIfYMjHKyrK+ZsPK9Dg1R/twJkP ku4UKoKqXrjgoVgV/nYB4W/j3LyVcFWQHfXEJ/ZDEzE9690qegv0HM1aVOqdriyQ+tSY 22EBJRPh91oa8EPrcJTErJ9F7TnMdRvLxepqMhcN7nYF8Pc2gNLT0k50+5eFnr2ZWhQd ltEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=y8b+fY+FSOhIQyquVtH2+ZFjRjsJrgUrVeSm/zV2Y8w=; b=tmU34JaKivlOm/HZX0vzorIlo7hSr9c4Sg6UYKvVmAg4msOICr/hG1VegwsB+krwKw hTodLnyy3WCE3/Y+Neu+tHH6+9w/pHJh7IjvodTl16HqulUQ1jLTVImiDRsvQLTdT+uw 0NcIVVMq0Rngbm/lJKBMiYVXnnzH0mmeo0Xw8vEevrhg2tbPFxZ5byOd5kBTn9X4jU4O UIHk/ZQPOQ/hZtZsFiUVb/h//17nt4epMK2lVVZ9J+8Pd2b5/SUDLprb+5DI+yTpKPWo QDup68UJ5lhI58o+EKzZoGI8bUC188Ode5eXnbxcRkVOHIdorklIHo7Nzeyy6/ANJ8G7 3VUQ== X-Gm-Message-State: AGi0PuY+qje9jeCrSf8IkPeYHMH/TM9Bv21OmPd8GfJ6RdWqBLc431f6 1eAXuV7mPAemx3vHZeZReqyvrWi1+n6JL/xvCaTGrMah X-Received: by 2002:a2e:99c9:: with SMTP id l9mr11633826ljj.79.1585682357722; Tue, 31 Mar 2020 12:19:17 -0700 (PDT) MIME-Version: 1.0 References: <20200331132831.443518-1-marcel@holtmann.org> In-Reply-To: <20200331132831.443518-1-marcel@holtmann.org> From: Alain Michaud Date: Tue, 31 Mar 2020 15:19:06 -0400 Message-ID: Subject: Re: [PATCH] Bluetooth: Add support for Read Local Simple Pairing Options To: Marcel Holtmann Cc: BlueZ Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Marcel, On Tue, Mar 31, 2020 at 9:28 AM Marcel Holtmann wrote: > > With the Read Local Simple Pairing Options command it is possible to > retrieve the support for max encryption key size supported by the > controller and also if the controller correctly verifies the ECDH public > key during pairing. > > Signed-off-by: Marcel Holtmann > --- > include/net/bluetooth/hci.h | 7 +++++++ > include/net/bluetooth/hci_core.h | 2 ++ > net/bluetooth/hci_core.c | 4 ++++ > net/bluetooth/hci_event.c | 21 +++++++++++++++++++++ > 4 files changed, 34 insertions(+) > > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h > index 5f60e135aeb6..a495964d5553 100644 > --- a/include/net/bluetooth/hci.h > +++ b/include/net/bluetooth/hci.h > @@ -1272,6 +1272,13 @@ struct hci_rp_read_data_block_size { > > #define HCI_OP_READ_LOCAL_CODECS 0x100b > > +#define HCI_OP_READ_LOCAL_PAIRING_OPTS 0x100c > +struct hci_rp_read_local_pairing_opts { > + __u8 status; > + __u8 pairing_opts; > + __u8 max_key_size; > +} __packed; > + > #define HCI_OP_READ_PAGE_SCAN_ACTIVITY 0x0c1b > struct hci_rp_read_page_scan_activity { > __u8 status; > diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h > index d4e28773d378..228b5021060c 100644 > --- a/include/net/bluetooth/hci_core.h > +++ b/include/net/bluetooth/hci_core.h > @@ -312,6 +312,8 @@ struct hci_dev { > __u16 conn_info_max_age; > __u16 auth_payload_timeout; > __u8 min_enc_key_size; > + __u8 max_enc_key_size; > + __u8 pairing_opts; > __u8 ssp_debug_mode; > __u8 hw_error_code; > __u32 clock; > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > index 2e7bc2da8371..331759878b3c 100644 > --- a/net/bluetooth/hci_core.c > +++ b/net/bluetooth/hci_core.c > @@ -826,6 +826,10 @@ static int hci_init4_req(struct hci_request *req, unsigned long opt) > if (hdev->commands[29] & 0x20) > hci_req_add(req, HCI_OP_READ_LOCAL_CODECS, 0, NULL); > > + /* Read local pairing options if the HCI command is supported */ > + if (hdev->commands[41] & 0x08) > + hci_req_add(req, HCI_OP_READ_LOCAL_PAIRING_OPTS, 0, NULL); > + > /* Get MWS transport configuration if the HCI command is supported */ > if (hdev->commands[30] & 0x08) > hci_req_add(req, HCI_OP_GET_MWS_TRANSPORT_CONFIG, 0, NULL); > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index 0a591be8b0ae..ca7a00e9312a 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -746,6 +746,23 @@ static void hci_cc_read_bd_addr(struct hci_dev *hdev, struct sk_buff *skb) > bacpy(&hdev->setup_addr, &rp->bdaddr); > } > > +static void hci_cc_read_local_pairing_opts(struct hci_dev *hdev, > + struct sk_buff *skb) > +{ > + struct hci_rp_read_local_pairing_opts *rp = (void *) skb->data; > + > + BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); > + > + if (rp->status) > + return; > + > + if (hci_dev_test_flag(hdev, HCI_SETUP) || > + hci_dev_test_flag(hdev, HCI_CONFIG)) { > + hdev->pairing_opts = rp->pairing_opts; > + hdev->max_enc_key_size = rp->max_key_size; > + } > +} > + > static void hci_cc_read_page_scan_activity(struct hci_dev *hdev, > struct sk_buff *skb) > { > @@ -3334,6 +3351,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb, > hci_cc_read_bd_addr(hdev, skb); > break; > > + case HCI_OP_READ_LOCAL_PAIRING_OPTS: > + hci_cc_read_local_pairing_opts(hdev, skb); > + break; > + > case HCI_OP_READ_PAGE_SCAN_ACTIVITY: > hci_cc_read_page_scan_activity(hdev, skb); > break; > -- > 2.25.1 > LGTM. Thanks, Alain