From 86770f28281765c7735989f064f7bf6ba16def86 Mon Sep 17 00:00:00 2001 From: Martin Brabham Date: Fri, 29 Oct 2021 21:27:27 +0000 Subject: [PATCH] Reset the IRK after all devices are unpaired Bug: 204355134 Bug: 195410559 Test: Check IRK, pair devices, unpair all devices, Check IRK Tag: #security Change-Id: I8e44f010a72dcdec595d81293a05f49ccc054065 Merged-In: I8e44f010a72dcdec595d81293a05f49ccc054065 --- bta/dm/bta_dm_act.cc | 11 +++++++++++ test/mock/mock_stack_btm_ble.cc | 3 +++ 2 files changed, 14 insertions(+) diff --git a/bta/dm/bta_dm_act.cc b/bta/dm/bta_dm_act.cc index 2566b5b42..ebdd9594c 100644 --- a/bta/dm/bta_dm_act.cc +++ b/bta/dm/bta_dm_act.cc @@ -25,11 +25,14 @@ #define LOG_TAG "bt_bta_dm" +#include + #include #include "bta/dm/bta_dm_int.h" #include "bta/gatt/bta_gattc_int.h" #include "bta/include/bta_dm_ci.h" +#include "btif/include/btif_config.h" #include "btif/include/btif_dm.h" #include "btif/include/btif_storage.h" #include "btif/include/stack_manager.h" @@ -42,6 +45,7 @@ #include "osi/include/fixed_queue.h" #include "osi/include/log.h" #include "osi/include/osi.h" +#include "stack/btm/btm_ble_int.h" #include "stack/btm/btm_sec.h" #include "stack/btm/neighbor_inquiry.h" #include "stack/gatt/connection_manager.h" @@ -645,6 +649,13 @@ void bta_dm_remove_device(const RawAddress& bd_addr) { if (!other_address_connected && !other_address.IsEmpty()) { bta_dm_process_remove_device(other_address); } + + /* Check the length of the paired devices, and if 0 then reset IRK */ + auto paired_devices = btif_config_get_paired_devices(); + if (paired_devices.empty()) { + LOG_INFO("Last paired device removed, resetting IRK"); + btm_ble_reset_id(); + } } /******************************************************************************* diff --git a/test/mock/mock_stack_btm_ble.cc b/test/mock/mock_stack_btm_ble.cc index 835b1d230..b6e24ee12 100644 --- a/test/mock/mock_stack_btm_ble.cc +++ b/test/mock/mock_stack_btm_ble.cc @@ -254,3 +254,6 @@ void read_phy_cb( uint8_t* data, uint16_t len) { mock_function_count_map[__func__]++; } +void btm_ble_reset_id(void) { + mock_function_count_map[__func__]++; +} -- 2.11.0