summary refs log tree commit diff
path: root/src/Cache.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-09-03 15:08:16 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2021-09-03 15:08:16 +0200
commit99f3296a644b50d4189a5cfd7785f2c53acafacf (patch)
tree713e47c1c41a1f72c70f30a0125fadd0072b0ba5 /src/Cache.cpp
parentFix room ping permission checked incorrectly (diff)
downloadnheko-99f3296a644b50d4189a5cfd7785f2c53acafacf.tar.xz
Make error case with unverified master key more descriptive
Diffstat (limited to 'src/Cache.cpp')
-rw-r--r--src/Cache.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp
index a7fe473f..5842f536 100644
--- a/src/Cache.cpp
+++ b/src/Cache.cpp
@@ -4442,13 +4442,19 @@ Cache::verificationStatus_(const std::string &user_id, lmdb::txn &txn)
                 // Update verified devices count to count without cross-signing
                 updateUnverifiedDevices(theirKeys->device_keys);
 
-                if (!mtx::crypto::ed25519_verify_signature(
-                      olm::client()->identity_keys().ed25519,
-                      json(ourKeys->master_keys),
-                      ourKeys->master_keys.signatures.at(local_user)
-                        .at("ed25519:" + http::client()->device_id()))) {
-                        verification_storage.status[user_id] = status;
-                        return status;
+                {
+                        auto &mk           = ourKeys->master_keys;
+                        std::string dev_id = "ed25519:" + http::client()->device_id();
+                        if (!mk.signatures.count(local_user) ||
+                            !mk.signatures.at(local_user).count(dev_id) ||
+                            !mtx::crypto::ed25519_verify_signature(
+                              olm::client()->identity_keys().ed25519,
+                              json(mk),
+                              mk.signatures.at(local_user).at(dev_id))) {
+                                nhlog::crypto()->debug("We have not verified our own master key");
+                                verification_storage.status[user_id] = status;
+                                return status;
+                        }
                 }
 
                 auto master_keys = ourKeys->master_keys.keys;