aboutsummaryrefslogtreecommitdiff
path: root/lib/connection.cpp
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-06-01 08:05:21 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-06-01 08:05:21 +0200
commitcd442611b19ec4a438d0847bf09b7bca99b494d3 (patch)
treea4f31a647f5aa30164643f02be2e36f0ef715b6b /lib/connection.cpp
parentec75d2d0e9601dcf32387120ca67135ac7e7f472 (diff)
downloadlibquotient-cd442611b19ec4a438d0847bf09b7bca99b494d3.tar.gz
libquotient-cd442611b19ec4a438d0847bf09b7bca99b494d3.zip
Fix FTBFS after the merge
Diffstat (limited to 'lib/connection.cpp')
-rw-r--r--lib/connection.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 102fb16d..7885718f 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -376,7 +376,7 @@ public:
const QByteArray& message) const;
bool createOlmSession(const QString& targetUserId,
const QString& targetDeviceId,
- const QJsonObject& oneTimeKeyObject);
+ const OneTimeKeys &oneTimeKeyObject);
QString curveKeyForUserDevice(const QString& userId,
const QString& device) const;
QString edKeyForUserDevice(const QString& userId,
@@ -2306,7 +2306,7 @@ std::pair<QOlmMessage::Type, QByteArray> Connection::Private::olmEncryptMessage(
bool Connection::Private::createOlmSession(const QString& targetUserId,
const QString& targetDeviceId,
- const QJsonObject& oneTimeKeyObject)
+ const OneTimeKeys& oneTimeKeyObject)
{
static QOlmUtility verifier;
qDebug(E2EE) << "Creating a new session for" << targetUserId
@@ -2316,17 +2316,23 @@ bool Connection::Private::createOlmSession(const QString& targetUserId,
<< targetDeviceId;
return false;
}
- auto signedOneTimeKey = oneTimeKeyObject.constBegin()->toObject();
+ auto* signedOneTimeKey =
+ std::get_if<SignedOneTimeKey>(&*oneTimeKeyObject.begin());
+ if (!signedOneTimeKey) {
+ qWarning(E2EE) << "No signed one time key for" << targetUserId
+ << targetDeviceId;
+ return false;
+ }
// Verify contents of signedOneTimeKey - for that, drop `signatures` and
// `unsigned` and then verify the object against the respective signature
const auto signature =
- signedOneTimeKey.take("signatures"_ls)[targetUserId]["ed25519:"_ls % targetDeviceId]
- .toString()
+ signedOneTimeKey
+ ->signatures[targetUserId]["ed25519:"_ls % targetDeviceId]
.toLatin1();
- signedOneTimeKey.remove("unsigned"_ls);
if (!verifier.ed25519Verify(
edKeyForUserDevice(targetUserId, targetDeviceId).toLatin1(),
- QJsonDocument(signedOneTimeKey).toJson(QJsonDocument::Compact),
+ QJsonDocument(toJson(SignedOneTimeKey { signedOneTimeKey->key, {} }))
+ .toJson(QJsonDocument::Compact),
signature)) {
qWarning(E2EE) << "Failed to verify one-time-key signature for" << targetUserId
<< targetDeviceId << ". Skipping this device.";
@@ -2336,7 +2342,7 @@ bool Connection::Private::createOlmSession(const QString& targetUserId,
curveKeyForUserDevice(targetUserId, targetDeviceId);
auto session =
QOlmSession::createOutboundSession(olmAccount.get(), recipientCurveKey,
- signedOneTimeKey["key"].toString());
+ signedOneTimeKey->key);
if (!session) {
qCWarning(E2EE) << "Failed to create olm session for "
<< recipientCurveKey << session.error();