Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3496082ybb; Tue, 31 Mar 2020 06:30:06 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtsugpIGjjOatKcCINZtKc3MoaT29lSmOL1mlDhMq+8ePspdRqjkTwZKuZcTqf6b//5gcla X-Received: by 2002:a4a:950b:: with SMTP id m11mr13551573ooi.83.1585661405867; Tue, 31 Mar 2020 06:30:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585661405; cv=none; d=google.com; s=arc-20160816; b=uNMHpHx4BlExkHYhjsbFjHdpu9JxiANu8uDPYB+Aiyl/GE5c9zupQPxsSgV42eFDjg 0fjGsEO7gbUvusGxO8uKl/AVKlGzTa+9J8GREkGkxNlCE5Ht9oZnXv0RwO6Jq8XM/1zp sdYhg1wWkuo+y+w+TExxNMWx9YpLj9QgNiTCoElqcwB5FmJnzd951XmM//th8ruedw3M omZmvXB5Qb8HNhWt2Iz9fmBZzsqzfqiUdpiBufkcugOR7ffvzt6dzgEoDFJe7mcmjXFo dcYvbMBBt7lMXLi430MwVR90i5zf2sS+dZEOVq7jXAB8km6kstlwzxdjKN58jNXHl0hP lNVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=c4nScbvXhKa8vVpLgLEIF1gBg3tgKfV2jDa0wi/mNTk=; b=TLysz3vJAmBy5ZaEd+zlil6Gack5FThR3TputtdOD2LYpUWUd3d3FYS+bWq7fR8pgW DKSHPeKyfJzHLirdyR3CHAlOxWZtZUq6dOMUpXomn3ZRJNitz0pltLmaf/j0nx0GJwLF mvKaPjwP1SZIalkhNKVuNg+0XR0jLapbM0qfeXNoMqH/S5IWPCJrDvn4PZThXTOwBK9w LWwI8WOTFQBrsCwH48GqBWzpEYxJlYumtGE/mVqoM0JBtBxkY00F1qoqHxEHKk8jLFhA 7kPDLblw+AJO+U8vOCI8v4P4kVp8YsvHh8GjaIewyplDhVAAYL8r5DysSGHY2709uqis tIqw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w16si3219046otq.235.2020.03.31.06.29.33; Tue, 31 Mar 2020 06:30:05 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730358AbgCaN2g (ORCPT + 99 others); Tue, 31 Mar 2020 09:28:36 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:60934 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730216AbgCaN2g (ORCPT ); Tue, 31 Mar 2020 09:28:36 -0400 Received: from localhost.localdomain (p4FEFC5A7.dip0.t-ipconnect.de [79.239.197.167]) by mail.holtmann.org (Postfix) with ESMTPSA id 613F7CECCA for ; Tue, 31 Mar 2020 15:38:08 +0200 (CEST) From: Marcel Holtmann To: linux-bluetooth@vger.kernel.org Subject: [PATCH] Bluetooth: Add support for Read Local Simple Pairing Options Date: Tue, 31 Mar 2020 15:28:31 +0200 Message-Id: <20200331132831.443518-1-marcel@holtmann.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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