From 21e1b04474ee5e8bc7acdd53772331f850234811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 8 Jan 2022 18:28:32 +0100 Subject: Channel: use counter to generate nonce --- src/network.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/network.cpp') diff --git a/src/network.cpp b/src/network.cpp index b735262..84c3083 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -135,7 +135,7 @@ void Peer::Priv::notifyWatchers() bool Peer::hasChannel() const { if (auto speer = p->speer.lock()) - return holds_alternative>(speer->channel); + return holds_alternative>(speer->channel); return false; } @@ -306,8 +306,8 @@ void Server::Priv::doListen() auto & peer = getPeer(paddr); current = &buf; - if (holds_alternative>(peer.channel)) { - if (auto dec = std::get>(peer.channel)->decrypt(buf)) { + if (holds_alternative>(peer.channel)) { + if (auto dec = std::get>(peer.channel)->decrypt(buf)) { decrypted = std::move(*dec); current = &decrypted; } @@ -421,14 +421,14 @@ void Server::Priv::handlePacket(Server::Peer & peer, const TransportHeader & hea if (auto pref = std::get(item.value)) { if (holds_alternative>(peer.channel) && std::get>(peer.channel).ref().digest() == pref.digest()) - peer.channel.emplace> + peer.channel.emplace> (std::get>(peer.channel)->data->channel()); } break; case TransportHeader::Type::DataRequest: { auto pref = std::get(item.value); - if (holds_alternative>(peer.channel) || + if (holds_alternative>(peer.channel) || plaintextRefs.find(pref.digest()) != plaintextRefs.end()) { if (auto ref = peer.tempStorage.ref(pref.digest())) { TransportHeader::Item hitem { TransportHeader::Type::DataResponse, *ref }; @@ -514,7 +514,7 @@ void Server::Priv::handlePacket(Server::Peer & peer, const TransportHeader & hea if (holds_alternative(peer.identity) && acc.isSignedBy(std::get(peer.identity).keyMessage())) { reply.header({ TransportHeader::Type::Acknowledged, pref }); - peer.channel.emplace>(acc.data->channel()); + peer.channel.emplace>(acc.data->channel()); } } } @@ -578,8 +578,8 @@ void Server::Peer::send(const TransportHeader & header, const vector & o data.insert(data.end(), part.begin(), part.end()); } - if (holds_alternative>(channel)) - out = std::get>(channel)->encrypt(data); + if (holds_alternative>(channel)) + out = std::get>(channel)->encrypt(data); else if (secure) secureOutQueue.emplace_back(move(data)); else @@ -676,11 +676,11 @@ void Server::Peer::trySendOutQueue() if (secureOutQueue.empty()) return; - if (!holds_alternative>(channel)) + if (!holds_alternative>(channel)) return; for (const auto & data : secureOutQueue) { - auto out = std::get>(channel)->encrypt(data); + auto out = std::get>(channel)->encrypt(data); sendto(server.sock, out.data(), out.size(), 0, (sockaddr *) &addr, sizeof(addr)); -- cgit v1.2.3