summary refs log tree commit diff
path: root/src/encryption
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-06-18 01:35:30 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2022-06-18 02:31:01 +0200
commit35ff02ce485f42d4ab74298048f50cffb84db472 (patch)
tree245f7efa81f7417872263159358d72ccd6c6871e /src/encryption
parentSupport the knock_restricted rule (diff)
downloadnheko-35ff02ce485f42d4ab74298048f50cffb84db472.tar.xz
Remove a few more headers
Diffstat (limited to 'src/encryption')
-rw-r--r--src/encryption/DeviceVerificationFlow.cpp16
-rw-r--r--src/encryption/DeviceVerificationFlow.h3
-rw-r--r--src/encryption/SelfVerificationStatus.cpp1
3 files changed, 9 insertions, 11 deletions
diff --git a/src/encryption/DeviceVerificationFlow.cpp b/src/encryption/DeviceVerificationFlow.cpp

index fa06fba2..d2dab491 100644 --- a/src/encryption/DeviceVerificationFlow.cpp +++ b/src/encryption/DeviceVerificationFlow.cpp
@@ -199,8 +199,8 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *, if (this->sender == false) { this->sendVerificationKey(); } else { - if (this->commitment != mtx::crypto::bin2base64_unpadded(mtx::crypto::sha256( - msg.key + this->canonical_json.dump()))) { + if (this->commitment != mtx::crypto::bin2base64_unpadded( + mtx::crypto::sha256(msg.key + this->canonical_json))) { this->cancelVerification(DeviceVerificationFlow::Error::MismatchedCommitment); return; } @@ -477,7 +477,7 @@ DeviceVerificationFlow::next() } else { switch (state_) { case PromptStartVerification: - if (canonical_json.is_null()) + if (canonical_json.empty()) sendVerificationReady(); else // legacy path without request and ready acceptVerificationRequest(); @@ -569,14 +569,14 @@ DeviceVerificationFlow::handleStartMessage(const mtx::events::msg::KeyVerificati return; } if (!sender) - this->canonical_json = nlohmann::json(msg); + this->canonical_json = nlohmann::json(msg).dump(); else { // resolve glare if (std::tuple(this->toClient.to_string(), this->deviceId.toStdString()) < std::tuple(utils::localUser().toStdString(), http::client()->device_id())) { // treat this as if the user with the smaller mxid or smaller deviceid (if the mxid // was the same) was the sender of "start" - this->canonical_json = nlohmann::json(msg); + this->canonical_json = nlohmann::json(msg).dump(); this->sender = false; } @@ -610,7 +610,7 @@ DeviceVerificationFlow::acceptVerificationRequest() else if (this->method == mtx::events::msg::SASMethods::Decimal) req.short_authentication_string = {mtx::events::msg::SASMethods::Decimal}; req.commitment = mtx::crypto::bin2base64_unpadded( - mtx::crypto::sha256(this->sas->public_key() + this->canonical_json.dump())); + mtx::crypto::sha256(this->sas->public_key() + this->canonical_json)); send(req); setState(WaitingForKeys); @@ -652,12 +652,12 @@ DeviceVerificationFlow::startVerificationRequest() if (this->type == DeviceVerificationFlow::Type::ToDevice) { mtx::requests::ToDeviceMessages<mtx::events::msg::KeyVerificationStart> body; req.transaction_id = this->transaction_id; - this->canonical_json = nlohmann::json(req); + this->canonical_json = nlohmann::json(req).dump(); } else if (this->type == DeviceVerificationFlow::Type::RoomMsg && model_) { req.relations.relations.push_back(this->relation); // Set synthesized to surpress the nheko relation extensions req.relations.synthesized = true; - this->canonical_json = nlohmann::json(req); + this->canonical_json = nlohmann::json(req).dump(); } send(req); setState(WaitingForOtherToAccept); diff --git a/src/encryption/DeviceVerificationFlow.h b/src/encryption/DeviceVerificationFlow.h
index 1955fab3..7968b739 100644 --- a/src/encryption/DeviceVerificationFlow.h +++ b/src/encryption/DeviceVerificationFlow.h
@@ -8,7 +8,6 @@ #include <QObject> #include <mtx/responses/crypto.hpp> -#include <nlohmann/json.hpp> #include "CacheCryptoStructs.h" #include "Logging.h" @@ -211,7 +210,7 @@ private: sas_ptr sas; std::string mac_method; std::string commitment; - nlohmann::json canonical_json; + std::string canonical_json; std::vector<int> sasList; UserKeyCache their_keys; diff --git a/src/encryption/SelfVerificationStatus.cpp b/src/encryption/SelfVerificationStatus.cpp
index f37b2af4..46e71015 100644 --- a/src/encryption/SelfVerificationStatus.cpp +++ b/src/encryption/SelfVerificationStatus.cpp
@@ -11,7 +11,6 @@ #include "Cache_p.h" #include "ChatPage.h" #include "Logging.h" -#include "MainWindow.h" #include "MatrixClient.h" #include "Olm.h" #include "encryption/VerificationManager.h"