libQuotient
A Qt library for building matrix clients
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Functions
a
b
c
d
e
f
g
h
i
j
l
m
o
p
q
r
s
t
u
v
z
Variables
a
b
c
d
e
f
h
i
j
l
m
n
o
p
q
r
s
t
u
Typedefs
a
b
c
d
e
f
i
k
l
m
o
q
r
s
t
u
v
Enumerations
Enumerator
Concepts
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Typedefs
a
c
d
e
f
g
h
i
m
p
r
s
t
u
v
Enumerations
Enumerator
a
b
c
d
e
f
g
h
i
k
m
n
o
p
r
s
t
u
w
Properties
a
c
d
e
f
h
i
j
k
l
m
n
o
p
r
s
t
u
v
Related Symbols
Files
File List
File Members
All
Functions
Macros
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
Concepts
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
"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
17
struct
OlmAccount;
18
19
namespace
Quotient
{
20
21
class
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
27
class
QUOTIENT_API
QOlmAccount
:
public
QObject
28
{
29
Q_OBJECT
30
public
:
31
QOlmAccount
(
QString
userId
,
QString
deviceId
,
QObject
*
parent
=
nullptr
);
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.
38
void
setupNewAccount
();
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.
42
[[
nodiscard
]]
OlmErrorCode
unpickle
(
QByteArray
&&
pickled
,
43
const
PicklingKey
&
key
);
44
45
//! Serialises an OlmAccount to encrypted Base64.
46
QByteArray
pickle
(
const
PicklingKey
&
key
)
const
;
47
48
//! Returns the account's public identity keys already formatted as JSON
49
IdentityKeys
identityKeys
()
const
;
50
51
//! Returns the signature of the supplied message.
52
QByteArray
sign
(
const
QByteArray
&
message
)
const
;
53
QByteArray
sign
(
const
QJsonObject
&
message
)
const
;
54
55
//! Sign identity keys.
56
QByteArray
signIdentityKeys
()
const
;
57
58
//! Maximum number of one time keys that this OlmAccount can
59
//! currently hold.
60
size_t
maxNumberOfOneTimeKeys
()
const
;
61
62
//! Generates the supplied number of one time keys.
63
size_t
generateOneTimeKeys
(
size_t
numberOfKeys
);
64
65
//! Gets the OlmAccount's one time keys formatted as JSON.
66
UnsignedOneTimeKeys
oneTimeKeys
()
const
;
67
68
//! Sign all one time keys.
69
OneTimeKeys
signOneTimeKeys
(
const
UnsignedOneTimeKeys
&
keys
)
const
;
70
71
JobHandle
<
UploadKeysJob
>
createUploadKeyRequest
(
const
UnsignedOneTimeKeys
&
oneTimeKeys
)
const
;
72
73
DeviceKeys
deviceKeys
()
const
;
74
75
//! Remove the one time key used to create the supplied session.
76
[[
nodiscard
]]
OlmErrorCode
removeOneTimeKeys
(
const
QOlmSession
&
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.
81
QOlmExpected
<
QOlmSession
>
createInboundSession
(
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.
88
QOlmExpected
<
QOlmSession
>
createInboundSessionFrom
(
89
const
QByteArray
&
theirIdentityKey
,
90
const
QOlmMessage
&
preKeyMessage
)
const
;
91
92
//! Creates an outbound session for sending messages to a specific
93
/// identity and one time key.
94
QOlmExpected
<
QOlmSession
>
createOutboundSession
(
95
const
QByteArray
&
theirIdentityKey
,
96
const
QByteArray
&
theirOneTimeKey
)
const
;
97
98
void
markKeysAsPublished
();
99
100
OlmErrorCode
lastErrorCode
()
const
;
101
const
char
*
lastError
()
const
;
102
103
Q_SIGNALS
:
104
void
needsSave
();
105
106
private
:
107
CStructPtr
<
OlmAccount
>
olmDataHolder
;
108
QString
m_userId
;
109
QString
m_deviceId
;
110
OlmAccount
*
olmData
=
olmDataHolder
.
get
();
111
112
QOlmExpected
<
QOlmSession
>
createInbound
(
QOlmMessage
preKeyMessage
,
113
const
QByteArray
&
theirIdentityKey
=
""
)
const
;
114
115
QString
accountId
()
const
;
116
};
117
118
// TODO, 0.9: Move the two below to qolmutility.h
119
120
QUOTIENT_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
125
QUOTIENT_API
bool
ed25519VerifySignature
(
const
QString& signingKey,
126
const
QJsonObject& obj,
127
const
QString& signature);
128
129
}
// namespace Quotient
Quotient::QOlmAccount
Definition
qolmaccount.h:28
Quotient
Definition
accountregistry.h:13
Quotient::ed25519VerifySignature
QUOTIENT_API bool ed25519VerifySignature(const QString &signingKey, const QJsonObject &obj, const QString &signature)
checks if the signature is signed by the signing_key
Quotient::verifyIdentitySignature
QUOTIENT_API bool verifyIdentitySignature(const DeviceKeys &deviceKeys, const QString &deviceId, const QString &userId)
QUOTIENT_API
#define QUOTIENT_API
Definition
quotient_export.h:22
Quotient
e2ee
qolmaccount.h
Generated by
1.9.8