summary refs log tree commit diff
path: root/src/ChatPage.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@ymail.com>2022-04-08 05:11:24 +0200
committerNicolas Werner <nicolas.werner@ymail.com>2022-04-08 05:11:24 +0200
commit864b4b2646f8f5daaaeb0810e4668ba6700071fa (patch)
treec4c82e801aa240470389aaa7e69de3f28c09efd9 /src/ChatPage.cpp
parentFix typo in key export (diff)
downloadnheko-864b4b2646f8f5daaaeb0810e4668ba6700071fa.tar.xz
Fix SSSS if another client used the wrong base64 format
Diffstat (limited to 'src/ChatPage.cpp')
-rw-r--r--src/ChatPage.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp
index 0550c7f3..5425d527 100644
--- a/src/ChatPage.cpp
+++ b/src/ChatPage.cpp
@@ -1155,8 +1155,8 @@ ChatPage::decryptDownloadedSecrets(mtx::secret_storage::AesHmacSha2KeyDescriptio
     stripped.remove(' ');
     stripped.remove('\n');
     stripped.remove('\t');
-    auto decryptionKey = mtx::crypto::key_from_recoverykey(stripped.toStdString(), keyDesc);
 
+    auto decryptionKey = mtx::crypto::key_from_recoverykey(stripped.toStdString(), keyDesc);
     if (!decryptionKey && keyDesc.passphrase) {
         try {
             decryptionKey = mtx::crypto::key_from_passphrase(text.toStdString(), keyDesc);
@@ -1180,6 +1180,8 @@ ChatPage::decryptDownloadedSecrets(mtx::secret_storage::AesHmacSha2KeyDescriptio
 
     for (const auto &[secretName, encryptedSecret] : secrets) {
         auto decrypted = mtx::crypto::decrypt(encryptedSecret, *decryptionKey, secretName);
+        nhlog::crypto()->debug("Secret {} decrypted: {}", secretName, !decrypted.empty());
+
         if (!decrypted.empty()) {
             cache::storeSecret(secretName, decrypted);
 
@@ -1222,7 +1224,8 @@ ChatPage::decryptDownloadedSecrets(mtx::secret_storage::AesHmacSha2KeyDescriptio
         }
     }
 
-    if (!req.signatures.empty())
+    if (!req.signatures.empty()) {
+        nhlog::crypto()->debug("Uploading new signatures: {}", json(req).dump(2));
         http::client()->keys_signatures_upload(
           req, [](const mtx::responses::KeySignaturesUpload &res, mtx::http::RequestErr err) {
               if (err) {
@@ -1240,6 +1243,7 @@ ChatPage::decryptDownloadedSecrets(mtx::secret_storage::AesHmacSha2KeyDescriptio
                                           mtx::errors::to_string(e.errcode),
                                           e.error);
           });
+    }
 }
 
 void