Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,11 @@ void Link::handshake() {
void Link::prove() {
assert(_object);
DEBUGF("Link %s requesting proof", link_id().toHex().c_str());
Bytes signed_data =_object->_link_id + _object->_pub_bytes + _object->_sig_pub_bytes;
Bytes signalling_bytes = Link::signalling_bytes(_object->_mtu, _object->_mode);
Bytes signed_data = _object->_link_id + _object->_pub_bytes + _object->_sig_pub_bytes + signalling_bytes;
const Bytes signature(_object->_owner.identity().sign(signed_data));

Bytes proof_data = signature + _object->_pub_bytes;
Bytes proof_data = signature + _object->_pub_bytes + signalling_bytes;
// CBA LINK
// CBA TODO: Determine which approach is better, passing liunk to packet or passing _link_destination
Packet proof(*this, proof_data, Type::Packet::PROOF, Type::Packet::LRPROOF);
Expand Down Expand Up @@ -337,7 +338,7 @@ void Link::validate_proof(const Packet& packet) {
handshake();

_object->_establishment_cost += packet.raw().size();
Bytes signed_data = _object->_link_id + _object->_peer_pub_bytes + _object->_peer_sig_pub_bytes;
Bytes signed_data = _object->_link_id + _object->_peer_pub_bytes + _object->_peer_sig_pub_bytes + signalling_bytes;
const Bytes signature(packet_data.left(Type::Identity::SIGLENGTH/8));

TRACEF("Link %s validating identity", link_id().toHex().c_str());
Expand Down
11 changes: 8 additions & 3 deletions src/Transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Reticulum.h"
#include "Destination.h"
#include "Identity.h"
#include "Link.h"
#include "Packet.h"
#include "Interface.h"
#include "Log.h"
Expand Down Expand Up @@ -2242,15 +2243,19 @@ using namespace RNS::Utilities;
// needs to be transported
if ((Reticulum::transport_enabled() || for_local_client_link || from_local_client) && _link_table.find(packet.destination_hash()) != _link_table.end()) {
TRACE("Handling link request proof...");
LinkEntry link_entry = (*_link_table.find(packet.destination_hash())).second;
LinkEntry& link_entry = (*_link_table.find(packet.destination_hash())).second;
if (packet.receiving_interface() == link_entry._outbound_interface) {
try {
if (packet.data().size() == (Type::Identity::SIGLENGTH/8 + Type::Link::ECPUBSIZE/2)) {
if (packet.data().size() == (Type::Identity::SIGLENGTH/8 + Type::Link::ECPUBSIZE/2) || packet.data().size() == (Type::Identity::SIGLENGTH/8 + Type::Link::ECPUBSIZE/2 + Type::Link::LINK_MTU_SIZE)) {
Bytes signalling_bytes;
if (packet.data().size() == (Type::Identity::SIGLENGTH/8 + Type::Link::ECPUBSIZE/2 + Type::Link::LINK_MTU_SIZE)) {
signalling_bytes = Link::signalling_bytes(Link::mtu_from_lp_packet(packet), Link::mode_from_lp_packet(packet));
}
Bytes peer_pub_bytes = packet.data().mid(Type::Identity::SIGLENGTH/8, Type::Link::ECPUBSIZE/2);
Identity peer_identity = Identity::recall(link_entry._destination_hash);
Bytes peer_sig_pub_bytes = peer_identity.get_public_key().mid(Type::Link::ECPUBSIZE/2, Type::Link::ECPUBSIZE/2);

Bytes signed_data = packet.destination_hash() + peer_pub_bytes + peer_sig_pub_bytes;
Bytes signed_data = packet.destination_hash() + peer_pub_bytes + peer_sig_pub_bytes + signalling_bytes;
Bytes signature = packet.data().left(Type::Identity::SIGLENGTH/8);

if (peer_identity.validate(signature, signed_data)) {
Expand Down