diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2014-01-10 05:07:30 -0500 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2014-02-13 02:51:34 -0500 |
commit | ec1091131f9b53ea280247b5a01a617ce87d399e (patch) | |
tree | 9b43a55637035e553420499d26c5ede5c18facae | |
parent | 0798872ef1ad6433362faca1d16a31ad7ad72638 (diff) |
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: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r-- | include/net/bluetooth/mgmt.h | 8 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 45 |
2 files changed, 42 insertions, 11 deletions
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 036ddc7dc7ed..e19049fb6c46 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h | |||
@@ -309,6 +309,14 @@ struct mgmt_cp_add_remote_oob_data { | |||
309 | __u8 randomizer[16]; | 309 | __u8 randomizer[16]; |
310 | } __packed; | 310 | } __packed; |
311 | #define MGMT_ADD_REMOTE_OOB_DATA_SIZE (MGMT_ADDR_INFO_SIZE + 32) | 311 | #define MGMT_ADD_REMOTE_OOB_DATA_SIZE (MGMT_ADDR_INFO_SIZE + 32) |
312 | struct mgmt_cp_add_remote_oob_ext_data { | ||
313 | struct mgmt_addr_info addr; | ||
314 | __u8 hash192[16]; | ||
315 | __u8 randomizer192[16]; | ||
316 | __u8 hash256[16]; | ||
317 | __u8 randomizer256[16]; | ||
318 | } __packed; | ||
319 | #define MGMT_ADD_REMOTE_OOB_EXT_DATA_SIZE (MGMT_ADDR_INFO_SIZE + 64) | ||
312 | 320 | ||
313 | #define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x0022 | 321 | #define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x0022 |
314 | struct mgmt_cp_remove_remote_oob_data { | 322 | struct mgmt_cp_remove_remote_oob_data { |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index bbe30c983492..4b6034fcc902 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -3096,23 +3096,46 @@ unlock: | |||
3096 | static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev, | 3096 | static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev, |
3097 | void *data, u16 len) | 3097 | void *data, u16 len) |
3098 | { | 3098 | { |
3099 | struct mgmt_cp_add_remote_oob_data *cp = data; | ||
3100 | u8 status; | ||
3101 | int err; | 3099 | int err; |
3102 | 3100 | ||
3103 | BT_DBG("%s ", hdev->name); | 3101 | BT_DBG("%s ", hdev->name); |
3104 | 3102 | ||
3105 | hci_dev_lock(hdev); | 3103 | hci_dev_lock(hdev); |
3106 | 3104 | ||
3107 | err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr, cp->hash, | 3105 | if (len == MGMT_ADD_REMOTE_OOB_DATA_SIZE) { |
3108 | cp->randomizer); | 3106 | struct mgmt_cp_add_remote_oob_data *cp = data; |
3109 | if (err < 0) | 3107 | u8 status; |
3110 | status = MGMT_STATUS_FAILED; | ||
3111 | else | ||
3112 | status = MGMT_STATUS_SUCCESS; | ||
3113 | 3108 | ||
3114 | err = cmd_complete(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA, status, | 3109 | err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr, |
3115 | &cp->addr, sizeof(cp->addr)); | 3110 | cp->hash, cp->randomizer); |
3111 | if (err < 0) | ||
3112 | status = MGMT_STATUS_FAILED; | ||
3113 | else | ||
3114 | status = MGMT_STATUS_SUCCESS; | ||
3115 | |||
3116 | err = cmd_complete(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA, | ||
3117 | status, &cp->addr, sizeof(cp->addr)); | ||
3118 | } else if (len == MGMT_ADD_REMOTE_OOB_EXT_DATA_SIZE) { | ||
3119 | struct mgmt_cp_add_remote_oob_ext_data *cp = data; | ||
3120 | u8 status; | ||
3121 | |||
3122 | err = hci_add_remote_oob_ext_data(hdev, &cp->addr.bdaddr, | ||
3123 | cp->hash192, | ||
3124 | cp->randomizer192, | ||
3125 | cp->hash256, | ||
3126 | cp->randomizer256); | ||
3127 | if (err < 0) | ||
3128 | status = MGMT_STATUS_FAILED; | ||
3129 | else | ||
3130 | status = MGMT_STATUS_SUCCESS; | ||
3131 | |||
3132 | err = cmd_complete(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA, | ||
3133 | status, &cp->addr, sizeof(cp->addr)); | ||
3134 | } else { | ||
3135 | BT_ERR("add_remote_oob_data: invalid length of %u bytes", len); | ||
3136 | err = cmd_status(sk, hdev->id, MGMT_OP_ADD_REMOTE_OOB_DATA, | ||
3137 | MGMT_STATUS_INVALID_PARAMS); | ||
3138 | } | ||
3116 | 3139 | ||
3117 | hci_dev_unlock(hdev); | 3140 | hci_dev_unlock(hdev); |
3118 | return err; | 3141 | return err; |
@@ -4202,7 +4225,7 @@ static const struct mgmt_handler { | |||
4202 | { user_passkey_reply, false, MGMT_USER_PASSKEY_REPLY_SIZE }, | 4225 | { user_passkey_reply, false, MGMT_USER_PASSKEY_REPLY_SIZE }, |
4203 | { user_passkey_neg_reply, false, MGMT_USER_PASSKEY_NEG_REPLY_SIZE }, | 4226 | { user_passkey_neg_reply, false, MGMT_USER_PASSKEY_NEG_REPLY_SIZE }, |
4204 | { read_local_oob_data, false, MGMT_READ_LOCAL_OOB_DATA_SIZE }, | 4227 | { read_local_oob_data, false, MGMT_READ_LOCAL_OOB_DATA_SIZE }, |
4205 | { add_remote_oob_data, false, MGMT_ADD_REMOTE_OOB_DATA_SIZE }, | 4228 | { add_remote_oob_data, true, MGMT_ADD_REMOTE_OOB_DATA_SIZE }, |
4206 | { remove_remote_oob_data, false, MGMT_REMOVE_REMOTE_OOB_DATA_SIZE }, | 4229 | { remove_remote_oob_data, false, MGMT_REMOVE_REMOTE_OOB_DATA_SIZE }, |
4207 | { start_discovery, false, MGMT_START_DISCOVERY_SIZE }, | 4230 | { start_discovery, false, MGMT_START_DISCOVERY_SIZE }, |
4208 | { stop_discovery, false, MGMT_STOP_DISCOVERY_SIZE }, | 4231 | { stop_discovery, false, MGMT_STOP_DISCOVERY_SIZE }, |