From 89c7b970b3e598e5d57875d5a2532a2a57114d88 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Tue, 27 Jun 2023 23:29:25 +0200 Subject: [PATCH] make sure we clean only what is needed if e2ee is disabled Signed-off-by: Matthieu Gallien --- src/libsync/clientsideencryption.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/libsync/clientsideencryption.cpp b/src/libsync/clientsideencryption.cpp index ba74be6d6dad..220fbd00036d 100644 --- a/src/libsync/clientsideencryption.cpp +++ b/src/libsync/clientsideencryption.cpp @@ -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; } @@ -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; } @@ -1180,8 +1177,6 @@ void ClientSideEncryption::writeMnemonic(OCC::AccountPtr account, void ClientSideEncryption::forgetSensitiveData(const AccountPtr &account) { - _publicKey = QSslKey(); - if (!sensitiveDataRemaining()) { checkAllSensitiveDataDeleted(); return; @@ -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(); @@ -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; }