Skip to content

Commit

Permalink
Added error reporting for E2EE issues.
Browse files Browse the repository at this point in the history
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed Nov 30, 2023
1 parent 6a0eb55 commit 995f801
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/libsync/clientsideencryption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,7 @@ bool ClientSideEncryption::sensitiveDataRemaining() const
void ClientSideEncryption::failedToInitialize(const AccountPtr &account)
{
forgetSensitiveData(account);
account->reportClientStatus(OCC::ClientStatusReporting::Status::E2EeError_GeneralError);
Q_EMIT initializationFinished();
}

Expand Down Expand Up @@ -1775,6 +1776,7 @@ void FolderMetadata::setupExistingMetadata(const QByteArray& metadata)

if (metadataKeys.isEmpty()) {
qCDebug(lcCse()) << "Could not migrate. No metadata keys found!";
_account->reportClientStatus(OCC::ClientStatusReporting::Status::E2EeError_GeneralError);
return;
}

Expand All @@ -1787,6 +1789,7 @@ void FolderMetadata::setupExistingMetadata(const QByteArray& metadata)

if (_metadataKey.isEmpty()) {
qCDebug(lcCse()) << "Could not setup existing metadata with missing metadataKeys!";
_account->reportClientStatus(OCC::ClientStatusReporting::Status::E2EeError_GeneralError);
return;
}

Expand Down Expand Up @@ -1861,6 +1864,7 @@ void FolderMetadata::setupExistingMetadata(const QByteArray& metadata)
} else {
_metadataKey.clear();
_files.clear();
_account->reportClientStatus(OCC::ClientStatusReporting::Status::E2EeError_GeneralError);
return;
}
}
Expand Down Expand Up @@ -1899,6 +1903,7 @@ QByteArray FolderMetadata::decryptData(const QByteArray &data) const
if (decryptResult.isEmpty())
{
qCDebug(lcCse()) << "ERROR. Could not decrypt the metadata key";
_account->reportClientStatus(OCC::ClientStatusReporting::Status::E2EeError_GeneralError);
return {};
}
return QByteArray::fromBase64(decryptResult);
Expand All @@ -1916,6 +1921,7 @@ QByteArray FolderMetadata::decryptDataUsingKey(const QByteArray &data,
if (decryptResult.isEmpty())
{
qCDebug(lcCse()) << "ERROR. Could not decrypt";
_account->reportClientStatus(OCC::ClientStatusReporting::Status::E2EeError_GeneralError);
return {};
}

Expand Down Expand Up @@ -1979,6 +1985,7 @@ QByteArray FolderMetadata::encryptedMetadata() const {

if (_metadataKey.isEmpty()) {
qCDebug(lcCse) << "Metadata generation failed! Empty metadata key!";
_account->reportClientStatus(OCC::ClientStatusReporting::Status::E2EeError_GeneralError);
return {};
}
const auto version = _account->capabilities().clientSideEncryptionVersion();
Expand All @@ -2000,6 +2007,7 @@ QByteArray FolderMetadata::encryptedMetadata() const {

QString encryptedEncrypted = encryptJsonObject(encryptedDoc.toJson(QJsonDocument::Compact), _metadataKey);
if (encryptedEncrypted.isEmpty()) {
_account->reportClientStatus(OCC::ClientStatusReporting::Status::E2EeError_GeneralError);
qCDebug(lcCse) << "Metadata generation failed!";
}
QJsonObject file;
Expand Down Expand Up @@ -2087,6 +2095,7 @@ bool FolderMetadata::moveFromFileDropToFiles()

if (decryptedKey.isEmpty() || decryptedAuthenticationTag.isEmpty() || decryptedInitializationVector.isEmpty()) {
qCDebug(lcCseMetadata) << "failed to decrypt filedrop entry" << it.key();
_account->reportClientStatus(OCC::ClientStatusReporting::Status::E2EeError_GeneralError);
continue;
}

Expand Down

0 comments on commit 995f801

Please sign in to comment.