libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
qolmaccount.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5
6#pragma once
7
8#include <Quotient/e2ee/e2ee_common.h>
9#include <Quotient/e2ee/qolmmessage.h>
10
11#include <Quotient/csapi/keys.h>
12
13#include <QtCore/QObject>
14
15struct OlmAccount;
16
17namespace Quotient {
18
19class QOlmSession;
20
21//! An olm account manages all cryptographic keys used on a device.
22//! \code{.cpp}
23//! const auto olmAccount = new QOlmAccount(this);
24//! \endcode
26{
28public:
30
31 //! Creates a new instance of OlmAccount. During the instantiation
32 //! the Ed25519 fingerprint key pair and the Curve25519 identity key
33 //! pair are generated.
34 //! \sa https://matrix.org/docs/guides/e2e_implementation.html#keys-used-in-end-to-end-encryption
35 //! \note This needs to be called before any other action or use unpickle() instead.
37
38 //! Deserialises from encrypted Base64 that was previously obtained by pickling a `QOlmAccount`.
39 //! \note This needs to be called before any other action or use setupNewAccount() instead.
41 const PicklingKey& key);
42
43 //! Serialises an OlmAccount to encrypted Base64.
45
46 //! Returns the account's public identity keys already formatted as JSON
48
49 //! Returns the signature of the supplied message.
52
53 //! Sign identity keys.
55
56 //! Maximum number of one time keys that this OlmAccount can
57 //! currently hold.
59
60 //! Generates the supplied number of one time keys.
62
63 //! Gets the OlmAccount's one time keys formatted as JSON.
65
66 //! Sign all one time keys.
68
70
72
73 //! Remove the one time key used to create the supplied session.
75
76 //! Creates an inbound session for sending/receiving messages from a received 'prekey' message.
77 //!
78 //! \param preKeyMessage An Olm pre-key message that was encrypted for this account.
80 const QOlmMessage& preKeyMessage) const;
81
82 //! Creates an inbound session for sending/receiving messages from a received 'prekey' message.
83 //!
84 //! \param theirIdentityKey - The identity key of the Olm account that
85 //! encrypted this Olm message.
88 const QOlmMessage& preKeyMessage) const;
89
90 //! Creates an outbound session for sending messages to a specific
91 /// identity and one time key.
94 const QByteArray& theirOneTimeKey) const;
95
97
99 const char* lastError() const;
100
102 void needsSave();
103
104private:
109
111 const QByteArray &theirIdentityKey = "") const;
112
113 QString accountId() const;
114};
115
116// TODO, 0.9: Move the two below to qolmutility.h
117
118QUOTIENT_API bool verifyIdentitySignature(const DeviceKeys& deviceKeys,
119 const QString& deviceId,
120 const QString& userId);
121
122//! checks if the signature is signed by the signing_key
123QUOTIENT_API bool ed25519VerifySignature(const QString& signingKey,
124 const QJsonObject& obj,
125 const QString& signature);
126
127} // namespace Quotient
QUOTIENT_API bool ed25519VerifySignature(const QString &signingKey, const QJsonObject &obj, const QString &signature)
checks if the signature is signed by the signing_key
QUOTIENT_API bool verifyIdentitySignature(const DeviceKeys &deviceKeys, const QString &deviceId, const QString &userId)
#define QUOTIENT_API