/* this structure holds optional OOB data for remote device */
typedef struct {
- RawAddress bdaddr; /* peer bdaddr */
- bt_out_of_band_data_t oob_data;
+ RawAddress bdaddr; /* peer bdaddr */
+ tBT_TRANSPORT transport; /* BR/EDR or LE */
+ int data_present; /* What type(s) of OOB Data present */
+ bt_oob_data_t p192_data; /* P192 Data or empty */
+ bt_oob_data_t p256_data; /* P256 Data or empty */
} btif_dm_oob_cb_t;
typedef struct { unsigned int manufact_id; } skip_sdp_entry_t;
* data
*
******************************************************************************/
-void btif_dm_create_bond_out_of_band(const RawAddress bd_addr, int transport,
- const bt_out_of_band_data_t oob_data) {
+void btif_dm_create_bond_out_of_band(const RawAddress bd_addr,
+ tBT_TRANSPORT transport,
+ const bt_oob_data_t p192_data,
+ const bt_oob_data_t p256_data) {
+ bt_oob_data_t empty_data;
+ memset(&empty_data, 0, sizeof(empty_data));
+
oob_cb.bdaddr = bd_addr;
- memcpy(&oob_cb.oob_data, &oob_data, sizeof(bt_out_of_band_data_t));
+ oob_cb.transport = transport;
+ oob_cb.data_present = (int)BTM_OOB_NONE;
+ if (memcmp(&p192_data, &empty_data, sizeof(p192_data)) != 0) {
+ memcpy(&oob_cb.p192_data, &p192_data, sizeof(bt_oob_data_t));
+ oob_cb.data_present = (int)BTM_OOB_PRESENT_192;
+ }
+ if (memcmp(&p256_data, &empty_data, sizeof(p256_data)) != 0) {
+ memcpy(&oob_cb.p256_data, &p256_data, sizeof(bt_oob_data_t));
+ if (oob_cb.data_present == (int)BTM_OOB_PRESENT_192) {
+ oob_cb.data_present = (int)BTM_OOB_PRESENT_192_AND_256;
+ } else {
+ oob_cb.data_present = (int)BTM_OOB_PRESENT_256;
+ }
+ }
uint8_t empty[] = {0, 0, 0, 0, 0, 0, 0};
- // If LE Bluetooth Device Address is provided, use provided address type
- // value.
- if (memcmp(oob_data.le_bt_dev_addr, empty, 7) != 0) {
- /* byte no 7 is address type in LE Bluetooth Address OOB data */
- tBLE_ADDR_TYPE address_type =
- static_cast<tBLE_ADDR_TYPE>(oob_data.le_bt_dev_addr[6]);
- if (address_type == BLE_ADDR_PUBLIC || address_type == BLE_ADDR_RANDOM) {
- // bd_addr->address is already reversed, so use it instead of
- // oob_data->le_bt_dev_addr
- BTM_SecAddBleDevice(bd_addr, BT_DEVICE_TYPE_BLE, address_type);
- }
+ // TODO(181889116): Upgrade to support p256 (for now we just ignore P256)
+ // because the controllers do not yet support it.
+ switch (transport) {
+ case BT_TRANSPORT_BR_EDR:
+ // TODO(182162589): Flesh out classic impl in legacy BTMSec
+ // Nothing to do yet, but not an error
+ break;
+ case BT_TRANSPORT_LE:
+ // If we have an address, lets get the type
+ if (memcmp(p192_data.address, empty, 7) != 0) {
+ /* byte no 7 is address type in LE Bluetooth Address OOB data */
+ tBLE_ADDR_TYPE address_type =
+ static_cast<tBLE_ADDR_TYPE>(p192_data.address[6]);
+ if (address_type == BLE_ADDR_PUBLIC ||
+ address_type == BLE_ADDR_RANDOM) {
+ // bd_addr->address is already reversed, so use it instead of
+ // oob_data->address
+ BTM_SecAddBleDevice(bd_addr, BT_DEVICE_TYPE_BLE, address_type);
+ }
+ }
+ break;
+ default:
+ LOG_ERROR("Invalid transport: %d", transport);
+ return;
}
BTIF_TRACE_EVENT("%s: bd_addr=%s, transport=%d", __func__,
* Description Initiate bonding with the specified device
*
******************************************************************************/
-
void btif_dm_cancel_bond(const RawAddress bd_addr) {
BTIF_TRACE_EVENT("%s: bd_addr=%s", __func__, bd_addr.ToString().c_str());
}
void btif_dm_set_oob_for_io_req(tBTM_OOB_DATA* p_has_oob_data) {
- if (is_empty_128bit(oob_cb.oob_data.c192)) {
+ if (is_empty_128bit(oob_cb.p192_data.c)) {
*p_has_oob_data = false;
} else {
*p_has_oob_data = true;
void btif_dm_set_oob_for_le_io_req(const RawAddress& bd_addr,
tBTM_OOB_DATA* p_has_oob_data,
tBTM_LE_AUTH_REQ* p_auth_req) {
- if (!is_empty_128bit(oob_cb.oob_data.le_sc_c) &&
- !is_empty_128bit(oob_cb.oob_data.le_sc_r)) {
+ if (!is_empty_128bit(oob_cb.p192_data.c) &&
+ !is_empty_128bit(oob_cb.p192_data.r)) {
/* We have LE SC OOB data */
/* make sure OOB data is for this particular device */
BTIF_TRACE_WARNING("%s: remote address didn't match OOB data address",
__func__);
}
- } else if (!is_empty_128bit(oob_cb.oob_data.sm_tk)) {
+ } else if (!is_empty_128bit(oob_cb.p192_data.sm_tk)) {
/* We have security manager TK */
/* make sure OOB data is for this particular device */
osi_property_get("service.brcm.bt.oob", prop_oob, "3");
BTIF_TRACE_DEBUG("%s: prop_oob = %s", __func__, prop_oob);
if (prop_oob[0] != '3') {
- if (is_empty_128bit(oob_cb.oob_data.c192)) {
+ if (is_empty_128bit(oob_cb.p192_data.c)) {
BTIF_TRACE_DEBUG("%s: read OOB, call BTA_DmLocalOob()", __func__);
BTA_DmLocalOob();
}
const char* path = NULL;
char prop_oob[PROPERTY_VALUE_MAX];
BTIF_TRACE_DEBUG("%s: valid=%d", __func__, valid);
- if (is_empty_128bit(oob_cb.oob_data.c192) && valid) {
+ if (is_empty_128bit(oob_cb.p192_data.c) && valid) {
BTIF_TRACE_DEBUG("save local OOB data in memory");
- memcpy(oob_cb.oob_data.c192, c.data(), OCTET16_LEN);
- memcpy(oob_cb.oob_data.r192, r.data(), OCTET16_LEN);
+ memcpy(oob_cb.p192_data.c, c.data(), OCTET16_LEN);
+ memcpy(oob_cb.p192_data.r, r.data(), OCTET16_LEN);
osi_property_get("service.brcm.bt.oob", prop_oob, "3");
BTIF_TRACE_DEBUG("%s: prop_oob = %s", __func__, prop_oob);
if (prop_oob[0] == '1')
* btif_dm_set_oob_for_le_io_req, but check here again. If it's not present
* do nothing, pairing will timeout.
*/
- if (is_empty_128bit(oob_cb.oob_data.sm_tk)) {
+ if (is_empty_128bit(oob_cb.p192_data.sm_tk)) {
return;
}
pairing_cb.is_le_only = true;
pairing_cb.is_le_nc = false;
- BTM_BleOobDataReply(req_oob_type->bd_addr, 0, 16, oob_cb.oob_data.sm_tk);
+ BTM_BleOobDataReply(req_oob_type->bd_addr, 0, 16, oob_cb.p192_data.sm_tk);
}
static void btif_dm_ble_sc_oob_req_evt(tBTA_DM_SP_RMT_OOB* req_oob_type) {
* btif_dm_set_oob_for_le_io_req, but check here again. If it's not present
* do nothing, pairing will timeout.
*/
- if (is_empty_128bit(oob_cb.oob_data.le_sc_c) &&
- is_empty_128bit(oob_cb.oob_data.le_sc_r)) {
+ if (is_empty_128bit(oob_cb.p192_data.c) &&
+ is_empty_128bit(oob_cb.p192_data.r)) {
BTIF_TRACE_WARNING("%s: LE SC OOB data is empty", __func__);
return;
}
true; // TODO: we can derive classic pairing from this one
pairing_cb.is_le_nc = false;
- BTM_BleSecureConnectionOobDataReply(
- req_oob_type->bd_addr, oob_cb.oob_data.le_sc_c, oob_cb.oob_data.le_sc_r);
+ BTM_BleSecureConnectionOobDataReply(req_oob_type->bd_addr, oob_cb.p192_data.c,
+ oob_cb.p192_data.r);
}
void btif_dm_update_ble_remote_properties(const RawAddress& bd_addr,
void* val;
} bt_property_t;
-/** Bluetooth Out Of Band data for bonding */
+/** Represents the actual Out of Band data itself */
typedef struct {
- uint8_t le_bt_dev_addr[7]; /* LE Bluetooth Device Address */
- uint8_t c192[16]; /* Simple Pairing Hash C-192 */
- uint8_t r192[16]; /* Simple Pairing Randomizer R-192 */
- uint8_t c256[16]; /* Simple Pairing Hash C-256 */
- uint8_t r256[16]; /* Simple Pairing Randomizer R-256 */
- uint8_t sm_tk[16]; /* Security Manager TK Value */
- uint8_t le_sc_c[16]; /* LE Secure Connections Confirmation Value */
- uint8_t le_sc_r[16]; /* LE Secure Connections Random Value */
-} bt_out_of_band_data_t;
+ // Both
+ uint8_t address[7]; /* Bluetooth Device Address (6) plus Address Type (1) */
+ uint8_t c[16]; /* Simple Pairing Hash C-192/256 (Classic or LE) */
+ uint8_t r[16]; /* Simple Pairing Randomizer R-192/256 (Classic or LE) */
+ uint8_t device_name[256]; /* Name of the device */
+
+ // Classic
+ uint8_t oob_data_length[2]; /* Classic only data Length. Value includes this
+ in length */
+ uint8_t class_of_device[2]; /* Class of Device (Classic or LE) */
+
+ // LE
+ uint8_t le_device_role; /* Supported and preferred role of device */
+ uint8_t sm_tk[16]; /* Security Manager TK Value (LE Only) */
+ uint8_t le_flags; /* LE Flags for discoverability and features */
+ uint8_t le_appearance[2]; /* For the appearance of the device */
+} bt_oob_data_t;
+
+/** Bundle that can contain 1 or both of P192 and P256 */
+// typedef struct {
+// uint8_t address[7]; /* Bluetooth Device Address (6) plus Address Type
+// (1) */ bt_oob_data_t p192_data; /* P192 Data or NULL */ bt_oob_data_t
+// p256_data; /* P256 Data or NULL */
+//} bt_oob_data_bundle_t;
/** Bluetooth Device Type */
typedef enum {
BT_DEVICE_DEVTYPE_BLE,
BT_DEVICE_DEVTYPE_DUAL
} bt_device_type_t;
+
/** Bluetooth Bond state */
typedef enum {
BT_BOND_STATE_NONE,
/** Create Bluetooth Bond using out of band data */
int (*create_bond_out_of_band)(const RawAddress* bd_addr, int transport,
- const bt_out_of_band_data_t* oob_data);
+ const bt_oob_data_t* p192_data,
+ const bt_oob_data_t* p256_data);
/** Remove Bond */
int (*remove_bond)(const RawAddress* bd_addr);