diff options
author | Carl Schwan <carl@carlschwan.eu> | 2021-01-27 00:50:27 +0100 |
---|---|---|
committer | Tobias Fella <fella@posteo.de> | 2021-12-01 21:34:52 +0100 |
commit | 57a218086d3c687cd26580ee2a0d2135646411dc (patch) | |
tree | 6df3c6d79ee8d197c84583cc564fb453e31d81ab /lib/olm/qolmaccount.h | |
parent | d0d8b267753792d0310dd964b0b688d6262e6eb4 (diff) | |
download | libquotient-57a218086d3c687cd26580ee2a0d2135646411dc.tar.gz libquotient-57a218086d3c687cd26580ee2a0d2135646411dc.zip |
Add hehlper functions
Diffstat (limited to 'lib/olm/qolmaccount.h')
-rw-r--r-- | lib/olm/qolmaccount.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/olm/qolmaccount.h b/lib/olm/qolmaccount.h index 3260ca71..df5e1be2 100644 --- a/lib/olm/qolmaccount.h +++ b/lib/olm/qolmaccount.h @@ -7,12 +7,15 @@ #include "olm/e2ee.h" #include "olm/errors.h" #include "olm/olm.h" +#include "olm/session.h" #include <QObject> struct OlmAccount; namespace Quotient { +class QOlmSession; + //! An olm account manages all cryptographic keys used on a device. //! \code{.cpp} //! const auto olmAccount = new QOlmAccount(this); @@ -63,10 +66,25 @@ public: QByteArray signOneTimeKey(const QString &key) const; SignedOneTimeKey signedOneTimeKey(const QByteArray &key, const QString &signature) const; - OlmAccount *data(); + + //! Creates an inbound session for sending/receiving messages from a received 'prekey' message. + //! + //! \param message An Olm pre-key message that was encrypted for this account. + std::variant<std::unique_ptr<QOlmSession>, OlmError> createInboundSession(const Message &preKeyMessage); + + //! Creates an inbound session for sending/receiving messages from a received 'prekey' message. + //! + //! \param theirIdentityKey - The identity key of an Olm account that + //! encrypted this Olm message. + std::variant<std::unique_ptr<QOlmSession>, OlmError> createInboundSessionFrom(const QByteArray &theirIdentityKey, const Message &preKeyMessage); + + //! Creates an outbound session for sending messages to a specific + /// identity and one time key. + std::variant<std::unique_ptr<QOlmSession>, OlmError> createOutboundSession(const QByteArray &theirIdentityKey, const QByteArray &theirOneTimeKey); // HACK do not use directly QOlmAccount(OlmAccount *account); + OlmAccount *data(); private: OlmAccount *m_account = nullptr; QString m_userId; |