summary refs log tree commit diff
path: root/src/encryption
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2021-11-08 18:32:19 -0500
committerJoseph Donofry <joedonofry@gmail.com>2021-11-08 18:32:19 -0500
commitc93a7b24353a98b09949baf3ca4d8de8439cfa4a (patch)
tree53adf948d663566e198d00ad179acc4465e329c3 /src/encryption
parentFix syntax issue (diff)
parentRemove appimage (diff)
downloadnheko-c93a7b24353a98b09949baf3ca4d8de8439cfa4a.tar.xz
Merge remote-tracking branch 'nheko-im/master' into video_player_enhancements
Diffstat (limited to 'src/encryption')
-rw-r--r--src/encryption/SelfVerificationStatus.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/encryption/SelfVerificationStatus.cpp b/src/encryption/SelfVerificationStatus.cpp

index ebb6b548..c4f4f196 100644 --- a/src/encryption/SelfVerificationStatus.cpp +++ b/src/encryption/SelfVerificationStatus.cpp
@@ -4,6 +4,8 @@ #include "SelfVerificationStatus.h" +#include <QApplication> + #include "Cache_p.h" #include "ChatPage.h" #include "Logging.h" @@ -18,13 +20,13 @@ SelfVerificationStatus::SelfVerificationStatus(QObject *o) : QObject(o) { - connect(MainWindow::instance(), &MainWindow::reload, this, [this] { + connect(ChatPage::instance(), &ChatPage::contentLoaded, this, [this] { connect(cache::client(), &Cache::selfVerificationStatusChanged, this, &SelfVerificationStatus::invalidate, Qt::UniqueConnection); - invalidate(); + cache::client()->markUserKeysOutOfDate({http::client()->user_id().to_string()}); }); } @@ -82,7 +84,7 @@ SelfVerificationStatus::setupCrosssigning(bool useSSSS, QString password, bool u ssss = olm::client()->create_ssss_key(password.toStdString()); if (!ssss) { nhlog::crypto()->critical("Failed to setup secure server side secret storage!"); - emit setupFailed(tr("Failed to create keys secure server side secret storage!")); + emit setupFailed(tr("Failed to create keys for secure server side secret storage!")); return; } @@ -259,15 +261,29 @@ SelfVerificationStatus::invalidate() using namespace mtx::secret_storage; nhlog::db()->info("Invalidating self verification status"); + if (!cache::isInitialized()) { + nhlog::db()->warn("SelfVerificationStatus: cache not initialized"); + return; + } + this->hasSSSS_ = false; emit hasSSSSChanged(); auto keys = cache::client()->userKeys(http::client()->user_id().to_string()); if (!keys || keys->device_keys.find(http::client()->device_id()) == keys->device_keys.end()) { + if (keys && (keys->seen_device_ids.count(http::client()->device_id()) || + keys->seen_device_keys.count(olm::client()->identity_keys().curve25519))) { + emit ChatPage::instance()->dropToLoginPageCb( + tr("Identity key changed. This breaks E2EE, so logging out.")); + return; + } + cache::client()->markUserKeysOutOfDate({http::client()->user_id().to_string()}); - cache::client()->query_keys(http::client()->user_id().to_string(), - [](const UserKeyCache &, mtx::http::RequestErr) {}); - return; + + QTimer::singleShot(1'000, [] { + cache::client()->query_keys(http::client()->user_id().to_string(), + [](const UserKeyCache &, mtx::http::RequestErr) {}); + }); } if (keys->master_keys.keys.empty()) {