libQuotient
A Qt library for building matrix clients
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages Concepts
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 "e2ee_common.h"
9#include "qolmmessage.h"
10
11#include "../csapi/keys.h"
12
13#include "../jobs/jobhandle.h"
14
15#include <QtCore/QObject>
16
17struct OlmAccount;
18
19namespace Quotient {
20
21class QOlmSession;
22
23//! An olm account manages all cryptographic keys used on a device.
24//! \code{.cpp}
25//! const auto olmAccount = new QOlmAccount(this);
26//! \endcode
28{
30public:
32
33 //! Creates a new instance of OlmAccount. During the instantiation
34 //! the Ed25519 fingerprint key pair and the Curve25519 identity key
35 //! pair are generated.
36 //! \sa https://matrix.org/docs/guides/e2e_implementation.html#keys-used-in-end-to-end-encryption
37 //! \note This needs to be called before any other action or use unpickle() instead.
39
40 //! Deserialises from encrypted Base64 that was previously obtained by pickling a `QOlmAccount`.
41 //! \note This needs to be called before any other action or use setupNewAccount() instead.
43 const PicklingKey& key);
44
45 //! Serialises an OlmAccount to encrypted Base64.
47
48 //! Returns the account's public identity keys already formatted as JSON
50
51 //! Returns the signature of the supplied message.
54
55 //! Sign identity keys.
57
58 //! Maximum number of one time keys that this OlmAccount can
59 //! currently hold.
61
62 //! Generates the supplied number of one time keys.
64
65 //! Gets the OlmAccount's one time keys formatted as JSON.
67
68 //! Sign all one time keys.
70
72
74
75 //! Remove the one time key used to create the supplied session.
77
78 //! Creates an inbound session for sending/receiving messages from a received 'prekey' message.
79 //!
80 //! \param preKeyMessage An Olm pre-key message that was encrypted for this account.
82 const QOlmMessage& preKeyMessage) const;
83
84 //! Creates an inbound session for sending/receiving messages from a received 'prekey' message.
85 //!
86 //! \param theirIdentityKey - The identity key of the Olm account that
87 //! encrypted this Olm message.
90 const QOlmMessage& preKeyMessage) const;
91
92 //! Creates an outbound session for sending messages to a specific
93 /// identity and one time key.
96 const QByteArray& theirOneTimeKey) const;
97
99
101 const char* lastError() const;
102
104 void needsSave();
105
106private:
111
113 const QByteArray &theirIdentityKey = "") const;
114
115 QString accountId() const;
116};
117
118// TODO, 0.9: Move the two below to qolmutility.h
119
120QUOTIENT_API bool verifyIdentitySignature(const DeviceKeys& deviceKeys,
121 const QString& deviceId,
122 const QString& userId);
123
124//! checks if the signature is signed by the signing_key
125QUOTIENT_API bool ed25519VerifySignature(const QString& signingKey,
126 const QJsonObject& obj,
127 const QString& signature);
128
129} // 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