Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 376b882e authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

Merge "Do not use security record after wipe_secrets_and_remote" am: 9addd1a7

parents 255f8b71 9addd1a7
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -186,17 +186,19 @@ bool BTM_SecDeleteDevice(const RawAddress& bd_addr) {
      BTM_AcceptlistRemove(p_dev_rec->bd_addr);
    }

    const auto device_type = p_dev_rec->device_type;
    const auto bond_type = p_dev_rec->bond_type;

    /* Clear out any saved BLE keys */
    btm_sec_clear_ble_keys(p_dev_rec);
    wipe_secrets_and_remove(p_dev_rec);
    /* Tell controller to get rid of the link key, if it has one stored */
    BTM_DeleteStoredLinkKey(&bda, NULL);
    LOG_INFO("%s %s complete", __func__, ADDRESS_TO_LOGGABLE_CSTR(bd_addr));
    BTM_LogHistory(
        kBtmLogTag, bd_addr, "Device removed",
    BTM_LogHistory(kBtmLogTag, bd_addr, "Device removed",
                   base::StringPrintf("device_type:%s bond_type:%s",
                           DeviceTypeText(p_dev_rec->device_type).c_str(),
                           bond_type_text(p_dev_rec->bond_type).c_str()));
                                      DeviceTypeText(device_type).c_str(),
                                      bond_type_text(bond_type).c_str()));
  } else {
    LOG_WARN("%s Unable to delete link key for unknown device %s", __func__,
             ADDRESS_TO_LOGGABLE_CSTR(bd_addr));
+19 −1
Original line number Diff line number Diff line
@@ -44,8 +44,8 @@
#include "stack/include/sec_hci_link_interface.h"
#include "stack/l2cap/l2c_int.h"
#include "test/common/mock_functions.h"
#include "test/mock/mock_osi_list.h"
#include "test/mock/mock_device_iot_config.h"
#include "test/mock/mock_osi_list.h"
#include "test/mock/mock_stack_hcic_hcicmds.h"
#include "types/raw_address.h"

@@ -438,3 +438,21 @@ TEST_F(StackBtmTest, bond_type_text) {
                                  std::numeric_limits<std::uint8_t>::max()))
                   .c_str());
}

TEST_F(StackBtmWithInitFreeTest, wipe_secrets_and_remove) {
  bluetooth::common::InitFlags::SetAllForTesting();

  RawAddress bd_addr = RawAddress({0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6});
  const uint16_t classic_handle = 0x1234;
  const uint16_t ble_handle = 0x9876;

  // Setup device
  tBTM_SEC_DEV_REC* device_record = btm_sec_allocate_dev_rec();
  ASSERT_NE(nullptr, device_record);
  ASSERT_EQ(BTM_SEC_IN_USE, device_record->sec_flags);
  device_record->bd_addr = bd_addr;
  device_record->hci_handle = classic_handle;
  device_record->ble_hci_handle = ble_handle;

  wipe_secrets_and_remove(device_record);
}