Loading system/bta/dm/bta_dm_sec.cc +0 −26 Original line number Diff line number Diff line Loading @@ -127,32 +127,6 @@ void bta_dm_remote_key_missing(const RawAddress bd_addr) { } } /******************************************************************************* * * Function bta_dm_add_device * * Description This function adds a Link Key to an security database entry. * It is normally called during host startup to restore all * required information stored in the NVRAM. ******************************************************************************/ void bta_dm_add_device(std::unique_ptr<tBTA_DM_API_ADD_DEVICE> msg) { DEV_CLASS dc = kDevClassEmpty; LinkKey* p_lc = NULL; /* If not all zeros, the device class has been specified */ if (msg->dc_known) dc = msg->dc; if (msg->link_key_known) p_lc = &msg->link_key; auto add_result = get_btm_client_interface().security.BTM_SecAddDevice( msg->bd_addr, dc, msg->bd_name, nullptr, p_lc, msg->key_type, msg->pin_length); if (!add_result) { log::error("Error adding device:{}", ADDRESS_TO_LOGGABLE_CSTR(msg->bd_addr)); } } /** Bonds with peer device */ void bta_dm_bond(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type, tBT_TRANSPORT transport, tBT_DEVICE_TYPE device_type) { Loading system/bta/dm/bta_dm_sec_api.cc +8 −23 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include "stack/btm/btm_sec.h" #include "stack/include/bt_octets.h" #include "stack/include/btm_ble_sec_api.h" #include "stack/include/btm_client_interface.h" #include "stack/include/main_thread.h" #include "types/raw_address.h" Loading Loading @@ -134,35 +135,19 @@ void BTA_DmConfirm(const RawAddress& bd_addr, bool accept) { * Description This function adds a device to the security database list of * peer device * * * Returns void * ******************************************************************************/ void BTA_DmAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, const LinkKey& link_key, uint8_t key_type, uint8_t pin_length) { std::unique_ptr<tBTA_DM_API_ADD_DEVICE> msg = std::make_unique<tBTA_DM_API_ADD_DEVICE>(); msg->bd_addr = bd_addr; msg->link_key_known = true; msg->key_type = key_type; msg->link_key = link_key; /* Load device class if specified */ if (dev_class != kDevClassEmpty) { msg->dc_known = true; msg->dc = dev_class; } memset(msg->bd_name, 0, BD_NAME_LEN + 1); msg->pin_length = pin_length; void BTA_DmAddDevice(RawAddress bd_addr, DEV_CLASS dev_class, LinkKey link_key, uint8_t key_type, uint8_t pin_length) { auto closure = base::Bind(get_btm_client_interface().security.BTM_SecAddDevice, bd_addr, dev_class, link_key, key_type, pin_length); if (IS_FLAG_ENABLED(synchronous_bta_sec)) { bta_dm_add_device(std::move(msg)); closure.Run(); } else { do_in_main_thread(FROM_HERE, base::Bind(bta_dm_add_device, base::Passed(&msg))); do_in_main_thread(FROM_HERE, closure); } } Loading system/bta/dm/bta_dm_sec_int.h +0 −12 Original line number Diff line number Diff line Loading @@ -44,17 +44,6 @@ typedef struct { bool accept; } tBTA_DM_CI_RMT_OOB; typedef struct { RawAddress bd_addr; DEV_CLASS dc; LinkKey link_key; uint8_t key_type; bool link_key_known; bool dc_known; BD_NAME bd_name; uint8_t pin_length; } tBTA_DM_API_ADD_DEVICE; typedef struct { tBTA_DM_SEC_CBACK* p_sec_cback; tBTA_DM_SEC_CBACK* p_sec_sirk_cback; Loading @@ -80,7 +69,6 @@ void bta_dm_add_ble_device(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TYPE dev_type); void bta_dm_add_blekey(const RawAddress& bd_addr, tBTA_LE_KEY_VALUE blekey, tBTM_LE_KEY_TYPE key_type); void bta_dm_add_device(std::unique_ptr<tBTA_DM_API_ADD_DEVICE> msg); void bta_dm_ble_config_local_privacy(bool privacy_enable); void bta_dm_ble_confirm_reply(const RawAddress& bd_addr, bool accept); void bta_dm_ble_passkey_reply(const RawAddress& bd_addr, bool accept, Loading system/bta/include/bta_sec_api.h +2 −3 Original line number Diff line number Diff line Loading @@ -337,9 +337,8 @@ void BTA_DmConfirm(const RawAddress& bd_addr, bool accept); * Returns void * ******************************************************************************/ void BTA_DmAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, const LinkKey& link_key, uint8_t key_type, uint8_t pin_length); void BTA_DmAddDevice(RawAddress bd_addr, DEV_CLASS dev_class, LinkKey link_key, uint8_t key_type, uint8_t pin_length); /******************************************************************************* * Loading system/stack/btm/btm_dev.cc +24 −43 Original line number Diff line number Diff line Loading @@ -77,26 +77,20 @@ static void wipe_secrets_and_remove(tBTM_SEC_DEV_REC* p_dev_rec) { * * Parameters: bd_addr - BD address of the peer * dev_class - Device Class * bd_name - Name of the peer device. NULL if unknown. * features - Remote device's features (up to 3 pages). * NULL if not known * link_key - Connection link key. NULL if unknown. * * Returns true if added OK, else false * Returns void * ******************************************************************************/ bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, const BD_NAME& bd_name, uint8_t* features, LinkKey* p_link_key, uint8_t key_type, uint8_t pin_length) { void BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, LinkKey link_key, uint8_t key_type, uint8_t pin_length) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr); if (!p_dev_rec) { p_dev_rec = btm_sec_allocate_dev_rec(); log::debug( "Caching new record from config file device:{} link_key_type:{:x} " "name:{}", ADDRESS_TO_LOGGABLE_STR(bd_addr), key_type, reinterpret_cast<const char*>(bd_name)); log::info( "Caching new record from config file device: {}, dev_class: 0x{:02x}, " "link_key_type: 0x{:x}", ADDRESS_TO_LOGGABLE_STR(bd_addr), fmt::join(dev_class, ""), key_type); p_dev_rec->bd_addr = bd_addr; p_dev_rec->hci_handle = BTM_GetHCIConnHandle(bd_addr, BT_TRANSPORT_BR_EDR); Loading @@ -105,9 +99,10 @@ bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, /* update conn params, use default value for background connection params */ memset(&p_dev_rec->conn_params, 0xff, sizeof(tBTM_LE_CONN_PRAMS)); } else { log::debug( "Caching existing record from config file device:{} link_key_type:{:x}", ADDRESS_TO_LOGGABLE_STR(bd_addr), key_type); log::info( "Caching existing record from config file device: {}, dev_class: " "0x{:02x}, link_key_type: 0x{:x}", ADDRESS_TO_LOGGABLE_STR(bd_addr), fmt::join(dev_class, ""), key_type); /* "Bump" timestamp for existing record */ p_dev_rec->timestamp = btm_sec_cb.dev_rec_count++; Loading @@ -125,19 +120,8 @@ bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, memset(p_dev_rec->sec_bd_name, 0, sizeof(BD_NAME)); if (bd_name && bd_name[0]) { log::debug(" Remote name known for device:{} name:{}", ADDRESS_TO_LOGGABLE_CSTR(bd_addr), reinterpret_cast<const char*>(bd_name)); p_dev_rec->sec_rec.sec_flags |= BTM_SEC_NAME_KNOWN; bd_name_copy(p_dev_rec->sec_bd_name, bd_name); } if (p_link_key) { log::debug(" Link key known for device:{}", ADDRESS_TO_LOGGABLE_CSTR(bd_addr)); p_dev_rec->sec_rec.sec_flags |= BTM_SEC_LINK_KEY_KNOWN; p_dev_rec->sec_rec.link_key = *p_link_key; p_dev_rec->sec_rec.link_key = link_key; p_dev_rec->sec_rec.link_key_type = key_type; p_dev_rec->sec_rec.pin_code_length = pin_length; Loading @@ -152,12 +136,9 @@ bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, p_dev_rec->sec_rec.sec_flags |= BTM_SEC_16_DIGIT_PIN_AUTHED | BTM_SEC_LINK_KEY_AUTHED; } } p_dev_rec->sec_rec.rmt_io_caps = BTM_IO_CAP_OUT; p_dev_rec->device_type |= BT_DEVICE_TYPE_BREDR; return true; } /** Removes the device from acceptlist */ Loading Loading
system/bta/dm/bta_dm_sec.cc +0 −26 Original line number Diff line number Diff line Loading @@ -127,32 +127,6 @@ void bta_dm_remote_key_missing(const RawAddress bd_addr) { } } /******************************************************************************* * * Function bta_dm_add_device * * Description This function adds a Link Key to an security database entry. * It is normally called during host startup to restore all * required information stored in the NVRAM. ******************************************************************************/ void bta_dm_add_device(std::unique_ptr<tBTA_DM_API_ADD_DEVICE> msg) { DEV_CLASS dc = kDevClassEmpty; LinkKey* p_lc = NULL; /* If not all zeros, the device class has been specified */ if (msg->dc_known) dc = msg->dc; if (msg->link_key_known) p_lc = &msg->link_key; auto add_result = get_btm_client_interface().security.BTM_SecAddDevice( msg->bd_addr, dc, msg->bd_name, nullptr, p_lc, msg->key_type, msg->pin_length); if (!add_result) { log::error("Error adding device:{}", ADDRESS_TO_LOGGABLE_CSTR(msg->bd_addr)); } } /** Bonds with peer device */ void bta_dm_bond(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type, tBT_TRANSPORT transport, tBT_DEVICE_TYPE device_type) { Loading
system/bta/dm/bta_dm_sec_api.cc +8 −23 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include "stack/btm/btm_sec.h" #include "stack/include/bt_octets.h" #include "stack/include/btm_ble_sec_api.h" #include "stack/include/btm_client_interface.h" #include "stack/include/main_thread.h" #include "types/raw_address.h" Loading Loading @@ -134,35 +135,19 @@ void BTA_DmConfirm(const RawAddress& bd_addr, bool accept) { * Description This function adds a device to the security database list of * peer device * * * Returns void * ******************************************************************************/ void BTA_DmAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, const LinkKey& link_key, uint8_t key_type, uint8_t pin_length) { std::unique_ptr<tBTA_DM_API_ADD_DEVICE> msg = std::make_unique<tBTA_DM_API_ADD_DEVICE>(); msg->bd_addr = bd_addr; msg->link_key_known = true; msg->key_type = key_type; msg->link_key = link_key; /* Load device class if specified */ if (dev_class != kDevClassEmpty) { msg->dc_known = true; msg->dc = dev_class; } memset(msg->bd_name, 0, BD_NAME_LEN + 1); msg->pin_length = pin_length; void BTA_DmAddDevice(RawAddress bd_addr, DEV_CLASS dev_class, LinkKey link_key, uint8_t key_type, uint8_t pin_length) { auto closure = base::Bind(get_btm_client_interface().security.BTM_SecAddDevice, bd_addr, dev_class, link_key, key_type, pin_length); if (IS_FLAG_ENABLED(synchronous_bta_sec)) { bta_dm_add_device(std::move(msg)); closure.Run(); } else { do_in_main_thread(FROM_HERE, base::Bind(bta_dm_add_device, base::Passed(&msg))); do_in_main_thread(FROM_HERE, closure); } } Loading
system/bta/dm/bta_dm_sec_int.h +0 −12 Original line number Diff line number Diff line Loading @@ -44,17 +44,6 @@ typedef struct { bool accept; } tBTA_DM_CI_RMT_OOB; typedef struct { RawAddress bd_addr; DEV_CLASS dc; LinkKey link_key; uint8_t key_type; bool link_key_known; bool dc_known; BD_NAME bd_name; uint8_t pin_length; } tBTA_DM_API_ADD_DEVICE; typedef struct { tBTA_DM_SEC_CBACK* p_sec_cback; tBTA_DM_SEC_CBACK* p_sec_sirk_cback; Loading @@ -80,7 +69,6 @@ void bta_dm_add_ble_device(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TYPE dev_type); void bta_dm_add_blekey(const RawAddress& bd_addr, tBTA_LE_KEY_VALUE blekey, tBTM_LE_KEY_TYPE key_type); void bta_dm_add_device(std::unique_ptr<tBTA_DM_API_ADD_DEVICE> msg); void bta_dm_ble_config_local_privacy(bool privacy_enable); void bta_dm_ble_confirm_reply(const RawAddress& bd_addr, bool accept); void bta_dm_ble_passkey_reply(const RawAddress& bd_addr, bool accept, Loading
system/bta/include/bta_sec_api.h +2 −3 Original line number Diff line number Diff line Loading @@ -337,9 +337,8 @@ void BTA_DmConfirm(const RawAddress& bd_addr, bool accept); * Returns void * ******************************************************************************/ void BTA_DmAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, const LinkKey& link_key, uint8_t key_type, uint8_t pin_length); void BTA_DmAddDevice(RawAddress bd_addr, DEV_CLASS dev_class, LinkKey link_key, uint8_t key_type, uint8_t pin_length); /******************************************************************************* * Loading
system/stack/btm/btm_dev.cc +24 −43 Original line number Diff line number Diff line Loading @@ -77,26 +77,20 @@ static void wipe_secrets_and_remove(tBTM_SEC_DEV_REC* p_dev_rec) { * * Parameters: bd_addr - BD address of the peer * dev_class - Device Class * bd_name - Name of the peer device. NULL if unknown. * features - Remote device's features (up to 3 pages). * NULL if not known * link_key - Connection link key. NULL if unknown. * * Returns true if added OK, else false * Returns void * ******************************************************************************/ bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, const BD_NAME& bd_name, uint8_t* features, LinkKey* p_link_key, uint8_t key_type, uint8_t pin_length) { void BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, LinkKey link_key, uint8_t key_type, uint8_t pin_length) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr); if (!p_dev_rec) { p_dev_rec = btm_sec_allocate_dev_rec(); log::debug( "Caching new record from config file device:{} link_key_type:{:x} " "name:{}", ADDRESS_TO_LOGGABLE_STR(bd_addr), key_type, reinterpret_cast<const char*>(bd_name)); log::info( "Caching new record from config file device: {}, dev_class: 0x{:02x}, " "link_key_type: 0x{:x}", ADDRESS_TO_LOGGABLE_STR(bd_addr), fmt::join(dev_class, ""), key_type); p_dev_rec->bd_addr = bd_addr; p_dev_rec->hci_handle = BTM_GetHCIConnHandle(bd_addr, BT_TRANSPORT_BR_EDR); Loading @@ -105,9 +99,10 @@ bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, /* update conn params, use default value for background connection params */ memset(&p_dev_rec->conn_params, 0xff, sizeof(tBTM_LE_CONN_PRAMS)); } else { log::debug( "Caching existing record from config file device:{} link_key_type:{:x}", ADDRESS_TO_LOGGABLE_STR(bd_addr), key_type); log::info( "Caching existing record from config file device: {}, dev_class: " "0x{:02x}, link_key_type: 0x{:x}", ADDRESS_TO_LOGGABLE_STR(bd_addr), fmt::join(dev_class, ""), key_type); /* "Bump" timestamp for existing record */ p_dev_rec->timestamp = btm_sec_cb.dev_rec_count++; Loading @@ -125,19 +120,8 @@ bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, memset(p_dev_rec->sec_bd_name, 0, sizeof(BD_NAME)); if (bd_name && bd_name[0]) { log::debug(" Remote name known for device:{} name:{}", ADDRESS_TO_LOGGABLE_CSTR(bd_addr), reinterpret_cast<const char*>(bd_name)); p_dev_rec->sec_rec.sec_flags |= BTM_SEC_NAME_KNOWN; bd_name_copy(p_dev_rec->sec_bd_name, bd_name); } if (p_link_key) { log::debug(" Link key known for device:{}", ADDRESS_TO_LOGGABLE_CSTR(bd_addr)); p_dev_rec->sec_rec.sec_flags |= BTM_SEC_LINK_KEY_KNOWN; p_dev_rec->sec_rec.link_key = *p_link_key; p_dev_rec->sec_rec.link_key = link_key; p_dev_rec->sec_rec.link_key_type = key_type; p_dev_rec->sec_rec.pin_code_length = pin_length; Loading @@ -152,12 +136,9 @@ bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, p_dev_rec->sec_rec.sec_flags |= BTM_SEC_16_DIGIT_PIN_AUTHED | BTM_SEC_LINK_KEY_AUTHED; } } p_dev_rec->sec_rec.rmt_io_caps = BTM_IO_CAP_OUT; p_dev_rec->device_type |= BT_DEVICE_TYPE_BREDR; return true; } /** Removes the device from acceptlist */ Loading