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

Commit 7d505e76 authored by Rahul Arya's avatar Rahul Arya Committed by Automerger Merge Worker
Browse files

Merge "[RootCanal] Check encryption response status" am: b8338171

parents b8b10fa0 b8338171
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));
    }
  }
}