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

Commit 407799cf authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "RootCanal: Allow adding multiple resolving list entries with empty peer IRK" into main

parents 949e1f76 e2234806
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -682,7 +682,7 @@ ErrorCode LinkLayerController::LeAddDeviceToResolvingList(
  for (auto const& entry : le_resolving_list_) {
  for (auto const& entry : le_resolving_list_) {
    if ((entry.peer_identity_address_type == peer_identity_address_type &&
    if ((entry.peer_identity_address_type == peer_identity_address_type &&
         entry.peer_identity_address == peer_identity_address) ||
         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");
      INFO(id_, "device is already present in the resolving list");
      return ErrorCode::INVALID_HCI_COMMAND_PARAMETERS;
      return ErrorCode::INVALID_HCI_COMMAND_PARAMETERS;
    }
    }
@@ -2837,6 +2837,10 @@ Address LinkLayerController::generate_rpa(
  return 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.
// Handle legacy advertising PDUs while in the Scanning state.
void LinkLayerController::ScanIncomingLeLegacyAdvertisingPdu(
void LinkLayerController::ScanIncomingLeLegacyAdvertisingPdu(
    model::packets::LeLegacyAdvertisingPduView& pdu, uint8_t rssi) {
    model::packets::LeLegacyAdvertisingPduView& pdu, uint8_t rssi) {
+3 −0
Original line number Original line Diff line number Diff line
@@ -63,6 +63,9 @@ class LinkLayerController {
  static Address generate_rpa(
  static Address generate_rpa(
      std::array<uint8_t, LinkLayerController::kIrkSize> irk);
      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,
  LinkLayerController(const Address& address,
                      const ControllerProperties& properties, int id = 0);
                      const ControllerProperties& properties, int id = 0);
  ~LinkLayerController();
  ~LinkLayerController();
+12 −0
Original line number Original line Diff line number Diff line
@@ -130,4 +130,16 @@ TEST_F(LeAddDeviceToResolvingListTest, PeerIrkDuplicate) {
            ErrorCode::INVALID_HCI_COMMAND_PARAMETERS);
            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
}  // namespace rootcanal