Skip to content

Commit

Permalink
make sure we clean only what is needed if e2ee is disabled
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu Gallien <[email protected]>
  • Loading branch information
mgallien committed Jun 30, 2023
1 parent c4f0e65 commit 2d7158d
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/libsync/clientsideencryption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1054,8 +1054,7 @@ void ClientSideEncryption::privateKeyFetched(Job *incoming)

// Error or no valid public key error out
if (readJob->error() != NoError || readJob->binaryData().length() == 0) {
_certificate = QSslCertificate();
_publicKey = QSslKey();
forgetSensitiveData(account);
getPublicKeyFromServer(account);
return;
}
Expand Down Expand Up @@ -1092,9 +1091,7 @@ void ClientSideEncryption::mnemonicKeyFetched(QKeychain::Job *incoming)

// Error or no valid public key error out
if (readJob->error() != NoError || readJob->textData().length() == 0) {
_certificate = QSslCertificate();
_publicKey = QSslKey();
_privateKey = QByteArray();
forgetSensitiveData(account);
getPublicKeyFromServer(account);
return;
}
Expand Down Expand Up @@ -1180,8 +1177,6 @@ void ClientSideEncryption::writeMnemonic(OCC::AccountPtr account,

void ClientSideEncryption::forgetSensitiveData(const AccountPtr &account)
{
_publicKey = QSslKey();

if (!sensitiveDataRemaining()) {
checkAllSensitiveDataDeleted();
return;
Expand All @@ -1198,12 +1193,10 @@ void ClientSideEncryption::forgetSensitiveData(const AccountPtr &account)
const auto deletePrivateKeyJob = createDeleteJob(user + e2e_private);
const auto deleteCertJob = createDeleteJob(user + e2e_cert);
const auto deleteMnemonicJob = createDeleteJob(user + e2e_mnemonic);
const auto deletePublicKeyJob = createDeleteJob(user + e2e_public);

connect(deletePrivateKeyJob, &DeletePasswordJob::finished, this, &ClientSideEncryption::handlePrivateKeyDeleted);
connect(deleteCertJob, &DeletePasswordJob::finished, this, &ClientSideEncryption::handleCertificateDeleted);
connect(deleteMnemonicJob, &DeletePasswordJob::finished, this, &ClientSideEncryption::handleMnemonicDeleted);
connect(deletePublicKeyJob, &DeletePasswordJob::finished, this, &ClientSideEncryption::handlePublicKeyDeleted);
deletePrivateKeyJob->start();
deleteCertJob->start();
deleteMnemonicJob->start();
Expand Down Expand Up @@ -1742,9 +1735,7 @@ void ClientSideEncryption::fetchAndValidatePublicKeyFromServer(const AccountPtr
}
} else {
qCInfo(lcCse()) << "Error invalid server public key";
_certificate = QSslCertificate();
_publicKey = QSslKey();
_privateKey = QByteArray();
forgetSensitiveData(account);
getPublicKeyFromServer(account);
return;
}
Expand Down

0 comments on commit 2d7158d

Please sign in to comment.