mirror of
https://github.com/ratspeak/microReticulum
synced 2026-11-22 23:10:38 +00:00
Fixed link compatibility with Reticulum python implementation
This commit is contained in:
1 parent
3babdc001d
commit
5864a3c6fc
2 files changed
+12
-6
No files matched your search
+4
-3
@@ -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);
|
||||
@@ -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());
|
||||
|
||||
+8
-3
@@ -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"
|
||||
@@ -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)) {
|
||||
|
||||
Reference in new issue
Block a user