aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/connection.cpp4
-rw-r--r--lib/connection.h2
-rw-r--r--lib/database.cpp7
-rw-r--r--lib/database.h2
-rw-r--r--lib/room.cpp6
5 files changed, 11 insertions, 10 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 4abb77a5..11c81edf 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -2150,9 +2150,9 @@ UnorderedMap<std::pair<QString, QString>, QOlmInboundGroupSessionPtr> Connection
return database()->loadMegolmSessions(room->id(), picklingMode());
}
-void Connection::saveMegolmSession(Room* room, const QString& senderKey, QOlmInboundGroupSession* session)
+void Connection::saveMegolmSession(Room* room, const QString& senderKey, QOlmInboundGroupSession* session, const QString& ed25519Key)
{
- database()->saveMegolmSession(room->id(), senderKey, session->sessionId(), session->pickle(picklingMode()));
+ database()->saveMegolmSession(room->id(), senderKey, session->sessionId(), ed25519Key, session->pickle(picklingMode()));
}
QStringList Connection::devicesForUser(User* user) const
diff --git a/lib/connection.h b/lib/connection.h
index 4a475319..a4986b06 100644
--- a/lib/connection.h
+++ b/lib/connection.h
@@ -318,7 +318,7 @@ public:
QOlmAccount* olmAccount() const;
Database* database();
UnorderedMap<std::pair<QString, QString>, QOlmInboundGroupSessionPtr> loadRoomMegolmSessions(Room* room);
- void saveMegolmSession(Room* room, const QString& senderKey, QOlmInboundGroupSession* session);
+ void saveMegolmSession(Room* room, const QString& senderKey, QOlmInboundGroupSession* session, const QString& ed25519Key);
#endif // Quotient_E2EE_ENABLED
Q_INVOKABLE Quotient::SyncJob* syncJob() const;
Q_INVOKABLE int millisToReconnect() const;
diff --git a/lib/database.cpp b/lib/database.cpp
index 84c93046..13b41a70 100644
--- a/lib/database.cpp
+++ b/lib/database.cpp
@@ -83,7 +83,7 @@ void Database::migrateTo1()
transaction();
execute(QStringLiteral("CREATE TABLE accounts (pickle TEXT);"));
execute(QStringLiteral("CREATE TABLE olm_sessions (senderKey TEXT, sessionId TEXT, pickle TEXT);"));
- execute(QStringLiteral("CREATE TABLE inbound_megolm_sessions (roomId TEXT, senderKey TEXT, sessionId TEXT, pickle TEXT);"));
+ execute(QStringLiteral("CREATE TABLE inbound_megolm_sessions (roomId TEXT, senderKey TEXT, sessionId TEXT, ed25519Key TEXT, pickle TEXT);"));
execute(QStringLiteral("CREATE TABLE outbound_megolm_sessions (roomId TEXT, senderKey TEXT, sessionId TEXT, pickle TEXT);"));
execute(QStringLiteral("CREATE TABLE group_session_record_index (roomId TEXT, sessionId TEXT, i INTEGER, eventId TEXT, ts INTEGER);"));
execute(QStringLiteral("CREATE TABLE tracked_users (matrixId TEXT);"));
@@ -179,12 +179,13 @@ UnorderedMap<std::pair<QString, QString>, QOlmInboundGroupSessionPtr> Database::
return sessions;
}
-void Database::saveMegolmSession(const QString& roomId, const QString& senderKey, const QString& sessionId, const QByteArray& pickle)
+void Database::saveMegolmSession(const QString& roomId, const QString& senderKey, const QString& sessionId, const QString& ed25519Key, const QByteArray& pickle)
{
- auto query = prepareQuery(QStringLiteral("INSERT INTO inbound_megolm_sessions(roomId, senderKey, sessionId, pickle) VALUES(:roomId, :senderKey, :sessionId, :pickle);"));
+ auto query = prepareQuery(QStringLiteral("INSERT INTO inbound_megolm_sessions(roomId, senderKey, sessionId, ed25519Key, pickle) VALUES(:roomId, :senderKey, :sessionId, :ed25519Key, :pickle);"));
query.bindValue(":roomId", roomId);
query.bindValue(":senderKey", senderKey);
query.bindValue(":sessionId", sessionId);
+ query.bindValue(":ed25519Key", ed25519Key);
query.bindValue(":pickle", pickle);
transaction();
execute(query);
diff --git a/lib/database.h b/lib/database.h
index d4d5fb56..f6a491fb 100644
--- a/lib/database.h
+++ b/lib/database.h
@@ -30,7 +30,7 @@ public:
void saveOlmSession(const QString& senderKey, const QString& sessionId, const QByteArray &pickle);
UnorderedMap<QString, std::vector<QOlmSessionPtr>> loadOlmSessions(const PicklingMode& picklingMode);
UnorderedMap<std::pair<QString, QString>, QOlmInboundGroupSessionPtr> loadMegolmSessions(const QString& roomId, const PicklingMode& picklingMode);
- void saveMegolmSession(const QString& roomId, const QString& senderKey, const QString& sessionKey, const QByteArray& pickle);
+ void saveMegolmSession(const QString& roomId, const QString& senderKey, const QString& sessionKey, const QString& ed25519Key, const QByteArray& pickle);
void addGroupSessionIndexRecord(const QString& roomId, const QString& sessionId, uint32_t index, const QString& eventId, qint64 ts);
std::pair<QString, qint64> groupSessionIndexRecord(const QString& roomId, const QString& sessionId, qint64 index);
void clearRoomData(const QString& roomId);
diff --git a/lib/room.cpp b/lib/room.cpp
index 6197b3a2..88aa1d07 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -341,7 +341,7 @@ public:
UnorderedMap<std::pair<QString, QString>, QOlmInboundGroupSessionPtr> groupSessions;
bool addInboundGroupSession(QString senderKey, QString sessionId,
- QString sessionKey)
+ QString sessionKey, QString ed25519Key)
{
if (groupSessions.find({senderKey, sessionId}) != groupSessions.end()) {
qCWarning(E2EE) << "Inbound Megolm session" << sessionId
@@ -356,7 +356,7 @@ public:
return false;
}
qCWarning(E2EE) << "Adding inbound session";
- connection->saveMegolmSession(q, senderKey, megolmSession.get());
+ connection->saveMegolmSession(q, senderKey, megolmSession.get(), ed25519Key);
groupSessions[{senderKey, sessionId}] = std::move(megolmSession);
return true;
}
@@ -1509,7 +1509,7 @@ void Room::handleRoomKeyEvent(const RoomKeyEvent& roomKeyEvent,
<< roomKeyEvent.algorithm() << "in m.room_key event";
}
if (d->addInboundGroupSession(senderKey, roomKeyEvent.sessionId(),
- roomKeyEvent.sessionKey())) {
+ roomKeyEvent.sessionKey(), roomKeyEvent.fullJson()["keys"]["ed25519"].toString())) {
qCWarning(E2EE) << "added new inboundGroupSession:"
<< d->groupSessions.size();
for (const auto& eventId : d->undecryptedEvents[roomKeyEvent.sessionId()]) {