Skip to content

Commit

Permalink
Bluetooth: Allow Microsoft extension to indicate curve validation
Browse files Browse the repository at this point in the history
Some controllers don't support the Simple Pairing Options feature that
can indicate the support for P-192 and P-256 public key validation.
However they might support the Microsoft vendor extension that can
indicate the validiation capability as well.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
  • Loading branch information
holtmann committed Apr 8, 2021
1 parent ba29d03 commit a61d671
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ struct hci_dev {
#if IS_ENABLED(CONFIG_BT_MSFTEXT)
__u16 msft_opcode;
void *msft_data;
bool msft_curve_validity;
#endif

#if IS_ENABLED(CONFIG_BT_AOSPEXT)
Expand Down
5 changes: 4 additions & 1 deletion net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3730,8 +3730,11 @@ static int read_controller_cap(struct sock *sk, struct hci_dev *hdev,

/* When the Read Simple Pairing Options command is supported, then
* the remote public key validation is supported.
*
* Alternatively, when Microsoft extensions are available, they can
* indicate support for public key validation as well.
*/
if (hdev->commands[41] & 0x08)
if ((hdev->commands[41] & 0x08) || msft_curve_validity(hdev))
flags |= 0x01; /* Remote public key validation (BR/EDR) */

flags |= 0x02; /* Remote public key validation (LE) */
Expand Down
8 changes: 8 additions & 0 deletions net/bluetooth/msft.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ static bool read_supported_features(struct hci_dev *hdev,
msft->evt_prefix_len = rp->evt_prefix_len;
msft->features = __le64_to_cpu(rp->features);

if (msft->features & MSFT_FEATURE_MASK_CURVE_VALIDITY)
hdev->msft_curve_validity = true;

kfree_skb(skb);
return true;

Expand Down Expand Up @@ -605,3 +608,8 @@ int msft_set_filter_enable(struct hci_dev *hdev, bool enable)

return err;
}

bool msft_curve_validity(struct hci_dev *hdev)
{
return hdev->msft_curve_validity;
}
6 changes: 6 additions & 0 deletions net/bluetooth/msft.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ int msft_remove_monitor(struct hci_dev *hdev, struct adv_monitor *monitor,
u16 handle);
void msft_req_add_set_filter_enable(struct hci_request *req, bool enable);
int msft_set_filter_enable(struct hci_dev *hdev, bool enable);
bool msft_curve_validity(struct hci_dev *hdev);

#else

Expand Down Expand Up @@ -54,4 +55,9 @@ static inline int msft_set_filter_enable(struct hci_dev *hdev, bool enable)
return -EOPNOTSUPP;
}

static inline bool msft_curve_validity(struct hci_dev *hdev)
{
return false;
}

#endif

0 comments on commit a61d671

Please sign in to comment.