aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-06-22 21:36:43 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-06-22 21:36:43 +0200
commit5de8d0a4bc9744327703c1613fc5ac3f232f44a8 (patch)
treefbe59e1c656658e09eca77d8649a370797ed4f1d
parentf853db5acc17f0ecd4ada65320fb2c846fc1b4d0 (diff)
downloadlibquotient-5de8d0a4bc9744327703c1613fc5ac3f232f44a8.tar.gz
libquotient-5de8d0a4bc9744327703c1613fc5ac3f232f44a8.zip
Fix signature verification
toJson(SignedOneTimeKey) incorrectly generated a "signatures" key mapped to an empty object when no signatures were in the C++ value. Also: fallback keys have an additional flag that also has to be taken into account when verifying signatures.
-rw-r--r--lib/e2ee/e2ee.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/e2ee/e2ee.h b/lib/e2ee/e2ee.h
index 234d4bcb..aba795a4 100644
--- a/lib/e2ee/e2ee.h
+++ b/lib/e2ee/e2ee.h
@@ -89,6 +89,8 @@ public:
//! Required. Signatures of the key object.
//! The signature is calculated using the process described at Signing JSON.
QHash<QString, QHash<QString, QString>> signatures;
+
+ bool fallback = false;
};
template <>
@@ -97,12 +99,14 @@ struct JsonObjectConverter<SignedOneTimeKey> {
{
fromJson(jo.value("key"_ls), result.key);
fromJson(jo.value("signatures"_ls), result.signatures);
+ fromJson(jo.value("fallback"_ls), result.fallback);
}
static void dumpTo(QJsonObject &jo, const SignedOneTimeKey &result)
{
- addParam<>(jo, QStringLiteral("key"), result.key);
- addParam<>(jo, QStringLiteral("signatures"), result.signatures);
+ addParam<>(jo, "key"_ls, result.key);
+ addParam<IfNotEmpty>(jo, "signatures"_ls, result.signatures);
+ addParam<IfNotEmpty>(jo, "key"_ls, result.fallback);
}
};