aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelvin Keskin <melvo@olomono.de>2022-03-07 14:58:29 +0100
committerLinus Jahn <lnj@kaidan.im>2022-03-07 20:19:29 +0100
commitebbf58a05ca112b7e56df8aa072f410398a86dae (patch)
tree414f3459888096124d4b3a1846c355ce2d0f290d
parent76965a11aa4d230ae8636c67e0e6f9ce20f5ec5c (diff)
downloadqxmpp-ebbf58a05ca112b7e56df8aa072f410398a86dae.tar.gz
Add parameter 'keyOwnerJid' to trust storages' 'trustLevel()'
-rw-r--r--src/client/QXmppAtmManager.cpp2
-rw-r--r--src/client/QXmppTrustMemoryStorage.cpp4
-rw-r--r--src/client/QXmppTrustMemoryStorage.h2
-rw-r--r--src/client/QXmppTrustStorage.cpp3
-rw-r--r--src/client/QXmppTrustStorage.h2
-rw-r--r--tests/qxmppatmmanager/tst_qxmppatmmanager.cpp8
-rw-r--r--tests/qxmpptrustmemorystorage/tst_qxmpptrustmemorystorage.cpp8
7 files changed, 23 insertions, 6 deletions
diff --git a/src/client/QXmppAtmManager.cpp b/src/client/QXmppAtmManager.cpp
index 2c9a8568..aef42d4d 100644
--- a/src/client/QXmppAtmManager.cpp
+++ b/src/client/QXmppAtmManager.cpp
@@ -301,7 +301,7 @@ QFuture<void> QXmppAtmManager::handleMessage(const QXmppMessage &message)
const auto senderKey = e2eeMetadata ? e2eeMetadata->senderKey() : QByteArray();
const auto encryption = trustMessageElement->encryption();
- auto future = m_trustStorage->trustLevel(encryption, senderKey);
+ auto future = m_trustStorage->trustLevel(encryption, senderJid, senderKey);
await(future, this, [=](const auto &&senderKeyTrustLevel) mutable {
const auto isSenderKeyAuthenticated = senderKeyTrustLevel == QXmppTrustStorage::Authenticated;
diff --git a/src/client/QXmppTrustMemoryStorage.cpp b/src/client/QXmppTrustMemoryStorage.cpp
index 5a1b6e61..c9e2f37f 100644
--- a/src/client/QXmppTrustMemoryStorage.cpp
+++ b/src/client/QXmppTrustMemoryStorage.cpp
@@ -223,11 +223,11 @@ QFuture<void> QXmppTrustMemoryStorage::setTrustLevel(const QString &encryption,
return makeReadyFuture();
}
-QFuture<QXmppTrustStorage::TrustLevel> QXmppTrustMemoryStorage::trustLevel(const QString &encryption, const QByteArray &keyId)
+QFuture<QXmppTrustStorage::TrustLevel> QXmppTrustMemoryStorage::trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId)
{
const auto keys = d->keys.values(encryption);
for (const auto &key : keys) {
- if (key.id == keyId) {
+ if (key.id == keyId && key.ownerJid == keyOwnerJid) {
return makeReadyFuture(std::move(QXmppTrustStorage::TrustLevel(key.trustLevel)));
}
}
diff --git a/src/client/QXmppTrustMemoryStorage.h b/src/client/QXmppTrustMemoryStorage.h
index abab2d6a..c9d15fe9 100644
--- a/src/client/QXmppTrustMemoryStorage.h
+++ b/src/client/QXmppTrustMemoryStorage.h
@@ -36,7 +36,7 @@ public:
QFuture<void> setTrustLevel(const QString &encryption, const QMultiHash<QString, QByteArray> &keyIds, TrustLevel trustLevel) override;
QFuture<void> setTrustLevel(const QString &encryption, const QList<QString> &keyOwnerJids, TrustLevel oldTrustLevel, TrustLevel newTrustLevel) override;
- QFuture<TrustLevel> trustLevel(const QString &encryption, const QByteArray &keyId) override;
+ QFuture<TrustLevel> trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId) override;
QFuture<void> resetAll(const QString &encryption) override;
/// \endcond
diff --git a/src/client/QXmppTrustStorage.cpp b/src/client/QXmppTrustStorage.cpp
index 149eccfe..5cfe5b95 100644
--- a/src/client/QXmppTrustStorage.cpp
+++ b/src/client/QXmppTrustStorage.cpp
@@ -176,13 +176,14 @@
///
///
-/// \fn QXmppTrustStorage::trustLevel(const QString &encryption, const QByteArray &keyId)
+/// \fn QXmppTrustStorage::trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId)
///
/// Returns the trust level of a key.
///
/// If the key is not stored, the trust in that key is undecided.
///
/// \param encryption encryption protocol namespace
+/// \param keyOwnerJid key owner's bare JID
/// \param keyId ID of the key
///
/// \return the key's trust level
diff --git a/src/client/QXmppTrustStorage.h b/src/client/QXmppTrustStorage.h
index dffbcfae..c1db773d 100644
--- a/src/client/QXmppTrustStorage.h
+++ b/src/client/QXmppTrustStorage.h
@@ -55,7 +55,7 @@ public:
virtual QFuture<void> setTrustLevel(const QString &encryption, const QMultiHash<QString, QByteArray> &keyIds, TrustLevel trustLevel) = 0;
virtual QFuture<void> setTrustLevel(const QString &encryption, const QList<QString> &keyOwnerJids, TrustLevel oldTrustLevel, TrustLevel newTrustLevel) = 0;
- virtual QFuture<TrustLevel> trustLevel(const QString &encryption, const QByteArray &keyId) = 0;
+ virtual QFuture<TrustLevel> trustLevel(const QString &encryption, const QString &keyOwnerJid, const QByteArray &keyId) = 0;
virtual QFuture<void> resetAll(const QString &encryption) = 0;
};
diff --git a/tests/qxmppatmmanager/tst_qxmppatmmanager.cpp b/tests/qxmppatmmanager/tst_qxmppatmmanager.cpp
index 215d7e8c..f8a55896 100644
--- a/tests/qxmppatmmanager/tst_qxmppatmmanager.cpp
+++ b/tests/qxmppatmmanager/tst_qxmppatmmanager.cpp
@@ -1683,6 +1683,7 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsSoleOwnKeyDistrusted()
QVERIFY2(!unexpectedTrustMessageSentSpy.wait(UNEXPECTED_TRUST_MESSAGE_WAITING_TIMEOUT), "Unexpected trust message sent!");
auto futureTrustLevel = m_trustStorage->trustLevel(ns_omemo,
+ QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("RwyI/3m9l4wgju9JduFxb5MEJvBNRDfPfo1Ewhl1DEI=")));
QVERIFY(futureTrustLevel.isFinished());
auto result = futureTrustLevel.result();
@@ -2026,6 +2027,7 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsSoleContactKeyDistrusted()
QVERIFY2(!unexpectedTrustMessageSentSpy.wait(UNEXPECTED_TRUST_MESSAGE_WAITING_TIMEOUT), "Unexpected trust message sent!");
const auto futureTrustLevel = m_trustStorage->trustLevel(ns_omemo,
+ QStringLiteral("bob@example.com"),
QByteArray::fromBase64(QByteArrayLiteral("+1VJvMLCGvkDquZ6mQZ+SS+gTbQ436BJUwFOoW0Ma1g=")));
QVERIFY(futureTrustLevel.isFinished());
const auto result = futureTrustLevel.result();
@@ -2035,18 +2037,21 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsSoleContactKeyDistrusted()
void tst_QXmppAtmManager::testMakeTrustDecisionsOwnKeysDone()
{
auto future = m_trustStorage->trustLevel(ns_omemo,
+ QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("0RcVsGk3LnpEFsqqztTzAgCDgVXlfa03paSqJFOOWOU=")));
QVERIFY(future.isFinished());
auto result = future.result();
QCOMPARE(result, QXmppTrustStorage::Authenticated);
future = m_trustStorage->trustLevel(ns_omemo,
+ QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("tYn/wcIOxBSoW4W1UfPr/zgbLipBK2KsFfC7F1bzut0=")));
QVERIFY(future.isFinished());
result = future.result();
QCOMPARE(result, QXmppTrustStorage::Authenticated);
future = m_trustStorage->trustLevel(ns_omemo,
+ QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("4iBsyJPVAfNWM/OgyA9fasOvkJ8K1/0wuYpwVGw4Q5M=")));
QVERIFY(future.isFinished());
result = future.result();
@@ -2056,18 +2061,21 @@ void tst_QXmppAtmManager::testMakeTrustDecisionsOwnKeysDone()
void tst_QXmppAtmManager::testMakeTrustDecisionsContactKeysDone()
{
auto future = m_trustStorage->trustLevel(ns_omemo,
+ QStringLiteral("bob@example.com"),
QByteArray::fromBase64(QByteArrayLiteral("+1VJvMLCGvkDquZ6mQZ+SS+gTbQ436BJUwFOoW0Ma1g=")));
QVERIFY(future.isFinished());
auto result = future.result();
QCOMPARE(result, QXmppTrustStorage::Authenticated);
future = m_trustStorage->trustLevel(ns_omemo,
+ QStringLiteral("bob@example.com"),
QByteArray::fromBase64(QByteArrayLiteral("mzDeKTQBVm1cTmzF9DjCGKa14pDADZOVLT9Kh7CK7AM=")));
QVERIFY(future.isFinished());
result = future.result();
QCOMPARE(result, QXmppTrustStorage::Authenticated);
future = m_trustStorage->trustLevel(ns_omemo,
+ QStringLiteral("bob@example.com"),
QByteArray::fromBase64(QByteArrayLiteral("8gBTC1fspYkO4akS6QKN+XFA9Nmf9NEIg7hjtlpTjII=")));
QVERIFY(future.isFinished());
result = future.result();
diff --git a/tests/qxmpptrustmemorystorage/tst_qxmpptrustmemorystorage.cpp b/tests/qxmpptrustmemorystorage/tst_qxmpptrustmemorystorage.cpp
index ff7537dc..cebe886f 100644
--- a/tests/qxmpptrustmemorystorage/tst_qxmpptrustmemorystorage.cpp
+++ b/tests/qxmpptrustmemorystorage/tst_qxmpptrustmemorystorage.cpp
@@ -523,6 +523,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
auto future = m_trustStorage.trustLevel(
ns_omemo,
+ QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("AZ/cF4OrUOILKO1gQBf62pQevOhBJ2NyHnXLwM4FDZU=")));
QVERIFY(future.isFinished());
auto result = future.result();
@@ -538,6 +539,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
future = m_trustStorage.trustLevel(
ns_omemo,
+ QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("AZ/cF4OrUOILKO1gQBf62pQevOhBJ2NyHnXLwM4FDZU=")));
QVERIFY(future.isFinished());
result = future.result();
@@ -545,6 +547,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
future = m_trustStorage.trustLevel(
ns_omemo,
+ QStringLiteral("bob@example.com"),
QByteArray::fromBase64(QByteArrayLiteral("9E51lG3vVmUn8CM7/AIcmIlLP2HPl6Ao0/VSf4VT/oA=")));
QVERIFY(future.isFinished());
result = future.result();
@@ -560,6 +563,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
future = m_trustStorage.trustLevel(
ns_omemo,
+ QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("9w6oPjKyGSALd9gHq7sNOdOAkD5bHUVOKACNs89FjkA=")));
QVERIFY(future.isFinished());
result = future.result();
@@ -569,6 +573,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
// The default value is returned.
future = m_trustStorage.trustLevel(
ns_omemo,
+ QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("WXL4EDfzUGbVPQWjT9pmBeiCpCBzYZv3lUAaj+UbPyE=")));
QVERIFY(future.isFinished());
result = future.result();
@@ -585,6 +590,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
future = m_trustStorage.trustLevel(
ns_omemo,
+ QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("AZ/cF4OrUOILKO1gQBf62pQevOhBJ2NyHnXLwM4FDZU=")));
QVERIFY(future.isFinished());
result = future.result();
@@ -592,6 +598,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
future = m_trustStorage.trustLevel(
ns_omemo,
+ QStringLiteral("bob@example.com"),
QByteArray::fromBase64(QByteArrayLiteral("9E51lG3vVmUn8CM7/AIcmIlLP2HPl6Ao0/VSf4VT/oA=")));
QVERIFY(future.isFinished());
result = future.result();
@@ -600,6 +607,7 @@ void tst_QXmppTrustMemoryStorage::testTrustLevels()
// Verify that the default trust level is returned for an unknown key.
future = m_trustStorage.trustLevel(
ns_omemo,
+ QStringLiteral("alice@example.org"),
QByteArray::fromBase64(QByteArrayLiteral("wE06Gwf8f4DvDLFDoaCsGs8ibcUjf84WIOA2FAjPI3o=")));
QVERIFY(future.isFinished());
result = future.result();