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

Commit b8338171 authored by Rahul Arya's avatar Rahul Arya Committed by Gerrit Code Review
Browse files

Merge "[RootCanal] Check encryption response status"

parents c7c0511c ec987663
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -4329,9 +4329,11 @@ void LinkLayerController::IncomingLeEncryptConnectionResponse(
      model::packets::LeEncryptConnectionResponseView::Create(incoming);
      model::packets::LeEncryptConnectionResponseView::Create(incoming);
  ASSERT(response.IsValid());
  ASSERT(response.IsValid());


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


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