10 constexpr inline auto SasV1Method =
"m.sas.v1"_L1;
20 using RoomEvent::RoomEvent;
28 class QUOTIENT_API KeyVerificationRequestEvent :
public KeyVerificationEvent {
30 QUO_EVENT(KeyVerificationRequestEvent,
"m.key.verification.request")
32 using KeyVerificationEvent::KeyVerificationEvent;
33 KeyVerificationRequestEvent(
const QString& transactionId,
34 const QString& fromDevice,
35 const QStringList& methods,
36 const QDateTime& timestamp)
37 : KeyVerificationRequestEvent(
38 basicJson(TypeId, { {
"transaction_id"_L1, transactionId },
39 {
"from_device"_L1, fromDevice },
40 {
"methods"_L1, toJson(methods) },
41 {
"timestamp"_L1, toJson(timestamp) } }))
57 class QUOTIENT_API KeyVerificationReadyEvent :
public KeyVerificationEvent {
59 QUO_EVENT(KeyVerificationReadyEvent,
"m.key.verification.ready")
61 using KeyVerificationEvent::KeyVerificationEvent;
62 KeyVerificationReadyEvent(
const QString& transactionId,
63 const QString& fromDevice,
64 const QStringList& methods)
65 : KeyVerificationReadyEvent(
66 basicJson(TypeId, { {
"transaction_id"_L1, transactionId },
67 {
"from_device"_L1, fromDevice },
68 {
"methods"_L1, toJson(methods) } }))
78 constexpr inline auto HmacSha256Code =
"hkdf-hmac-sha256"_L1;
79 constexpr inline auto HmacSha256V2Code =
"hkdf-hmac-sha256.v2"_L1;
80 constexpr std::array SupportedMacs { HmacSha256Code, HmacSha256V2Code };
83 class QUOTIENT_API KeyVerificationStartEvent :
public KeyVerificationEvent {
85 QUO_EVENT(KeyVerificationStartEvent,
"m.key.verification.start")
87 using KeyVerificationEvent::KeyVerificationEvent;
88 KeyVerificationStartEvent(
const QString& transactionId,
89 const QString& fromDevice)
90 : KeyVerificationStartEvent(
91 basicJson(TypeId, { {
"transaction_id"_L1, transactionId },
92 {
"from_device"_L1, fromDevice },
93 {
"method"_L1, SasV1Method },
94 {
"hashes"_L1, QJsonArray{
"sha256"_L1 } },
95 {
"key_agreement_protocols"_L1,
96 QJsonArray{
"curve25519-hkdf-sha256"_L1 } },
97 {
"message_authentication_codes"_L1,
98 toJson(SupportedMacs) },
99 {
"short_authentication_string"_L1,
100 QJsonArray{
"decimal"_L1,
"emoji"_L1 } } }))
116 QStringList keyAgreementProtocols()
const
118 Q_ASSERT(method() == SasV1Method);
119 return contentPart<QStringList>(
"key_agreement_protocols"_L1);
124 QStringList hashes()
const
126 Q_ASSERT(method() == SasV1Method);
127 return contentPart<QStringList>(
"hashes"_L1);
132 QStringList messageAuthenticationCodes()
const
134 Q_ASSERT(method() == SasV1Method);
135 return contentPart<QStringList>(
"message_authentication_codes"_L1);
141 QString shortAuthenticationString()
const
143 Q_ASSERT(method() == SasV1Method);
144 return contentPart<QString>(
"short_authentication_string"_L1);
149 class QUOTIENT_API KeyVerificationAcceptEvent :
public KeyVerificationEvent {
151 QUO_EVENT(KeyVerificationAcceptEvent,
"m.key.verification.accept")
153 using KeyVerificationEvent::KeyVerificationEvent;
154 KeyVerificationAcceptEvent(
const QString& transactionId,
155 const QString& commitment)
156 : KeyVerificationAcceptEvent(basicJson(
157 TypeId, { {
"transaction_id"_L1, transactionId },
158 {
"method"_L1, SasV1Method },
159 {
"key_agreement_protocol"_L1,
"curve25519-hkdf-sha256"_L1 },
160 {
"hash"_L1,
"sha256"_L1 },
161 {
"message_authentication_code"_L1, HmacSha256V2Code },
162 {
"short_authentication_string"_L1,
163 QJsonArray{
"decimal"_L1,
"emoji"_L1, } },
164 {
"commitment"_L1, commitment } }))
191 class QUOTIENT_API KeyVerificationCancelEvent :
public KeyVerificationEvent {
193 QUO_EVENT(KeyVerificationCancelEvent,
"m.key.verification.cancel")
195 using KeyVerificationEvent::KeyVerificationEvent;
196 KeyVerificationCancelEvent(
const QString& transactionId,
197 const QString& reason)
198 : KeyVerificationCancelEvent(
200 {
"transaction_id"_L1, transactionId },
201 {
"reason"_L1, reason },
202 {
"code"_L1, reason }
215 class QUOTIENT_API KeyVerificationKeyEvent :
public KeyVerificationEvent {
217 QUO_EVENT(KeyVerificationKeyEvent,
"m.key.verification.key")
219 using KeyVerificationEvent::KeyVerificationEvent;
220 KeyVerificationKeyEvent(
const QString& transactionId,
const QString& key)
221 : KeyVerificationKeyEvent(
222 basicJson(TypeId, { {
"transaction_id"_L1, transactionId },
223 {
"key"_L1, key } }))
231 class QUOTIENT_API KeyVerificationMacEvent :
public KeyVerificationEvent {
233 QUO_EVENT(KeyVerificationMacEvent,
"m.key.verification.mac")
235 using KeyVerificationEvent::KeyVerificationEvent;
236 KeyVerificationMacEvent(
const QString& transactionId,
const QString& keys,
237 const QJsonObject& mac)
238 : KeyVerificationMacEvent(
239 basicJson(TypeId, { {
"transaction_id"_L1, transactionId },
241 {
"mac"_L1, mac } }))
247 QHash<QString, QString> mac()
const
249 return contentPart<QHash<QString, QString>>(
"mac"_L1);
253 class QUOTIENT_API KeyVerificationDoneEvent :
public KeyVerificationEvent {
255 QUO_EVENT(KeyVerificationDoneEvent,
"m.key.verification.done")
257 using KeyVerificationEvent::KeyVerificationEvent;
258 explicit KeyVerificationDoneEvent(
const QString& transactionId)
259 : KeyVerificationDoneEvent(
260 basicJson(TypeId, { {
"transaction_id"_L1, transactionId } }))