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

Commit e2234806 authored by Henri Chataing's avatar Henri Chataing
Browse files

RootCanal: Allow adding multiple resolving list entries with empty peer IRK

Empty peer IRKs are used for specific peer privacy modes.

Bug: 286588829
Test: atest rootcanal_hci_test
Change-Id: Ic7f21481bd8cd242249fc857d49700fb3517df1b
parent 3fea1e9a
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -682,7 +682,7 @@ ErrorCode LinkLayerController::LeAddDeviceToResolvingList(
  for (auto const& entry : le_resolving_list_) {
    if ((entry.peer_identity_address_type == peer_identity_address_type &&
         entry.peer_identity_address == peer_identity_address) ||
        entry.peer_irk == peer_irk) {
        (entry.peer_irk == peer_irk && !irk_is_zero(peer_irk))) {
      INFO(id_, "device is already present in the resolving list");
      return ErrorCode::INVALID_HCI_COMMAND_PARAMETERS;
    }
@@ -2837,6 +2837,10 @@ Address LinkLayerController::generate_rpa(
  return rpa;
}

bool LinkLayerController::irk_is_zero(std::array<uint8_t, LinkLayerController::kIrkSize> irk) {
    return std::all_of(irk.begin(), irk.end(), [](uint8_t b) { return b == 0; });
}

// Handle legacy advertising PDUs while in the Scanning state.
void LinkLayerController::ScanIncomingLeLegacyAdvertisingPdu(
    model::packets::LeLegacyAdvertisingPduView& pdu, uint8_t rssi) {
+3 −0
Original line number Diff line number Diff line
@@ -63,6 +63,9 @@ class LinkLayerController {
  static Address generate_rpa(
      std::array<uint8_t, LinkLayerController::kIrkSize> irk);

  // Return true if the input IRK is all 0s.
  static bool irk_is_zero(std::array<uint8_t, LinkLayerController::kIrkSize> irk);

  LinkLayerController(const Address& address,
                      const ControllerProperties& properties, int id = 0);
  ~LinkLayerController();
+12 −0
Original line number Diff line number Diff line
@@ -130,4 +130,16 @@ TEST_F(LeAddDeviceToResolvingListTest, PeerIrkDuplicate) {
            ErrorCode::INVALID_HCI_COMMAND_PARAMETERS);
}

TEST_F(LeAddDeviceToResolvingListTest, EmptyPeerIrkDuplicate) {
  ASSERT_EQ(controller_.LeAddDeviceToResolvingList(
                PeerAddressType::PUBLIC_DEVICE_OR_IDENTITY_ADDRESS, Address{1},
                std::array<uint8_t, 16>{0}, std::array<uint8_t, 16>{1}),
            ErrorCode::SUCCESS);

  ASSERT_EQ(controller_.LeAddDeviceToResolvingList(
                PeerAddressType::RANDOM_DEVICE_OR_IDENTITY_ADDRESS, Address{1},
                std::array<uint8_t, 16>{0}, std::array<uint8_t, 16>{1}),
            ErrorCode::SUCCESS);
}

}  // namespace rootcanal