Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>2022-08-24 20:22:10 +0300
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>2022-09-11 17:17:23 +0300
commit16b044b51d4c9db12bafa4e8d6eaf32554620dea (patch)
tree823063dc84cab0db788313063ecca20ae60643fe
parent6c2962420267e3f4d21c3b2a871d2258ed55697b (diff)
ensure we do not generate E2EE keys without user intent
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
-rw-r--r--src/gui/accountsettings.cpp8
-rw-r--r--src/gui/accountsettings.h2
-rw-r--r--src/libsync/clientsideencryption.cpp9
-rw-r--r--src/libsync/clientsideencryption.h3
4 files changed, 14 insertions, 8 deletions
diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp
index d46cce6ca..ff46ee7da 100644
--- a/src/gui/accountsettings.cpp
+++ b/src/gui/accountsettings.cpp
@@ -226,9 +226,9 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
connect(this, &AccountSettings::requestMnemonic, _accountState->account()->e2e(), &ClientSideEncryption::slotRequestMnemonic);
connect(_accountState->account()->e2e(), &ClientSideEncryption::showMnemonic, this, &AccountSettings::slotShowMnemonic);
- connect(_accountState->account()->e2e(), &ClientSideEncryption::mnemonicGeneratedChanged, this, &AccountSettings::slotNewMnemonicGenerated);
- if (_accountState->account()->e2e()->newMnemonicGenerated()) {
- slotNewMnemonicGenerated();
+ connect(_accountState->account()->e2e(), &ClientSideEncryption::mnemonicGeneratedChanged, this, &AccountSettings::slotOfferEnableE2EE);
+ if (!_accountState->account()->e2e()->newMnemonicGenerated()) {
+ slotOfferEnableE2EE();
} else {
_ui->encryptionMessage->setText(tr("This account supports End-to-End encryption"));
@@ -249,7 +249,7 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
customizeStyle();
}
-void AccountSettings::slotNewMnemonicGenerated()
+void AccountSettings::slotOfferEnableE2EE()
{
_ui->encryptionMessage->setText(tr("This account supports End-to-End encryption"));
diff --git a/src/gui/accountsettings.h b/src/gui/accountsettings.h
index a9908138f..ec2f564f8 100644
--- a/src/gui/accountsettings.h
+++ b/src/gui/accountsettings.h
@@ -105,7 +105,7 @@ protected slots:
// Encryption Related Stuff.
void slotShowMnemonic(const QString &mnemonic);
- void slotNewMnemonicGenerated();
+ void slotOfferEnableE2EE();
void slotEncryptFolderFinished(int status);
void slotSelectiveSyncChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
diff --git a/src/libsync/clientsideencryption.cpp b/src/libsync/clientsideencryption.cpp
index 0c66c6b43..5ddcc2051 100644
--- a/src/libsync/clientsideencryption.cpp
+++ b/src/libsync/clientsideencryption.cpp
@@ -1191,6 +1191,11 @@ void ClientSideEncryption::slotRequestMnemonic()
emit showMnemonic(_mnemonic);
}
+void ClientSideEncryption::checkServerForKeys(const AccountPtr &account)
+{
+ fetchAndValidatePublicKeyFromServer(account);
+}
+
void ClientSideEncryption::generateKeyPair(const AccountPtr &account)
{
// AES/GCM/NoPadding,
@@ -1452,8 +1457,8 @@ void ClientSideEncryption::getPublicKeyFromServer(const AccountPtr &account)
fetchAndValidatePublicKeyFromServer(account);
} else if (retCode == 404) {
setServerHasPublicKey(false);
- qCInfo(lcCse()) << "No public key on the server";
- generateKeyPair(account);
+ qCInfo(lcCse()) << "No public key on the server. End to end encryption has not been enabled.";
+ emit initializationFinished();
} else {
setServerHasPublicKey(false);
qCInfo(lcCse()) << "Error while requesting public key: " << retCode;
diff --git a/src/libsync/clientsideencryption.h b/src/libsync/clientsideencryption.h
index ea077ffb3..5ee7352f7 100644
--- a/src/libsync/clientsideencryption.h
+++ b/src/libsync/clientsideencryption.h
@@ -138,6 +138,8 @@ public:
void forgetSensitiveData(const AccountPtr &account);
bool newMnemonicGenerated() const;
+
+ void checkServerForKeys(const AccountPtr &account);
public slots:
void slotRequestMnemonic();
@@ -169,7 +171,6 @@ private:
void generateKeyPair(const AccountPtr &account);
void generateCSR(const AccountPtr &account, EVP_PKEY *keyPair);
void encryptPrivateKey(const AccountPtr &account);
-
void getPrivateKeyFromServer(const AccountPtr &account);
void getPublicKeyFromServer(const AccountPtr &account);
void fetchAndValidatePublicKeyFromServer(const AccountPtr &account);