aboutsummaryrefslogtreecommitdiff
path: root/lib/events/encryptedfile.h
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-02-16 08:40:56 +0100
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-02-16 17:58:17 +0100
commitb5e1fc7d8fcf9336db0dfb351403aa06dcb226a0 (patch)
treec5af5984d51a1db1d6ff59bb2360eb4cec4f0b29 /lib/events/encryptedfile.h
parent0a43c023b94e12b3130572f2dd0d6ac8bb4ed110 (diff)
downloadlibquotient-b5e1fc7d8fcf9336db0dfb351403aa06dcb226a0.tar.gz
libquotient-b5e1fc7d8fcf9336db0dfb351403aa06dcb226a0.zip
More cleanup, especially in EncryptedFile
For EncryptedFile: - JSON converter bodies moved away to .cpp; - instead of C-style casts, reinterpret_cast is used to convert from (const) char* to (const) unsigned char*; - the size for the target plain text takes into account the case where the cipher block size can be larger than 1 (after reading https://www.openssl.org/docs/man1.1.1/man3/EVP_DecryptUpdate.html). - file decryption is wrapped in #ifdef Quotient_E2EE_ENABLED, to avoid OpenSSL linking errors when compiling without E2EE.
Diffstat (limited to 'lib/events/encryptedfile.h')
-rw-r--r--lib/events/encryptedfile.h40
1 files changed, 6 insertions, 34 deletions
diff --git a/lib/events/encryptedfile.h b/lib/events/encryptedfile.h
index 43bafc49..0558563f 100644
--- a/lib/events/encryptedfile.h
+++ b/lib/events/encryptedfile.h
@@ -49,42 +49,14 @@ public:
};
template <>
-struct JsonObjectConverter<EncryptedFile> {
- static void dumpTo(QJsonObject& jo, const EncryptedFile& pod)
- {
- addParam<>(jo, QStringLiteral("url"), pod.url);
- addParam<>(jo, QStringLiteral("key"), pod.key);
- addParam<>(jo, QStringLiteral("iv"), pod.iv);
- addParam<>(jo, QStringLiteral("hashes"), pod.hashes);
- addParam<>(jo, QStringLiteral("v"), pod.v);
- }
- static void fillFrom(const QJsonObject& jo, EncryptedFile& pod)
- {
- fromJson(jo.value("url"_ls), pod.url);
- fromJson(jo.value("key"_ls), pod.key);
- fromJson(jo.value("iv"_ls), pod.iv);
- fromJson(jo.value("hashes"_ls), pod.hashes);
- fromJson(jo.value("v"_ls), pod.v);
- }
+struct QUOTIENT_API JsonObjectConverter<EncryptedFile> {
+ static void dumpTo(QJsonObject& jo, const EncryptedFile& pod);
+ static void fillFrom(const QJsonObject& jo, EncryptedFile& pod);
};
template <>
-struct JsonObjectConverter<JWK> {
- static void dumpTo(QJsonObject& jo, const JWK& pod)
- {
- addParam<>(jo, QStringLiteral("kty"), pod.kty);
- addParam<>(jo, QStringLiteral("key_ops"), pod.keyOps);
- addParam<>(jo, QStringLiteral("alg"), pod.alg);
- addParam<>(jo, QStringLiteral("k"), pod.k);
- addParam<>(jo, QStringLiteral("ext"), pod.ext);
- }
- static void fillFrom(const QJsonObject& jo, JWK& pod)
- {
- fromJson(jo.value("kty"_ls), pod.kty);
- fromJson(jo.value("key_ops"_ls), pod.keyOps);
- fromJson(jo.value("alg"_ls), pod.alg);
- fromJson(jo.value("k"_ls), pod.k);
- fromJson(jo.value("ext"_ls), pod.ext);
- }
+struct QUOTIENT_API JsonObjectConverter<JWK> {
+ static void dumpTo(QJsonObject& jo, const JWK& pod);
+ static void fillFrom(const QJsonObject& jo, JWK& pod);
};
} // namespace Quotient