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

Commit ec987663 authored by Rahul Arya's avatar Rahul Arya
Browse files

[RootCanal] Check encryption response status

If the status != SUCCESS, do not encrypt the connection.

Test: manual
Bug: 276513139
Change-Id: I5df5a73494b6a7e0435c65ee0aee124a1b487e9e
parent f03696d4
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -4329,9 +4329,11 @@ void LinkLayerController::IncomingLeEncryptConnectionResponse(
      model::packets::LeEncryptConnectionResponseView::Create(incoming);
  ASSERT(response.IsValid());

  bool success = true;
  // Zero LTK is a rejection
  if (response.GetLtk() == std::array<uint8_t, 16>{0}) {
    status = ErrorCode::AUTHENTICATION_FAILURE;
    success = false;
  }

  if (connections_.IsEncrypted(handle)) {
@@ -4339,12 +4341,17 @@ void LinkLayerController::IncomingLeEncryptConnectionResponse(
      send_event_(bluetooth::hci::EncryptionKeyRefreshCompleteBuilder::Create(
          status, handle));
    }
  } else {
  } else if (success) {
    connections_.Encrypt(handle);
    if (IsEventUnmasked(EventCode::ENCRYPTION_CHANGE)) {
      send_event_(bluetooth::hci::EncryptionChangeBuilder::Create(
          status, handle, bluetooth::hci::EncryptionEnabled::ON));
    }
  } else {
    if (IsEventUnmasked(EventCode::ENCRYPTION_CHANGE)) {
      send_event_(bluetooth::hci::EncryptionChangeBuilder::Create(
          status, handle, bluetooth::hci::EncryptionEnabled::OFF));
    }
  }
}