* Mesh::onAnonDataRecv() slight optimisation, so that shared-secret calc doesn't need to be repeated

* SensporMesh: req_type now optionally encoded in anon_req payload (so can send various requests without a prior login)
This commit is contained in:
Scott Powell 2025-07-07 20:41:28 +10:00
parent 7fb7b69bbc
commit 810b1f8fe7
6 changed files with 76 additions and 60 deletions

View file

@ -181,7 +181,7 @@ DispatcherAction Mesh::onRecvPacket(Packet* pkt) {
uint8_t data[MAX_PACKET_PAYLOAD];
int len = Utils::MACThenDecrypt(secret, data, macAndData, pkt->payload_len - i);
if (len > 0) { // success!
onAnonDataRecv(pkt, pkt->getPayloadType(), sender, data, len);
onAnonDataRecv(pkt, secret, sender, data, len);
pkt->markDoNotRetransmit();
}
}

View file

@ -107,10 +107,10 @@ protected:
/**
* \brief A (now decrypted) data packet has been received.
* NOTE: these can be received multiple times (per sender/contents), via different routes
* \param type one of: PAYLOAD_TYPE_ANON_REQ
* \param secret ECDH shared secret
* \param sender public key provided by sender
*/
virtual void onAnonDataRecv(Packet* packet, uint8_t type, const Identity& sender, uint8_t* data, size_t len) { }
virtual void onAnonDataRecv(Packet* packet, const uint8_t* secret, const Identity& sender, uint8_t* data, size_t len) { }
/**
* \brief A path TO 'sender' has been received. (also with optional 'extra' data encoded)