aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2022-05-08Event content: provide toJson() instead of deriving from EC::BaseAlexey Rusakov
EventContent::Base has been made primarily for the sake of dynamic polymorphism needed within RoomMessageEvent content (arguably, it might not be really needed even there, but that's a bigger matter for another time). When that polymorphism is not needed, it's easier for reading and maintenance to have toJson() member function (or even specialise JsonConverter<> outside of the content structure) instead of deriving from EC::Base and then still having fillJson() member function. This commit removes EventContent::Base dependency where it's not beneficial.
2022-05-08Simplify EventContent a bitAlexey Rusakov
Main changes: 1. Base::fillJson() gets a QJsonObject& instead of QJsonObject* - c'mon, there's nothing inherently wrong with using an lvalue reference for a read-write parameter. 2. UrlWithThumbnailContent merged into UrlBasedContent. The original UrlBasedContent was only used to produce a single class, AudioContent, and even that can logically have a thumbnail even if the spec doesn't provision that. And there's no guarantee even for visual content (ImageContent, e.g.) to have thumbnail data; the fallback is already tested. 3. toInfoJson is converted from a template to a couple of overloads that supersede fillInfoJson() member functions in FileInfo/ImageInfo. These overloads are easier on the eye; and clang-tidy no more warns about ImageInfo::fillInfoJson() shadowing FileInfo::fillInfoJson(). 4. Now that UrlWithThumbnail is gone, PlayableContent can directly derive from UrlBasedContent since both its specialisations use it. 5. Instead of FileInfo/ImageInfo, fillInfoJson() has been reinvented within UrlBasedContent so that, in particular, PlayableContent wouldn't need to extract 'info' subobject and then roll it back inside the content JSON object.
2022-05-08Cleanup; comments reformattingAlexey Rusakov
2022-05-08StateEvent: use non-member JSON convertersAlexey Rusakov
With the reworked JsonConverter code it is possible to work uniformly with structures that have a member toJson() and a constructor converting from QJsonObject, as well as with structures that rely on an external JsonConverter specialisation.
2022-05-08toSnakeCase and EventContent::SingleKeyValueAlexey Rusakov
This is a rework of EventContent::SimpleContent previously defined in simplestateevents.h. Quite a few events (and not only state events) have just a single key-value pair in their content - this structure (which is really just a template wrapper around the value) and the accompanying JsonConverter<> specialisation encapsulate the concept to streamline definition of such events. This commit only has simplestateevents.h using it; further commits will use SingleKeyValue in other places. toSnakeCase is a facility function that converts camelCase used for C++ variables into snake_case used in JSON payloads. Combined with the preprocessor trick that makes a string literal from an identifier, this allows to reduce boilerplate code that repeats the same name for fields in C++ event classes and fields in JSON. SingleKeyValue uses it, and there are other cases for it coming.
2022-04-23CleanupAlexey Rusakov
2022-04-23SLICE()Alexey Rusakov
Add a macro to make slicing clear in the code and quiet for static analysis.
2022-04-16Use more idiomatic C++Tobias Fella
2022-04-16Only build function when E2EE is enabledTobias Fella
2022-04-16Try fixing lgtm.comTobias Fella
2022-04-09Comment out debug statementTobias Fella
2022-04-09Prepare for MSC 3700Tobias Fella
2022-04-09Don't crash when decrypting existing messagesTobias Fella
2022-04-09Make sure devices are known before decrypting olm messagesTobias Fella
2022-04-09Check edKey when receiving an olm messageTobias Fella
2022-04-09Correctly load EncryptedEventsTobias Fella
2022-03-11Fix loading images when E2EE is disabledTobias Fella
2022-03-10Merge pull request #541 from TobiasFella/storesessionedkeyAlexey Rusakov
Store some more things in the database
2022-03-09Check for empty ed25519 key.Tobias Fella
2022-03-09Update lib/database.cppTobias Fella
Co-authored-by: Carl Schwan <carl@carlschwan.eu>
2022-03-08Store time of last decrypted message for each olm sessionTobias Fella
Is required to correctly choose a session to use for sending messages
2022-03-07Add datbase migrationTobias Fella
2022-03-07Guard against device reuse attacksTobias Fella
2022-03-07Store the device's ed25519 in the databaseTobias Fella
2022-02-27Merge #538: Verification should return false instead of error for failed ↵Alexey Rusakov
signature checks
2022-02-27Merge #535: Convenience functions for querying user devices and keys from cacheAlexey Rusakov
2022-02-27Update lib/e2ee/qolmutility.cppTobias Fella
Co-authored-by: Carl Schwan <carl@carlschwan.eu>
2022-02-27Return false instead of error for failed signature checksTobias Fella
2022-02-27Merge pull request #537 from TobiasFella/decryptcheckroomAlexey Rusakov
2022-02-27Apply suggestionsTobias Fella
2022-02-27Apply suggestionsTobias Fella
2022-02-27Merge #536: Use QOlmMessage::Type in more placesAlexey Rusakov
2022-02-26Check that decrypted events are for the current roomTobias Fella
2022-02-26Use QOlmMessage::Type in more placesTobias Fella
Make sure that the enum values correspond to the values used in the spec and use them instead of magic constants
2022-02-26Handle to-device messages before handling roomdataTobias Fella
Probably improves the performance slightly If we handle to room data first, if a message arrives at the same time as the to-device message containing the key and we handle the message first, it will not be decryptable and stored as undecrypted. Then, when the key is handled, the cache of undecrypted messages is searched, the message decrypted and replaced. When handling the key first, the message can be decryped instantly.
2022-02-26Add convenience functions for querying user devices and keys from cacheTobias Fella
2022-02-26Merge pull request #477 from TobiasFella/work/readencryptedmessagesAlexey Rusakov
2022-02-25IfdefTobias Fella
2022-02-25Save key counts to stateTobias Fella
Otherwise new one time keys will be uploaded on every start
2022-02-24Fix all testsTobias Fella
2022-02-16quotient_export.h: #include <qglobal.h>Alexey Rusakov
To ensure Q_DECL_EXPORT/Q_DECL_IMPORT macros are defined.
2022-02-16More cleanup, especially in EncryptedFileAlexey Rusakov
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.
2022-02-16isSupportedAlgorithm()Alexey Rusakov
That's a better primitive than just exposing SupportedAlgorithms list.
2022-02-16Use QHash instead of QMapAlexey Rusakov
We don't seem to need sorted associative containers in those cases.
2022-02-16Fix file decryptionTobias Fella
2022-02-16Connection: guard device loading per-objectAlexey Rusakov
Using a static variable is incorrect as it doesn't load the device list for any subsequent created Connection object.
2022-02-16CleanupAlexey Rusakov
A note on switching to QLatin1String for JSON key constants - this is more concise and barely affects (if at all) runtime performance (padding each QChar with zeros is trivial for assignment; and comparison can be done directly with the same performance as for two QStrings).
2022-02-16Add a few missing QUOTIENT_API stanzasAlexey Rusakov
Also, removed Q_GADGET macros from key verification events as those don't seem to do anything (no Q_ENUM/Q_FLAG things, namely).
2022-02-14Don't set lifetime as version in call invitesTobias Fella
2022-02-14Revert "Don't #include "logging.h" from headers"Alexey Rusakov
This reverts commit 2cf44607cf0f057e147c2c4fe6dded6c13c58a8a (that was stupid, honestly).