|
|
@ -13,7 +13,8 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *) |
|
|
|
{ |
|
|
|
{ |
|
|
|
timeout = new QTimer(this); |
|
|
|
timeout = new QTimer(this); |
|
|
|
timeout->setSingleShot(true); |
|
|
|
timeout->setSingleShot(true); |
|
|
|
this->sas = olm::client()->sas_init(); |
|
|
|
this->sas = olm::client()->sas_init(); |
|
|
|
|
|
|
|
this->isMacVerified = false; |
|
|
|
connect(timeout, &QTimer::timeout, this, [this]() { |
|
|
|
connect(timeout, &QTimer::timeout, this, [this]() { |
|
|
|
emit timedout(); |
|
|
|
emit timedout(); |
|
|
|
this->deleteLater(); |
|
|
|
this->deleteLater(); |
|
|
@ -134,45 +135,47 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
connect(ChatPage::instance(), |
|
|
|
connect( |
|
|
|
&ChatPage::recievedDeviceVerificationMac, |
|
|
|
ChatPage::instance(), |
|
|
|
this, |
|
|
|
&ChatPage::recievedDeviceVerificationMac, |
|
|
|
[this](const mtx::events::collections::DeviceEvents &message) { |
|
|
|
this, |
|
|
|
auto msg = |
|
|
|
[this](const mtx::events::collections::DeviceEvents &message) { |
|
|
|
std::get<mtx::events::DeviceEvent<msgs::KeyVerificationMac>>(message); |
|
|
|
auto msg = std::get<mtx::events::DeviceEvent<msgs::KeyVerificationMac>>(message); |
|
|
|
if (msg.content.transaction_id == this->transaction_id) { |
|
|
|
if (msg.content.transaction_id == this->transaction_id) { |
|
|
|
std::string info = |
|
|
|
std::string info = |
|
|
|
"MATRIX_KEY_VERIFICATION_MAC" + this->toClient.to_string() + |
|
|
|
"MATRIX_KEY_VERIFICATION_MAC" + this->toClient.to_string() + |
|
|
|
this->deviceId.toStdString() + |
|
|
|
this->deviceId.toStdString() + http::client()->user_id().to_string() + |
|
|
|
http::client()->user_id().to_string() + |
|
|
|
http::client()->device_id() + this->transaction_id; |
|
|
|
http::client()->device_id() + this->transaction_id; |
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> key_list; |
|
|
|
std::vector<std::string> key_list; |
|
|
|
std::string key_string; |
|
|
|
std::string key_string; |
|
|
|
for (auto mac : msg.content.mac) { |
|
|
|
for (auto mac : msg.content.mac) { |
|
|
|
key_string += mac.first + ","; |
|
|
|
if (mac.second == |
|
|
|
if (device_keys[mac.first] != "") { |
|
|
|
this->sas->calculate_mac(this->device_keys[mac.first], |
|
|
|
if (mac.second == |
|
|
|
info + mac.first)) { |
|
|
|
this->sas->calculate_mac(this->device_keys[mac.first], |
|
|
|
key_string += mac.first; |
|
|
|
info + mac.first)) { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this->cancelVerification(); |
|
|
|
this->cancelVerification(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (msg.content.keys == |
|
|
|
} |
|
|
|
this->sas->calculate_mac(key_string, info + "KEY_IDS")) { |
|
|
|
key_string = key_string.substr(0, key_string.length() - 1); |
|
|
|
// uncomment this in future to be compatible with the
|
|
|
|
if (msg.content.keys == |
|
|
|
// MSC2366 this->sendVerificationDone(); and remoeve the
|
|
|
|
this->sas->calculate_mac(key_string, info + "KEY_IDS")) { |
|
|
|
// below line
|
|
|
|
// uncomment this in future to be compatible with the
|
|
|
|
if (this->isMacVerified == true) |
|
|
|
// MSC2366 this->sendVerificationDone(); and remove the
|
|
|
|
emit this->deviceVerified(); |
|
|
|
// below line
|
|
|
|
else |
|
|
|
if (this->isMacVerified == true) |
|
|
|
this->isMacVerified = true; |
|
|
|
emit this->deviceVerified(); |
|
|
|
} else { |
|
|
|
else |
|
|
|
this->cancelVerification(); |
|
|
|
this->isMacVerified = true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
} |
|
|
|
this->cancelVerification(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
connect(ChatPage::instance(), |
|
|
|
connect(ChatPage::instance(), |
|
|
|
&ChatPage::recievedDeviceVerificationReady, |
|
|
|
&ChatPage::recievedDeviceVerificationReady, |
|
|
|
this, |
|
|
|
this, |
|
|
|