Loading system/stack/acl/acl.h +3 −0 Original line number Diff line number Diff line Loading @@ -360,3 +360,6 @@ struct tACL_CB { }; tACL_CONN* btm_acl_for_bda(const RawAddress& bd_addr, tBT_TRANSPORT transport); void btm_acl_encrypt_change(uint16_t handle, uint8_t status, uint8_t encr_enable); No newline at end of file system/stack/btm/btm_sec.cc +74 −2 Original line number Diff line number Diff line Loading @@ -3346,6 +3346,80 @@ void btm_sec_encrypt_change(uint16_t handle, tHCI_STATUS status, btm_sec_dev_rec_cback_event(p_dev_rec, btm_status, false); } constexpr uint8_t MIN_KEY_SIZE = 7; static void read_encryption_key_size_complete_after_encryption_change( uint8_t status, uint16_t handle, uint8_t key_size) { if (status == HCI_ERR_INSUFFCIENT_SECURITY) { /* If remote device stop the encryption before we call "Read Encryption Key * Size", we might receive Insufficient Security, which means that link is * no longer encrypted. */ LOG_INFO("encryption stopped on link:0x%x", handle); return; } if (status != HCI_SUCCESS) { LOG_ERROR("disconnecting, status:0x%x", status); acl_disconnect_from_handle(handle, HCI_ERR_PEER_USER, "stack::btu::btu_hcif::read_encryption_key_size_" "complete_after_encryption_change Bad key size"); return; } if (key_size < MIN_KEY_SIZE) { LOG_ERROR( "encryption key too short, disconnecting. handle:0x%x,key_size:%d", handle, key_size); acl_disconnect_from_handle( handle, HCI_ERR_HOST_REJECT_SECURITY, "stack::btu::btu_hcif::read_encryption_key_size_complete_after_" "encryption_change Key Too Short"); return; } // good key size - succeed btm_acl_encrypt_change(handle, static_cast<tHCI_STATUS>(status), 1 /* enable */); btm_sec_encrypt_change(handle, static_cast<tHCI_STATUS>(status), 1 /* enable */); } // TODO: Remove void smp_cancel_start_encryption_attempt(); /******************************************************************************* * * Function btm_encryption_change_evt * * Description Process event HCI_ENCRYPTION_CHANGE_EVT * * Returns void * ******************************************************************************/ void btm_sec_encryption_change_evt(uint16_t handle, tHCI_STATUS status, uint8_t encr_enable) { if (status != HCI_SUCCESS || encr_enable == 0 || BTM_IsBleConnection(handle) || !controller_get_interface()->supports_read_encryption_key_size() || // Skip encryption key size check when using set_min_encryption_key_size (bluetooth::common::init_flags::set_min_encryption_is_enabled() && controller_get_interface()->supports_set_min_encryption_key_size())) { if (status == HCI_ERR_CONNECTION_TOUT) { smp_cancel_start_encryption_attempt(); return; } btm_acl_encrypt_change(handle, static_cast<tHCI_STATUS>(status), encr_enable); btm_sec_encrypt_change(handle, static_cast<tHCI_STATUS>(status), encr_enable); } else { btsnd_hcic_read_encryption_key_size( handle, base::Bind(&read_encryption_key_size_complete_after_encryption_change)); } } /******************************************************************************* * * Function btm_sec_connect_after_reject_timeout Loading Loading @@ -3829,8 +3903,6 @@ void btm_sec_role_changed(tHCI_STATUS hci_status, const RawAddress& bd_addr, } } constexpr uint8_t MIN_KEY_SIZE = 7; static void read_encryption_key_size_complete_after_key_refresh( uint8_t status, uint16_t handle, uint8_t key_size) { if (status == HCI_ERR_INSUFFCIENT_SECURITY) { Loading system/stack/btm/btm_sec.h +12 −0 Original line number Diff line number Diff line Loading @@ -591,6 +591,18 @@ void btm_read_local_oob_complete(const tBTM_SP_LOC_OOB evt_data); ******************************************************************************/ void btm_sec_auth_complete(uint16_t handle, tHCI_STATUS status); /******************************************************************************* * * Function btm_sec_encryption_change_evt * * Description This function is called to process an encryption change. * * Returns void * ******************************************************************************/ void btm_sec_encryption_change_evt(uint16_t handle, tHCI_STATUS status, uint8_t encr_enable); /******************************************************************************* * * Function btm_sec_encrypt_change Loading system/stack/btu/btu_hcif.cc +2 −58 Original line number Diff line number Diff line Loading @@ -884,44 +884,6 @@ static void btu_hcif_rmt_name_request_comp_evt(const uint8_t* p, btm_sec_rmt_name_request_complete(&bd_addr, p, to_hci_status_code(status)); } constexpr uint8_t MIN_KEY_SIZE = 7; static void read_encryption_key_size_complete_after_encryption_change(uint8_t status, uint16_t handle, uint8_t key_size) { if (status == HCI_ERR_INSUFFCIENT_SECURITY) { /* If remote device stop the encryption before we call "Read Encryption Key * Size", we might receive Insufficient Security, which means that link is * no longer encrypted. */ LOG_INFO("encryption stopped on link:0x%x", handle); return; } if (status != HCI_SUCCESS) { LOG_ERROR("disconnecting, status:0x%x", status); acl_disconnect_from_handle(handle, HCI_ERR_PEER_USER, "stack::btu::btu_hcif::read_encryption_key_size_" "complete_after_encryption_change Bad key size"); return; } if (key_size < MIN_KEY_SIZE) { LOG_ERROR( "encryption key too short, disconnecting. handle:0x%x,key_size:%d", handle, key_size); acl_disconnect_from_handle( handle, HCI_ERR_HOST_REJECT_SECURITY, "stack::btu::btu_hcif::read_encryption_key_size_complete_after_" "encryption_change Key Too Short"); return; } // good key size - succeed btm_acl_encrypt_change(handle, static_cast<tHCI_STATUS>(status), 1 /* enable */); btm_sec_encrypt_change(handle, static_cast<tHCI_STATUS>(status), 1 /* enable */); } /******************************************************************************* * * Function btu_hcif_encryption_change_evt Loading @@ -940,26 +902,8 @@ static void btu_hcif_encryption_change_evt(uint8_t* p) { STREAM_TO_UINT16(handle, p); STREAM_TO_UINT8(encr_enable, p); if (status != HCI_SUCCESS || encr_enable == 0 || BTM_IsBleConnection(handle) || !controller_get_interface()->supports_read_encryption_key_size() || // Skip encryption key size check when using set_min_encryption_key_size (bluetooth::common::init_flags::set_min_encryption_is_enabled() && controller_get_interface()->supports_set_min_encryption_key_size())) { if (status == HCI_ERR_CONNECTION_TOUT) { smp_cancel_start_encryption_attempt(); return; } btm_acl_encrypt_change(handle, static_cast<tHCI_STATUS>(status), encr_enable); btm_sec_encrypt_change(handle, static_cast<tHCI_STATUS>(status), btm_sec_encryption_change_evt(handle, static_cast<tHCI_STATUS>(status), encr_enable); } else { btsnd_hcic_read_encryption_key_size( handle, base::Bind(&read_encryption_key_size_complete_after_encryption_change)); } } /******************************************************************************* Loading system/stack/include/acl_hci_link_interface.h +0 −2 Original line number Diff line number Diff line Loading @@ -39,8 +39,6 @@ void on_acl_br_edr_failed(const RawAddress& bda, tHCI_STATUS status, bool locally_initiated); void btm_acl_disconnected(tHCI_STATUS status, uint16_t handle, tHCI_STATUS reason); void btm_acl_encrypt_change(uint16_t handle, uint8_t status, uint8_t encr_enable); void btm_acl_role_changed(tHCI_STATUS hci_status, const RawAddress& bd_addr, tHCI_ROLE new_role); void btm_rejectlist_role_change_device(const RawAddress& bd_addr, Loading Loading
system/stack/acl/acl.h +3 −0 Original line number Diff line number Diff line Loading @@ -360,3 +360,6 @@ struct tACL_CB { }; tACL_CONN* btm_acl_for_bda(const RawAddress& bd_addr, tBT_TRANSPORT transport); void btm_acl_encrypt_change(uint16_t handle, uint8_t status, uint8_t encr_enable); No newline at end of file
system/stack/btm/btm_sec.cc +74 −2 Original line number Diff line number Diff line Loading @@ -3346,6 +3346,80 @@ void btm_sec_encrypt_change(uint16_t handle, tHCI_STATUS status, btm_sec_dev_rec_cback_event(p_dev_rec, btm_status, false); } constexpr uint8_t MIN_KEY_SIZE = 7; static void read_encryption_key_size_complete_after_encryption_change( uint8_t status, uint16_t handle, uint8_t key_size) { if (status == HCI_ERR_INSUFFCIENT_SECURITY) { /* If remote device stop the encryption before we call "Read Encryption Key * Size", we might receive Insufficient Security, which means that link is * no longer encrypted. */ LOG_INFO("encryption stopped on link:0x%x", handle); return; } if (status != HCI_SUCCESS) { LOG_ERROR("disconnecting, status:0x%x", status); acl_disconnect_from_handle(handle, HCI_ERR_PEER_USER, "stack::btu::btu_hcif::read_encryption_key_size_" "complete_after_encryption_change Bad key size"); return; } if (key_size < MIN_KEY_SIZE) { LOG_ERROR( "encryption key too short, disconnecting. handle:0x%x,key_size:%d", handle, key_size); acl_disconnect_from_handle( handle, HCI_ERR_HOST_REJECT_SECURITY, "stack::btu::btu_hcif::read_encryption_key_size_complete_after_" "encryption_change Key Too Short"); return; } // good key size - succeed btm_acl_encrypt_change(handle, static_cast<tHCI_STATUS>(status), 1 /* enable */); btm_sec_encrypt_change(handle, static_cast<tHCI_STATUS>(status), 1 /* enable */); } // TODO: Remove void smp_cancel_start_encryption_attempt(); /******************************************************************************* * * Function btm_encryption_change_evt * * Description Process event HCI_ENCRYPTION_CHANGE_EVT * * Returns void * ******************************************************************************/ void btm_sec_encryption_change_evt(uint16_t handle, tHCI_STATUS status, uint8_t encr_enable) { if (status != HCI_SUCCESS || encr_enable == 0 || BTM_IsBleConnection(handle) || !controller_get_interface()->supports_read_encryption_key_size() || // Skip encryption key size check when using set_min_encryption_key_size (bluetooth::common::init_flags::set_min_encryption_is_enabled() && controller_get_interface()->supports_set_min_encryption_key_size())) { if (status == HCI_ERR_CONNECTION_TOUT) { smp_cancel_start_encryption_attempt(); return; } btm_acl_encrypt_change(handle, static_cast<tHCI_STATUS>(status), encr_enable); btm_sec_encrypt_change(handle, static_cast<tHCI_STATUS>(status), encr_enable); } else { btsnd_hcic_read_encryption_key_size( handle, base::Bind(&read_encryption_key_size_complete_after_encryption_change)); } } /******************************************************************************* * * Function btm_sec_connect_after_reject_timeout Loading Loading @@ -3829,8 +3903,6 @@ void btm_sec_role_changed(tHCI_STATUS hci_status, const RawAddress& bd_addr, } } constexpr uint8_t MIN_KEY_SIZE = 7; static void read_encryption_key_size_complete_after_key_refresh( uint8_t status, uint16_t handle, uint8_t key_size) { if (status == HCI_ERR_INSUFFCIENT_SECURITY) { Loading
system/stack/btm/btm_sec.h +12 −0 Original line number Diff line number Diff line Loading @@ -591,6 +591,18 @@ void btm_read_local_oob_complete(const tBTM_SP_LOC_OOB evt_data); ******************************************************************************/ void btm_sec_auth_complete(uint16_t handle, tHCI_STATUS status); /******************************************************************************* * * Function btm_sec_encryption_change_evt * * Description This function is called to process an encryption change. * * Returns void * ******************************************************************************/ void btm_sec_encryption_change_evt(uint16_t handle, tHCI_STATUS status, uint8_t encr_enable); /******************************************************************************* * * Function btm_sec_encrypt_change Loading
system/stack/btu/btu_hcif.cc +2 −58 Original line number Diff line number Diff line Loading @@ -884,44 +884,6 @@ static void btu_hcif_rmt_name_request_comp_evt(const uint8_t* p, btm_sec_rmt_name_request_complete(&bd_addr, p, to_hci_status_code(status)); } constexpr uint8_t MIN_KEY_SIZE = 7; static void read_encryption_key_size_complete_after_encryption_change(uint8_t status, uint16_t handle, uint8_t key_size) { if (status == HCI_ERR_INSUFFCIENT_SECURITY) { /* If remote device stop the encryption before we call "Read Encryption Key * Size", we might receive Insufficient Security, which means that link is * no longer encrypted. */ LOG_INFO("encryption stopped on link:0x%x", handle); return; } if (status != HCI_SUCCESS) { LOG_ERROR("disconnecting, status:0x%x", status); acl_disconnect_from_handle(handle, HCI_ERR_PEER_USER, "stack::btu::btu_hcif::read_encryption_key_size_" "complete_after_encryption_change Bad key size"); return; } if (key_size < MIN_KEY_SIZE) { LOG_ERROR( "encryption key too short, disconnecting. handle:0x%x,key_size:%d", handle, key_size); acl_disconnect_from_handle( handle, HCI_ERR_HOST_REJECT_SECURITY, "stack::btu::btu_hcif::read_encryption_key_size_complete_after_" "encryption_change Key Too Short"); return; } // good key size - succeed btm_acl_encrypt_change(handle, static_cast<tHCI_STATUS>(status), 1 /* enable */); btm_sec_encrypt_change(handle, static_cast<tHCI_STATUS>(status), 1 /* enable */); } /******************************************************************************* * * Function btu_hcif_encryption_change_evt Loading @@ -940,26 +902,8 @@ static void btu_hcif_encryption_change_evt(uint8_t* p) { STREAM_TO_UINT16(handle, p); STREAM_TO_UINT8(encr_enable, p); if (status != HCI_SUCCESS || encr_enable == 0 || BTM_IsBleConnection(handle) || !controller_get_interface()->supports_read_encryption_key_size() || // Skip encryption key size check when using set_min_encryption_key_size (bluetooth::common::init_flags::set_min_encryption_is_enabled() && controller_get_interface()->supports_set_min_encryption_key_size())) { if (status == HCI_ERR_CONNECTION_TOUT) { smp_cancel_start_encryption_attempt(); return; } btm_acl_encrypt_change(handle, static_cast<tHCI_STATUS>(status), encr_enable); btm_sec_encrypt_change(handle, static_cast<tHCI_STATUS>(status), btm_sec_encryption_change_evt(handle, static_cast<tHCI_STATUS>(status), encr_enable); } else { btsnd_hcic_read_encryption_key_size( handle, base::Bind(&read_encryption_key_size_complete_after_encryption_change)); } } /******************************************************************************* Loading
system/stack/include/acl_hci_link_interface.h +0 −2 Original line number Diff line number Diff line Loading @@ -39,8 +39,6 @@ void on_acl_br_edr_failed(const RawAddress& bda, tHCI_STATUS status, bool locally_initiated); void btm_acl_disconnected(tHCI_STATUS status, uint16_t handle, tHCI_STATUS reason); void btm_acl_encrypt_change(uint16_t handle, uint8_t status, uint8_t encr_enable); void btm_acl_role_changed(tHCI_STATUS hci_status, const RawAddress& bd_addr, tHCI_ROLE new_role); void btm_rejectlist_role_change_device(const RawAddress& bd_addr, Loading