]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
Bluetooth: Add support for Read Local Simple Pairing Options
authorMarcel Holtmann <marcel@holtmann.org>
Fri, 3 Apr 2020 19:44:04 +0000 (21:44 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Sun, 5 Apr 2020 11:53:11 +0000 (14:53 +0300)
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 <marcel@holtmann.org>
Reviewed-by: Alain Michaud <alainm@chromium.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
include/net/bluetooth/hci.h
include/net/bluetooth/hci_core.h
net/bluetooth/hci_core.c
net/bluetooth/hci_event.c

index 9ff2f7a9e131c83549818750f4ad67a6ec0eec13..086a9e9d5d030bfcf48b5b748f61eb2e4c991f48 100644 (file)
@@ -1275,6 +1275,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;
index 3cb0f82d0c83346f258e8eef632de489fd6287d9..2f3275f1d1c4a3075e2b18c0b2451f700ba032f1 100644 (file)
@@ -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;
index ef0ee3a3d9eddbff82f183b47b804d029cc083d0..589c4085499cac2db83d756e73038a14047fe8e5 100644 (file)
@@ -827,6 +827,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);
index 2803beaa1c44ea7ee2aca7c64c1334d2130f97ef..51e6461f0b71213c707de264b7986d6aa5de0f8d 100644 (file)
@@ -747,6 +747,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)
 {
@@ -3343,6 +3360,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;