Loading system/bta/dm/bta_dm_act.cc +67 −15 Original line number Diff line number Diff line Loading @@ -35,9 +35,11 @@ #include "bt_types.h" #include "bta_api.h" #include "bta_dm_api.h" #include "bta_dm_ci.h" #include "bta_dm_co.h" #include "bta_dm_int.h" #include "bta_sys.h" #include "btif_dm.h" #include "btif_storage.h" #include "btm_api.h" #include "btm_int.h" Loading Loading @@ -373,7 +375,7 @@ void BTA_dm_on_hw_on() { /* load BLE local information: ID keys, ER if available */ Octet16 er; bta_dm_co_ble_load_local_keys(&key_mask, &er, &id_key); btif_dm_get_ble_local_keys(&key_mask, &er, &id_key); if (key_mask & BTA_BLE_LOCAL_KEY_TYPE_ER) { BTM_BleLoadLocalKeys(BTA_BLE_LOCAL_KEY_TYPE_ER, (tBTM_BLE_LOCAL_KEYS*)&er); Loading Loading @@ -2357,12 +2359,14 @@ static uint8_t bta_dm_sp_cback(tBTM_SP_EVT event, tBTM_SP_EVT_DATA* p_data) { APPL_TRACE_EVENT("bta_dm_sp_cback: %d", event); if (!bta_dm_cb.p_sec_cback) return BTM_NOT_AUTHORIZED; bool sp_rmt_result = false; /* TODO_SP */ switch (event) { case BTM_SP_IO_REQ_EVT: if (btm_local_io_caps != BTM_IO_CAP_NONE) { /* translate auth_req */ bta_dm_co_io_req(p_data->io_req.bd_addr, &p_data->io_req.io_cap, btif_dm_set_oob_for_io_req(&p_data->io_req.oob_data); btif_dm_proc_io_req(p_data->io_req.bd_addr, &p_data->io_req.io_cap, &p_data->io_req.oob_data, &p_data->io_req.auth_req, p_data->io_req.is_orig); } Loading @@ -2371,7 +2375,7 @@ static uint8_t bta_dm_sp_cback(tBTM_SP_EVT event, tBTM_SP_EVT_DATA* p_data) { break; case BTM_SP_IO_RSP_EVT: if (btm_local_io_caps != BTM_IO_CAP_NONE) { bta_dm_co_io_rsp(p_data->io_rsp.bd_addr, p_data->io_rsp.io_cap, btif_dm_proc_io_rsp(p_data->io_rsp.bd_addr, p_data->io_rsp.io_cap, p_data->io_rsp.oob_data, p_data->io_rsp.auth_req); } break; Loading Loading @@ -2459,13 +2463,23 @@ static uint8_t bta_dm_sp_cback(tBTM_SP_EVT event, tBTM_SP_EVT_DATA* p_data) { break; case BTM_SP_LOC_OOB_EVT: bta_dm_co_loc_oob((bool)(p_data->loc_oob.status == BTM_SUCCESS), #ifdef BTIF_DM_OOB_TEST btif_dm_proc_loc_oob((bool)(p_data->loc_oob.status == BTM_SUCCESS), p_data->loc_oob.c, p_data->loc_oob.r); #endif break; case BTM_SP_RMT_OOB_EVT: bta_dm_co_rmt_oob(p_data->rmt_oob.bd_addr); case BTM_SP_RMT_OOB_EVT: { Octet16 c; Octet16 r; sp_rmt_result = false; #ifdef BTIF_DM_OOB_TEST sp_rmt_result = btif_dm_proc_rmt_oob(p_data->rmt_oob.bd_addr, &c, &r); #endif BTIF_TRACE_DEBUG("bta_dm_ci_rmt_oob: result=%d", sp_rmt_result); bta_dm_ci_rmt_oob(sp_rmt_result, p_data->rmt_oob.bd_addr, c, r); break; } default: status = BTM_NOT_AUTHORIZED; Loading Loading @@ -3566,6 +3580,46 @@ static void bta_dm_observe_cmpl_cb(void* p_result) { } } static void ble_io_req(const RawAddress& bd_addr, tBTM_IO_CAP* p_io_cap, tBTM_OOB_DATA* p_oob_data, tBTM_LE_AUTH_REQ* p_auth_req, uint8_t* p_max_key_size, tBTA_LE_KEY_TYPE* p_init_key, tBTA_LE_KEY_TYPE* p_resp_key) { bte_appl_cfg.ble_io_cap = btif_storage_get_local_io_caps_ble(); /* Retrieve the properties from file system if possible */ tBTE_APPL_CFG nv_config; if (btif_dm_get_smp_config(&nv_config)) bte_appl_cfg = nv_config; /* *p_auth_req by default is false for devices with NoInputNoOutput; true for * other devices. */ if (bte_appl_cfg.ble_auth_req) *p_auth_req = bte_appl_cfg.ble_auth_req | (bte_appl_cfg.ble_auth_req & 0x04) | ((*p_auth_req) & 0x04); /* if OOB is not supported, this call-out function does not need to do * anything * otherwise, look for the OOB data associated with the address and set * *p_oob_data accordingly. * If the answer can not be obtained right away, * set *p_oob_data to BTA_OOB_UNKNOWN and call bta_dm_ci_io_req() when the * answer is available. */ btif_dm_set_oob_for_le_io_req(bd_addr, p_oob_data, p_auth_req); if (bte_appl_cfg.ble_io_cap <= 4) *p_io_cap = bte_appl_cfg.ble_io_cap; if (bte_appl_cfg.ble_init_key <= BTM_BLE_INITIATOR_KEY_SIZE) *p_init_key = bte_appl_cfg.ble_init_key; if (bte_appl_cfg.ble_resp_key <= BTM_BLE_RESPONDER_KEY_SIZE) *p_resp_key = bte_appl_cfg.ble_resp_key; if (bte_appl_cfg.ble_max_key_size > 7 && bte_appl_cfg.ble_max_key_size <= 16) *p_max_key_size = bte_appl_cfg.ble_max_key_size; } /******************************************************************************* * * Function bta_dm_ble_smp_cback Loading @@ -3587,13 +3641,11 @@ static uint8_t bta_dm_ble_smp_cback(tBTM_LE_EVT event, const RawAddress& bda, memset(&sec_event, 0, sizeof(tBTA_DM_SEC)); switch (event) { case BTM_LE_IO_REQ_EVT: bta_dm_co_ble_io_req( bda, &p_data->io_req.io_cap, &p_data->io_req.oob_data, ble_io_req(bda, &p_data->io_req.io_cap, &p_data->io_req.oob_data, &p_data->io_req.auth_req, &p_data->io_req.max_key_size, &p_data->io_req.init_keys, &p_data->io_req.resp_keys); APPL_TRACE_EVENT("io mitm: %d oob_data:%d", p_data->io_req.auth_req, p_data->io_req.oob_data); break; case BTM_LE_SEC_REQUEST_EVT: Loading system/btif/co/bta_dm_co.cc +0 −208 Original line number Diff line number Diff line Loading @@ -57,211 +57,3 @@ bool bta_dm_co_get_compress_memory(UNUSED_ATTR tBTA_SYS_ID id, return true; } /******************************************************************************* * * Function bta_dm_co_io_req * * Description This callout function is executed by DM to get IO * capabilities of the local device for the Simple Pairing * process. * * Parameters bd_addr - The peer device * *p_io_cap - The local Input/Output capabilities * *p_oob_data - true, if OOB data is available for the peer * device. * *p_auth_req - true, if MITM protection is required. * * Returns void. * ******************************************************************************/ void bta_dm_co_io_req(UNUSED_ATTR const RawAddress& bd_addr, tBTM_IO_CAP* p_io_cap, tBTM_OOB_DATA* p_oob_data, tBTM_AUTH_REQ* p_auth_req, bool is_orig) { btif_dm_set_oob_for_io_req(p_oob_data); btif_dm_proc_io_req(bd_addr, p_io_cap, p_oob_data, p_auth_req, is_orig); BTIF_TRACE_DEBUG("bta_dm_co_io_req *p_oob_data = %d", *p_oob_data); BTIF_TRACE_DEBUG("bta_dm_co_io_req *p_io_cap = %d", *p_io_cap); BTIF_TRACE_DEBUG("bta_dm_co_io_req *p_auth_req = %d", *p_auth_req); BTIF_TRACE_DEBUG("bta_dm_co_io_req is_orig = %d", is_orig); } /******************************************************************************* * * Function bta_dm_co_io_rsp * * Description This callout function is executed by DM to report IO * capabilities of the peer device for the Simple Pairing * process. * * Parameters bd_addr - The peer device * io_cap - The remote Input/Output capabilities * oob_data - true, if OOB data is available for the peer * device. * auth_req - true, if MITM protection is required. * * Returns void. * ******************************************************************************/ void bta_dm_co_io_rsp(const RawAddress& bd_addr, tBTM_IO_CAP io_cap, tBTM_OOB_DATA oob_data, tBTM_AUTH_REQ auth_req) { btif_dm_proc_io_rsp(bd_addr, io_cap, oob_data, auth_req); } /******************************************************************************* * * Function bta_dm_co_loc_oob * * Description This callout function is executed by DM to report the OOB * data of the local device for the Simple Pairing process * * Parameters valid - true, if the local OOB data is retrieved from LM * c - Simple Pairing Hash C * r - Simple Pairing Randomnizer R * * Returns void. * ******************************************************************************/ void bta_dm_co_loc_oob(bool valid, const Octet16& c, const Octet16& r) { BTIF_TRACE_DEBUG("bta_dm_co_loc_oob, valid = %d", valid); #ifdef BTIF_DM_OOB_TEST btif_dm_proc_loc_oob(valid, c, r); #endif } /******************************************************************************* * * Function bta_dm_co_rmt_oob * * Description This callout function is executed by DM to request the OOB * data for the remote device for the Simple Pairing process * Need to call bta_dm_ci_rmt_oob() in response * * Parameters bd_addr - The peer device * * Returns void. * ******************************************************************************/ void bta_dm_co_rmt_oob(const RawAddress& bd_addr) { Octet16 c; Octet16 r; bool result = false; #ifdef BTIF_DM_OOB_TEST result = btif_dm_proc_rmt_oob(bd_addr, &c, &r); #endif BTIF_TRACE_DEBUG("bta_dm_co_rmt_oob: result=%d", result); bta_dm_ci_rmt_oob(result, bd_addr, c, r); } /******************************************************************************* * * Function bta_dm_co_le_io_key_req * * Description This callout function is executed by DM to get BLE key * information * before SMP pairing gets going. * * Parameters bd_addr - The peer device * *p_max_key_size - max key size local device supported. * *p_init_key - initiator keys. * *p_resp_key - responder keys. * * Returns void. * ******************************************************************************/ void bta_dm_co_le_io_key_req(UNUSED_ATTR const RawAddress& bd_addr, uint8_t* p_max_key_size, tBTA_LE_KEY_TYPE* p_init_key, tBTA_LE_KEY_TYPE* p_resp_key) { BTIF_TRACE_ERROR("##################################"); BTIF_TRACE_ERROR("bta_dm_co_le_io_key_req: only setting max size to 16"); BTIF_TRACE_ERROR("##################################"); *p_max_key_size = 16; *p_init_key = *p_resp_key = (BTA_LE_KEY_PENC | BTA_LE_KEY_PID | BTA_LE_KEY_PCSRK | BTA_LE_KEY_LENC | BTA_LE_KEY_LID | BTA_LE_KEY_LCSRK); } /******************************************************************************* * * Function bta_dm_co_ble_local_key_reload * * Description This callout function is to load the local BLE keys if * available on the device. * * Parameters none * * Returns void. * ******************************************************************************/ void bta_dm_co_ble_load_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK* p_key_mask, Octet16* p_er, tBTA_BLE_LOCAL_ID_KEYS* p_id_keys) { BTIF_TRACE_DEBUG("##################################"); BTIF_TRACE_DEBUG( "bta_dm_co_ble_load_local_keys: Load local keys if any are persisted"); BTIF_TRACE_DEBUG("##################################"); btif_dm_get_ble_local_keys(p_key_mask, p_er, p_id_keys); } /******************************************************************************* * * Function bta_dm_co_ble_io_req * * Description This callout function is executed by DM to get BLE IO * capabilities before SMP pairing gets going. * * Parameters bd_addr - The peer device * *p_io_cap - The local Input/Output capabilities * *p_oob_data - true, if OOB data is available for the peer * device. * *p_auth_req - Auth request setting (Bonding and MITM * required or not) * *p_max_key_size - max key size local device supported. * *p_init_key - initiator keys. * *p_resp_key - responder keys. * * Returns void. * ******************************************************************************/ void bta_dm_co_ble_io_req(const RawAddress& bd_addr, tBTM_IO_CAP* p_io_cap, tBTM_OOB_DATA* p_oob_data, tBTM_LE_AUTH_REQ* p_auth_req, uint8_t* p_max_key_size, tBTA_LE_KEY_TYPE* p_init_key, tBTA_LE_KEY_TYPE* p_resp_key) { bte_appl_cfg.ble_io_cap = btif_storage_get_local_io_caps_ble(); /* Retrieve the properties from file system if possible */ tBTE_APPL_CFG nv_config; if (btif_dm_get_smp_config(&nv_config)) bte_appl_cfg = nv_config; /* *p_auth_req by default is false for devices with NoInputNoOutput; true for * other devices. */ if (bte_appl_cfg.ble_auth_req) *p_auth_req = bte_appl_cfg.ble_auth_req | (bte_appl_cfg.ble_auth_req & 0x04) | ((*p_auth_req) & 0x04); /* if OOB is not supported, this call-out function does not need to do * anything * otherwise, look for the OOB data associated with the address and set * *p_oob_data accordingly. * If the answer can not be obtained right away, * set *p_oob_data to BTA_OOB_UNKNOWN and call bta_dm_ci_io_req() when the * answer is available. */ btif_dm_set_oob_for_le_io_req(bd_addr, p_oob_data, p_auth_req); if (bte_appl_cfg.ble_io_cap <= 4) *p_io_cap = bte_appl_cfg.ble_io_cap; if (bte_appl_cfg.ble_init_key <= BTM_BLE_INITIATOR_KEY_SIZE) *p_init_key = bte_appl_cfg.ble_init_key; if (bte_appl_cfg.ble_resp_key <= BTM_BLE_RESPONDER_KEY_SIZE) *p_resp_key = bte_appl_cfg.ble_resp_key; if (bte_appl_cfg.ble_max_key_size > 7 && bte_appl_cfg.ble_max_key_size <= 16) *p_max_key_size = bte_appl_cfg.ble_max_key_size; } Loading
system/bta/dm/bta_dm_act.cc +67 −15 Original line number Diff line number Diff line Loading @@ -35,9 +35,11 @@ #include "bt_types.h" #include "bta_api.h" #include "bta_dm_api.h" #include "bta_dm_ci.h" #include "bta_dm_co.h" #include "bta_dm_int.h" #include "bta_sys.h" #include "btif_dm.h" #include "btif_storage.h" #include "btm_api.h" #include "btm_int.h" Loading Loading @@ -373,7 +375,7 @@ void BTA_dm_on_hw_on() { /* load BLE local information: ID keys, ER if available */ Octet16 er; bta_dm_co_ble_load_local_keys(&key_mask, &er, &id_key); btif_dm_get_ble_local_keys(&key_mask, &er, &id_key); if (key_mask & BTA_BLE_LOCAL_KEY_TYPE_ER) { BTM_BleLoadLocalKeys(BTA_BLE_LOCAL_KEY_TYPE_ER, (tBTM_BLE_LOCAL_KEYS*)&er); Loading Loading @@ -2357,12 +2359,14 @@ static uint8_t bta_dm_sp_cback(tBTM_SP_EVT event, tBTM_SP_EVT_DATA* p_data) { APPL_TRACE_EVENT("bta_dm_sp_cback: %d", event); if (!bta_dm_cb.p_sec_cback) return BTM_NOT_AUTHORIZED; bool sp_rmt_result = false; /* TODO_SP */ switch (event) { case BTM_SP_IO_REQ_EVT: if (btm_local_io_caps != BTM_IO_CAP_NONE) { /* translate auth_req */ bta_dm_co_io_req(p_data->io_req.bd_addr, &p_data->io_req.io_cap, btif_dm_set_oob_for_io_req(&p_data->io_req.oob_data); btif_dm_proc_io_req(p_data->io_req.bd_addr, &p_data->io_req.io_cap, &p_data->io_req.oob_data, &p_data->io_req.auth_req, p_data->io_req.is_orig); } Loading @@ -2371,7 +2375,7 @@ static uint8_t bta_dm_sp_cback(tBTM_SP_EVT event, tBTM_SP_EVT_DATA* p_data) { break; case BTM_SP_IO_RSP_EVT: if (btm_local_io_caps != BTM_IO_CAP_NONE) { bta_dm_co_io_rsp(p_data->io_rsp.bd_addr, p_data->io_rsp.io_cap, btif_dm_proc_io_rsp(p_data->io_rsp.bd_addr, p_data->io_rsp.io_cap, p_data->io_rsp.oob_data, p_data->io_rsp.auth_req); } break; Loading Loading @@ -2459,13 +2463,23 @@ static uint8_t bta_dm_sp_cback(tBTM_SP_EVT event, tBTM_SP_EVT_DATA* p_data) { break; case BTM_SP_LOC_OOB_EVT: bta_dm_co_loc_oob((bool)(p_data->loc_oob.status == BTM_SUCCESS), #ifdef BTIF_DM_OOB_TEST btif_dm_proc_loc_oob((bool)(p_data->loc_oob.status == BTM_SUCCESS), p_data->loc_oob.c, p_data->loc_oob.r); #endif break; case BTM_SP_RMT_OOB_EVT: bta_dm_co_rmt_oob(p_data->rmt_oob.bd_addr); case BTM_SP_RMT_OOB_EVT: { Octet16 c; Octet16 r; sp_rmt_result = false; #ifdef BTIF_DM_OOB_TEST sp_rmt_result = btif_dm_proc_rmt_oob(p_data->rmt_oob.bd_addr, &c, &r); #endif BTIF_TRACE_DEBUG("bta_dm_ci_rmt_oob: result=%d", sp_rmt_result); bta_dm_ci_rmt_oob(sp_rmt_result, p_data->rmt_oob.bd_addr, c, r); break; } default: status = BTM_NOT_AUTHORIZED; Loading Loading @@ -3566,6 +3580,46 @@ static void bta_dm_observe_cmpl_cb(void* p_result) { } } static void ble_io_req(const RawAddress& bd_addr, tBTM_IO_CAP* p_io_cap, tBTM_OOB_DATA* p_oob_data, tBTM_LE_AUTH_REQ* p_auth_req, uint8_t* p_max_key_size, tBTA_LE_KEY_TYPE* p_init_key, tBTA_LE_KEY_TYPE* p_resp_key) { bte_appl_cfg.ble_io_cap = btif_storage_get_local_io_caps_ble(); /* Retrieve the properties from file system if possible */ tBTE_APPL_CFG nv_config; if (btif_dm_get_smp_config(&nv_config)) bte_appl_cfg = nv_config; /* *p_auth_req by default is false for devices with NoInputNoOutput; true for * other devices. */ if (bte_appl_cfg.ble_auth_req) *p_auth_req = bte_appl_cfg.ble_auth_req | (bte_appl_cfg.ble_auth_req & 0x04) | ((*p_auth_req) & 0x04); /* if OOB is not supported, this call-out function does not need to do * anything * otherwise, look for the OOB data associated with the address and set * *p_oob_data accordingly. * If the answer can not be obtained right away, * set *p_oob_data to BTA_OOB_UNKNOWN and call bta_dm_ci_io_req() when the * answer is available. */ btif_dm_set_oob_for_le_io_req(bd_addr, p_oob_data, p_auth_req); if (bte_appl_cfg.ble_io_cap <= 4) *p_io_cap = bte_appl_cfg.ble_io_cap; if (bte_appl_cfg.ble_init_key <= BTM_BLE_INITIATOR_KEY_SIZE) *p_init_key = bte_appl_cfg.ble_init_key; if (bte_appl_cfg.ble_resp_key <= BTM_BLE_RESPONDER_KEY_SIZE) *p_resp_key = bte_appl_cfg.ble_resp_key; if (bte_appl_cfg.ble_max_key_size > 7 && bte_appl_cfg.ble_max_key_size <= 16) *p_max_key_size = bte_appl_cfg.ble_max_key_size; } /******************************************************************************* * * Function bta_dm_ble_smp_cback Loading @@ -3587,13 +3641,11 @@ static uint8_t bta_dm_ble_smp_cback(tBTM_LE_EVT event, const RawAddress& bda, memset(&sec_event, 0, sizeof(tBTA_DM_SEC)); switch (event) { case BTM_LE_IO_REQ_EVT: bta_dm_co_ble_io_req( bda, &p_data->io_req.io_cap, &p_data->io_req.oob_data, ble_io_req(bda, &p_data->io_req.io_cap, &p_data->io_req.oob_data, &p_data->io_req.auth_req, &p_data->io_req.max_key_size, &p_data->io_req.init_keys, &p_data->io_req.resp_keys); APPL_TRACE_EVENT("io mitm: %d oob_data:%d", p_data->io_req.auth_req, p_data->io_req.oob_data); break; case BTM_LE_SEC_REQUEST_EVT: Loading
system/btif/co/bta_dm_co.cc +0 −208 Original line number Diff line number Diff line Loading @@ -57,211 +57,3 @@ bool bta_dm_co_get_compress_memory(UNUSED_ATTR tBTA_SYS_ID id, return true; } /******************************************************************************* * * Function bta_dm_co_io_req * * Description This callout function is executed by DM to get IO * capabilities of the local device for the Simple Pairing * process. * * Parameters bd_addr - The peer device * *p_io_cap - The local Input/Output capabilities * *p_oob_data - true, if OOB data is available for the peer * device. * *p_auth_req - true, if MITM protection is required. * * Returns void. * ******************************************************************************/ void bta_dm_co_io_req(UNUSED_ATTR const RawAddress& bd_addr, tBTM_IO_CAP* p_io_cap, tBTM_OOB_DATA* p_oob_data, tBTM_AUTH_REQ* p_auth_req, bool is_orig) { btif_dm_set_oob_for_io_req(p_oob_data); btif_dm_proc_io_req(bd_addr, p_io_cap, p_oob_data, p_auth_req, is_orig); BTIF_TRACE_DEBUG("bta_dm_co_io_req *p_oob_data = %d", *p_oob_data); BTIF_TRACE_DEBUG("bta_dm_co_io_req *p_io_cap = %d", *p_io_cap); BTIF_TRACE_DEBUG("bta_dm_co_io_req *p_auth_req = %d", *p_auth_req); BTIF_TRACE_DEBUG("bta_dm_co_io_req is_orig = %d", is_orig); } /******************************************************************************* * * Function bta_dm_co_io_rsp * * Description This callout function is executed by DM to report IO * capabilities of the peer device for the Simple Pairing * process. * * Parameters bd_addr - The peer device * io_cap - The remote Input/Output capabilities * oob_data - true, if OOB data is available for the peer * device. * auth_req - true, if MITM protection is required. * * Returns void. * ******************************************************************************/ void bta_dm_co_io_rsp(const RawAddress& bd_addr, tBTM_IO_CAP io_cap, tBTM_OOB_DATA oob_data, tBTM_AUTH_REQ auth_req) { btif_dm_proc_io_rsp(bd_addr, io_cap, oob_data, auth_req); } /******************************************************************************* * * Function bta_dm_co_loc_oob * * Description This callout function is executed by DM to report the OOB * data of the local device for the Simple Pairing process * * Parameters valid - true, if the local OOB data is retrieved from LM * c - Simple Pairing Hash C * r - Simple Pairing Randomnizer R * * Returns void. * ******************************************************************************/ void bta_dm_co_loc_oob(bool valid, const Octet16& c, const Octet16& r) { BTIF_TRACE_DEBUG("bta_dm_co_loc_oob, valid = %d", valid); #ifdef BTIF_DM_OOB_TEST btif_dm_proc_loc_oob(valid, c, r); #endif } /******************************************************************************* * * Function bta_dm_co_rmt_oob * * Description This callout function is executed by DM to request the OOB * data for the remote device for the Simple Pairing process * Need to call bta_dm_ci_rmt_oob() in response * * Parameters bd_addr - The peer device * * Returns void. * ******************************************************************************/ void bta_dm_co_rmt_oob(const RawAddress& bd_addr) { Octet16 c; Octet16 r; bool result = false; #ifdef BTIF_DM_OOB_TEST result = btif_dm_proc_rmt_oob(bd_addr, &c, &r); #endif BTIF_TRACE_DEBUG("bta_dm_co_rmt_oob: result=%d", result); bta_dm_ci_rmt_oob(result, bd_addr, c, r); } /******************************************************************************* * * Function bta_dm_co_le_io_key_req * * Description This callout function is executed by DM to get BLE key * information * before SMP pairing gets going. * * Parameters bd_addr - The peer device * *p_max_key_size - max key size local device supported. * *p_init_key - initiator keys. * *p_resp_key - responder keys. * * Returns void. * ******************************************************************************/ void bta_dm_co_le_io_key_req(UNUSED_ATTR const RawAddress& bd_addr, uint8_t* p_max_key_size, tBTA_LE_KEY_TYPE* p_init_key, tBTA_LE_KEY_TYPE* p_resp_key) { BTIF_TRACE_ERROR("##################################"); BTIF_TRACE_ERROR("bta_dm_co_le_io_key_req: only setting max size to 16"); BTIF_TRACE_ERROR("##################################"); *p_max_key_size = 16; *p_init_key = *p_resp_key = (BTA_LE_KEY_PENC | BTA_LE_KEY_PID | BTA_LE_KEY_PCSRK | BTA_LE_KEY_LENC | BTA_LE_KEY_LID | BTA_LE_KEY_LCSRK); } /******************************************************************************* * * Function bta_dm_co_ble_local_key_reload * * Description This callout function is to load the local BLE keys if * available on the device. * * Parameters none * * Returns void. * ******************************************************************************/ void bta_dm_co_ble_load_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK* p_key_mask, Octet16* p_er, tBTA_BLE_LOCAL_ID_KEYS* p_id_keys) { BTIF_TRACE_DEBUG("##################################"); BTIF_TRACE_DEBUG( "bta_dm_co_ble_load_local_keys: Load local keys if any are persisted"); BTIF_TRACE_DEBUG("##################################"); btif_dm_get_ble_local_keys(p_key_mask, p_er, p_id_keys); } /******************************************************************************* * * Function bta_dm_co_ble_io_req * * Description This callout function is executed by DM to get BLE IO * capabilities before SMP pairing gets going. * * Parameters bd_addr - The peer device * *p_io_cap - The local Input/Output capabilities * *p_oob_data - true, if OOB data is available for the peer * device. * *p_auth_req - Auth request setting (Bonding and MITM * required or not) * *p_max_key_size - max key size local device supported. * *p_init_key - initiator keys. * *p_resp_key - responder keys. * * Returns void. * ******************************************************************************/ void bta_dm_co_ble_io_req(const RawAddress& bd_addr, tBTM_IO_CAP* p_io_cap, tBTM_OOB_DATA* p_oob_data, tBTM_LE_AUTH_REQ* p_auth_req, uint8_t* p_max_key_size, tBTA_LE_KEY_TYPE* p_init_key, tBTA_LE_KEY_TYPE* p_resp_key) { bte_appl_cfg.ble_io_cap = btif_storage_get_local_io_caps_ble(); /* Retrieve the properties from file system if possible */ tBTE_APPL_CFG nv_config; if (btif_dm_get_smp_config(&nv_config)) bte_appl_cfg = nv_config; /* *p_auth_req by default is false for devices with NoInputNoOutput; true for * other devices. */ if (bte_appl_cfg.ble_auth_req) *p_auth_req = bte_appl_cfg.ble_auth_req | (bte_appl_cfg.ble_auth_req & 0x04) | ((*p_auth_req) & 0x04); /* if OOB is not supported, this call-out function does not need to do * anything * otherwise, look for the OOB data associated with the address and set * *p_oob_data accordingly. * If the answer can not be obtained right away, * set *p_oob_data to BTA_OOB_UNKNOWN and call bta_dm_ci_io_req() when the * answer is available. */ btif_dm_set_oob_for_le_io_req(bd_addr, p_oob_data, p_auth_req); if (bte_appl_cfg.ble_io_cap <= 4) *p_io_cap = bte_appl_cfg.ble_io_cap; if (bte_appl_cfg.ble_init_key <= BTM_BLE_INITIATOR_KEY_SIZE) *p_init_key = bte_appl_cfg.ble_init_key; if (bte_appl_cfg.ble_resp_key <= BTM_BLE_RESPONDER_KEY_SIZE) *p_resp_key = bte_appl_cfg.ble_resp_key; if (bte_appl_cfg.ble_max_key_size > 7 && bte_appl_cfg.ble_max_key_size <= 16) *p_max_key_size = bte_appl_cfg.ble_max_key_size; }