[network/ruqola] src/core/encryption: Allow to decrypt one room
Laurent Montel <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit e3420cb785adc7e4976b5764bc5ef5789268e3bc by Laurent Montel.
Committed on 06/08/2026 at 05:20.
Pushed by mlaurent into branch 'master'.
Allow to decrypt one room
M +24 -3 src/core/encryption/e2ekeymanager.cpp
M +2 -0 src/core/encryption/e2ekeymanager.h
https://invent.kde.org/network/ruqola/-/commit/e3420cb785adc7e4976b5764bc5ef5789268e3bc
diff --git a/src/core/encryption/e2ekeymanager.cpp b/src/core/encryption/e2ekeymanager.cpp
index 63b13b3fbc..e16db85f62 100644
--- a/src/core/encryption/e2ekeymanager.cpp
+++ b/src/core/encryption/e2ekeymanager.cpp
@@ -587,9 +587,9 @@ bool E2eKeyManager::decryptRoomsSessionKeys() const
}
RoomModel *model = mAccount->roomModel();
- for (Room *room : model->rooms()) {
- if (!room->e2EKey().isEmpty()) {
- room->decryptSessionKeyWithPrivateKey(privateKey);
+ for (Room *r : model->rooms()) {
+ if (!r->e2EKey().isEmpty()) {
+ r->decryptSessionKeyWithPrivateKey(privateKey);
}
}
@@ -598,4 +598,25 @@ bool E2eKeyManager::decryptRoomsSessionKeys() const
return true;
}
+bool E2eKeyManager::decryptRoomSessionKeys(Room *r) const
+{
+#if USE_E2E_SUPPORT
+ if (mDecodedPrivateKey.isEmpty()) {
+ return false;
+ }
+
+ RSA *privateKey = EncryptionUtils::privateKeyFromPEM(mDecodedPrivateKey);
+ if (!privateKey) {
+ qCWarning(RUQOLA_ENCRYPTION_LOG) << "decryptRoomsSessionKeys: failed to load private key from PEM";
+ return false;
+ }
+
+ if (!r->e2EKey().isEmpty()) {
+ r->decryptSessionKeyWithPrivateKey(privateKey);
+ }
+ RSA_free(privateKey);
+#endif
+ return true;
+}
+
#include "moc_e2ekeymanager.cpp"
diff --git a/src/core/encryption/e2ekeymanager.h b/src/core/encryption/e2ekeymanager.h
index e71e0c33eb..3209b5f4d0 100644
--- a/src/core/encryption/e2ekeymanager.h
+++ b/src/core/encryption/e2ekeymanager.h
@@ -14,6 +14,7 @@ namespace QKeychain
{
class Job;
}
+class Room;
class LIBRUQOLACORE_EXPORT E2eKeyManager : public QObject
{
Q_OBJECT
@@ -50,6 +51,7 @@ public:
void verifyExistingKeyForTest(const QJsonObject &json);
[[nodiscard]] bool decryptRoomsSessionKeys() const;
+ [[nodiscard]] bool decryptRoomSessionKeys(Room *r) const;
Q_SIGNALS:
void needDecodeEncryptionKey();