diff options
-rw-r--r-- | .github/workflows/ci.yml | 5 | ||||
-rw-r--r-- | lib/connection.cpp | 6 | ||||
-rw-r--r-- | lib/e2ee/qolmmessage.h | 2 | ||||
-rw-r--r-- | lib/room.cpp | 7 |
4 files changed, 13 insertions, 7 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0bbbc06c..b704b3b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,8 @@ jobs: - os: ubuntu-latest compiler: GCC qt-version: '5.12.12' - sonar: 'sonar' + e2ee: e2ee + sonar: sonar - os: windows-2019 compiler: MSVC platform: x64 @@ -111,7 +112,7 @@ jobs: # Build libQuotient as a shared library across platforms but also # check the static configuration somewhere CMAKE_ARGS="-G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DBUILD_SHARED_LIBS=${{ !matrix.sonar && runner.os == 'Linux' }} \ + -DBUILD_SHARED_LIBS=${{ runner.os == 'Linux' }} \ -DCMAKE_INSTALL_PREFIX=~/.local \ -DCMAKE_PREFIX_PATH=~/.local \ -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON" diff --git a/lib/connection.cpp b/lib/connection.cpp index 24951b42..4abb77a5 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -274,10 +274,10 @@ public: QString decrypted; int type = personalCipherObject.value(TypeKeyL).toInt(-1); QByteArray body = personalCipherObject.value(BodyKeyL).toString().toLatin1(); - if (type == 0) { + if (type == QOlmMessage::PreKey) { QOlmMessage preKeyMessage(body, QOlmMessage::PreKey); decrypted = sessionDecryptPrekey(preKeyMessage, senderKey, account); - } else if (type == 1) { + } else if (type == QOlmMessage::General) { QOlmMessage message(body, QOlmMessage::General); decrypted = sessionDecryptGeneral(message, senderKey); } @@ -777,11 +777,11 @@ void Connection::onSyncSuccess(SyncData&& data, bool fromCache) d->consumeDevicesList(data.takeDevicesList()); #endif // Quotient_E2EE_ENABLED + d->consumeToDeviceEvents(data.takeToDeviceEvents()); d->data->setLastEvent(data.nextBatch()); d->consumeRoomData(data.takeRoomData(), fromCache); d->consumeAccountData(data.takeAccountData()); d->consumePresenceData(data.takePresenceData()); - d->consumeToDeviceEvents(data.takeToDeviceEvents()); #ifdef Quotient_E2EE_ENABLED if(d->encryptionUpdateRequired) { d->loadOutdatedUserDevices(); diff --git a/lib/e2ee/qolmmessage.h b/lib/e2ee/qolmmessage.h index 5d5db636..b4285a93 100644 --- a/lib/e2ee/qolmmessage.h +++ b/lib/e2ee/qolmmessage.h @@ -22,8 +22,8 @@ class QUOTIENT_API QOlmMessage : public QByteArray { Q_GADGET public: enum Type { + PreKey = 0, General, - PreKey, }; Q_ENUM(Type) diff --git a/lib/room.cpp b/lib/room.cpp index ea9915c3..6197b3a2 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -1487,7 +1487,12 @@ RoomEventPtr Room::decryptMessage(const EncryptedEvent& encryptedEvent) // qCWarning(E2EE) << "Encrypted message is empty"; return {}; } - return encryptedEvent.createDecrypted(decrypted); + auto decryptedEvent = encryptedEvent.createDecrypted(decrypted); + if (decryptedEvent->roomId() == id()) { + return decryptedEvent; + } + qCWarning(E2EE) << "Decrypted event" << encryptedEvent.id() << "not for this room; discarding."; + return {}; #endif // Quotient_E2EE_ENABLED } |