diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-05-16 10:41:54 +0200 |
---|---|---|
committer | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-05-16 10:42:24 +0200 |
commit | 79b3dba1ed4b6870c4e989ada88e33b1ce0ddc21 (patch) | |
tree | 1a29d39730f2f6eca8d58e57c15266cfa961f773 /lib/e2ee/qolmutility.h | |
parent | a3486fd0e9786c47564ce8173a2e4039135b10f9 (diff) | |
download | libquotient-79b3dba1ed4b6870c4e989ada88e33b1ce0ddc21.tar.gz libquotient-79b3dba1ed4b6870c4e989ada88e33b1ce0ddc21.zip |
QOlmExpected and associated refactoring
As mentioned in the commit introducing `Expected`, `QOlmExpected` is
simply an alias for `Expected<T, QOlmError>`. This simplifies quite
a few function signatures in `QOlm*` classes and collapses unwieldy
`std::holds_alternative<>`/`std::get<>` constructs into a neat
contextual bool cast and an invocation of `operator*` or
`value()`/`error()` accessors that don't need to specify the type.
While refactoring the code, I found a couple of cases of mismatching
`uint32_t` and `qint32_t` in return values; a couple of cases where
`decrypt()` returns `QString` which is in fact `QByteArray` (e.g., in
`QOlmSession::decrypt()`); there's a repetitive algorithm in
`Connection::Private::sessionDecryptPrekey()` and
`sessionDecryptGeneral()`
Diffstat (limited to 'lib/e2ee/qolmutility.h')
-rw-r--r-- | lib/e2ee/qolmutility.h | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/e2ee/qolmutility.h b/lib/e2ee/qolmutility.h index a12af49a..5f6bcdc5 100644 --- a/lib/e2ee/qolmutility.h +++ b/lib/e2ee/qolmutility.h @@ -4,15 +4,12 @@ #pragma once -#include <variant> -#include "e2ee/qolmerrors.h" +#include "e2ee/e2ee.h" struct OlmUtility; namespace Quotient { -class QOlmSession; - //! Allows you to make use of crytographic hashing via SHA-2 and //! verifying ed25519 signatures. class QUOTIENT_API QOlmUtility @@ -32,7 +29,7 @@ public: //! \param key QByteArray The public part of the ed25519 key that signed the message. //! \param message QByteArray The message that was signed. //! \param signature QByteArray The signature of the message. - std::variant<bool, QOlmError> ed25519Verify(const QByteArray &key, + QOlmExpected<bool> ed25519Verify(const QByteArray &key, const QByteArray &message, const QByteArray &signature); private: |