Commit ec109113 authored by Marcel Holtmann's avatar Marcel Holtmann Committed by Johan Hedberg

Bluetooth: Add support for remote OOB input of P-256 data

The current management interface only allows to provide the remote
OOB input of P-192 data. This extends the command to also accept
P-256 data as well. To make this backwards compatible, the userspace
can decide to only provide P-192 data or the combined P-192 and P-256
data. It is also allowed to leave the P-192 data empty if userspace
only has the remote P-256 data.
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent 0798872e
...@@ -309,6 +309,14 @@ struct mgmt_cp_add_remote_oob_data { ...@@ -309,6 +309,14 @@ struct mgmt_cp_add_remote_oob_data {
__u8 randomizer[16]; __u8 randomizer[16];
} __packed; } __packed;
#define MGMT_ADD_REMOTE_OOB_DATA_SIZE (MGMT_ADDR_INFO_SIZE + 32) #define MGMT_ADD_REMOTE_OOB_DATA_SIZE (MGMT_ADDR_INFO_SIZE + 32)
struct mgmt_cp_add_remote_oob_ext_data {
struct mgmt_addr_info addr;
__u8 hash192[16];
__u8 randomizer192[16];
__u8 hash256[16];
__u8 randomizer256[16];
} __packed;
#define MGMT_ADD_REMOTE_OOB_EXT_DATA_SIZE (MGMT_ADDR_INFO_SIZE + 64)
#define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x0022 #define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x0022
struct mgmt_cp_remove_remote_oob_data { struct mgmt_cp_remove_remote_oob_data {
......
...@@ -3096,23 +3096,46 @@ static int read_local_oob_data(struct sock *sk, struct hci_dev *hdev, ...@@ -3096,23 +3096,46 @@ static int read_local_oob_data(struct sock *sk, struct hci_dev *hdev,
static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev, static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev,
void *data, u16 len) void *data, u16 len)
{ {
struct mgmt_cp_add_remote_oob_data *cp = data;
u8 status;
int err; int err;
BT_DBG("%s ", hdev->name); BT_DBG("%s ", hdev->name);
hci_dev_lock(hdev); hci_dev_lock(hdev);
err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr, cp->hash, if (len == MGMT_ADD_REMOTE_OOB_DATA_SIZE) {
cp->randomizer); struct mgmt_cp_add_remote_oob_data *cp = data;
if (err < 0) u8 status;
status = MGMT_STATUS_FAILED;
else
status = MGMT_STATUS_SUCCESS;
err = cmd_complete(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA, status, err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr,
&cp->addr, sizeof(cp->addr)); cp->hash, cp->randomizer);
if (err < 0)
status = MGMT_STATUS_FAILED;
else
status = MGMT_STATUS_SUCCESS;
err = cmd_complete(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA,
status, &cp->addr, sizeof(cp->addr));
} else if (len == MGMT_ADD_REMOTE_OOB_EXT_DATA_SIZE) {
struct mgmt_cp_add_remote_oob_ext_data *cp = data;
u8 status;
err = hci_add_remote_oob_ext_data(hdev, &cp->addr.bdaddr,
cp->hash192,
cp->randomizer192,
cp->hash256,
cp->randomizer256);
if (err < 0)
status = MGMT_STATUS_FAILED;
else
status = MGMT_STATUS_SUCCESS;
err = cmd_complete(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA,
status, &cp->addr, sizeof(cp->addr));
} else {
BT_ERR("add_remote_oob_data: invalid length of %u bytes", len);
err = cmd_status(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA,
MGMT_STATUS_INVALID_PARAMS);
}
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
return err; return err;
...@@ -4202,7 +4225,7 @@ static const struct mgmt_handler { ...@@ -4202,7 +4225,7 @@ static const struct mgmt_handler {
{ user_passkey_reply, false, MGMT_USER_PASSKEY_REPLY_SIZE }, { user_passkey_reply, false, MGMT_USER_PASSKEY_REPLY_SIZE },
{ user_passkey_neg_reply, false, MGMT_USER_PASSKEY_NEG_REPLY_SIZE }, { user_passkey_neg_reply, false, MGMT_USER_PASSKEY_NEG_REPLY_SIZE },
{ read_local_oob_data, false, MGMT_READ_LOCAL_OOB_DATA_SIZE }, { read_local_oob_data, false, MGMT_READ_LOCAL_OOB_DATA_SIZE },
{ add_remote_oob_data, false, MGMT_ADD_REMOTE_OOB_DATA_SIZE }, { add_remote_oob_data, true, MGMT_ADD_REMOTE_OOB_DATA_SIZE },
{ remove_remote_oob_data, false, MGMT_REMOVE_REMOTE_OOB_DATA_SIZE }, { remove_remote_oob_data, false, MGMT_REMOVE_REMOTE_OOB_DATA_SIZE },
{ start_discovery, false, MGMT_START_DISCOVERY_SIZE }, { start_discovery, false, MGMT_START_DISCOVERY_SIZE },
{ stop_discovery, false, MGMT_STOP_DISCOVERY_SIZE }, { stop_discovery, false, MGMT_STOP_DISCOVERY_SIZE },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment