Fix SSSS if another client used the wrong base64 format

This commit is contained in:
Nicolas Werner 2022-04-08 05:11:24 +02:00
parent cf38e6974a
commit 864b4b2646
3 changed files with 8 additions and 4 deletions

View file

@ -401,7 +401,7 @@ if(USE_BUNDLED_MTXCLIENT)
FetchContent_Declare( FetchContent_Declare(
MatrixClient MatrixClient
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
GIT_TAG c5e8def06f0fc64aa150f30d5c9c366e876120e1 GIT_TAG 8781d1a13b8ac3771d39d402449c5c06bf68b73a
) )
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "") set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "") set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")

View file

@ -176,7 +176,7 @@ modules:
buildsystem: cmake-ninja buildsystem: cmake-ninja
name: mtxclient name: mtxclient
sources: sources:
- commit: c5e8def06f0fc64aa150f30d5c9c366e876120e1 - commit: 8781d1a13b8ac3771d39d402449c5c06bf68b73a
#tag: v0.7.0 #tag: v0.7.0
type: git type: git
url: https://github.com/Nheko-Reborn/mtxclient.git url: https://github.com/Nheko-Reborn/mtxclient.git

View file

@ -1155,8 +1155,8 @@ ChatPage::decryptDownloadedSecrets(mtx::secret_storage::AesHmacSha2KeyDescriptio
stripped.remove(' '); stripped.remove(' ');
stripped.remove('\n'); stripped.remove('\n');
stripped.remove('\t'); 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) { if (!decryptionKey && keyDesc.passphrase) {
try { try {
decryptionKey = mtx::crypto::key_from_passphrase(text.toStdString(), keyDesc); 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) { for (const auto &[secretName, encryptedSecret] : secrets) {
auto decrypted = mtx::crypto::decrypt(encryptedSecret, *decryptionKey, secretName); auto decrypted = mtx::crypto::decrypt(encryptedSecret, *decryptionKey, secretName);
nhlog::crypto()->debug("Secret {} decrypted: {}", secretName, !decrypted.empty());
if (!decrypted.empty()) { if (!decrypted.empty()) {
cache::storeSecret(secretName, decrypted); 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( http::client()->keys_signatures_upload(
req, [](const mtx::responses::KeySignaturesUpload &res, mtx::http::RequestErr err) { req, [](const mtx::responses::KeySignaturesUpload &res, mtx::http::RequestErr err) {
if (err) { if (err) {
@ -1240,6 +1243,7 @@ ChatPage::decryptDownloadedSecrets(mtx::secret_storage::AesHmacSha2KeyDescriptio
mtx::errors::to_string(e.errcode), mtx::errors::to_string(e.errcode),
e.error); e.error);
}); });
}
} }
void void