提交 3f706b72 编写于 作者: J Johan Hedberg 提交者: Gustavo Padovan

Bluetooth: Refactor valid LTK data testing into its own function

This patch refactors valid LTK data testing into its own function. This
will help keep the code readable since there are several tests still
missing that need to be done on the LTK data.
Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
Acked-by: NMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: NGustavo Padovan <gustavo.padovan@collabora.co.uk>
上级 54ad6d8a
...@@ -2701,6 +2701,13 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev, ...@@ -2701,6 +2701,13 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
return err; return err;
} }
static bool ltk_is_valid(struct mgmt_ltk_info *key)
{
if (key->master != 0x00 && key->master != 0x01)
return false;
return true;
}
static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
void *cp_data, u16 len) void *cp_data, u16 len)
{ {
...@@ -2724,7 +2731,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, ...@@ -2724,7 +2731,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
for (i = 0; i < key_count; i++) { for (i = 0; i < key_count; i++) {
struct mgmt_ltk_info *key = &cp->keys[i]; struct mgmt_ltk_info *key = &cp->keys[i];
if (key->master != 0x00 && key->master != 0x01) if (!ltk_is_valid(key))
return cmd_status(sk, hdev->id, return cmd_status(sk, hdev->id,
MGMT_OP_LOAD_LONG_TERM_KEYS, MGMT_OP_LOAD_LONG_TERM_KEYS,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册