mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-30 08:29:56 +00:00
Check for blank key coming from client
This commit is contained in:
parent
2661fc694f
commit
8ce1c07c4e
@ -472,8 +472,10 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
|
|||||||
LOG_DEBUG("Using PKI!\n");
|
LOG_DEBUG("Using PKI!\n");
|
||||||
if (numbytes + 8 > MAX_RHPACKETLEN)
|
if (numbytes + 8 > MAX_RHPACKETLEN)
|
||||||
return meshtastic_Routing_Error_TOO_LARGE;
|
return meshtastic_Routing_Error_TOO_LARGE;
|
||||||
if (memcmp(p->public_key.bytes, node->user.public_key.bytes, 32) != 0) {
|
if (p->pki_encrypted && !memfll(p->public_key.bytes, 0, 32) &&
|
||||||
LOG_WARN("Client public key for client differs from requested!\n");
|
memcmp(p->public_key.bytes, node->user.public_key.bytes, 32) != 0) {
|
||||||
|
LOG_WARN("Client public key for client differs from requested! Requested 0x%02x, but stored key begins 0x%02x\n",
|
||||||
|
*p->public_key.bytes, *node->user.public_key.bytes);
|
||||||
return meshtastic_Routing_Error_PKI_FAILED;
|
return meshtastic_Routing_Error_PKI_FAILED;
|
||||||
}
|
}
|
||||||
crypto->encryptCurve25519(p->to, getFrom(p), p->id, numbytes, bytes, ScratchEncrypted);
|
crypto->encryptCurve25519(p->to, getFrom(p), p->id, numbytes, bytes, ScratchEncrypted);
|
||||||
|
@ -64,4 +64,13 @@ void printBytes(const char *label, const uint8_t *p, size_t numbytes)
|
|||||||
for (size_t i = 0; i < numbytes; i++)
|
for (size_t i = 0; i < numbytes; i++)
|
||||||
LOG_DEBUG("%02x ", p[i]);
|
LOG_DEBUG("%02x ", p[i]);
|
||||||
LOG_DEBUG("\n");
|
LOG_DEBUG("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < numbytes; i++) {
|
||||||
|
if (mem[i] != find)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
@ -14,4 +14,7 @@ template <class T> constexpr const T &clamp(const T &v, const T &lo, const T &hi
|
|||||||
char *strnstr(const char *s, const char *find, size_t slen);
|
char *strnstr(const char *s, const char *find, size_t slen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void printBytes(const char *label, const uint8_t *p, size_t numbytes);
|
void printBytes(const char *label, const uint8_t *p, size_t numbytes);
|
||||||
|
|
||||||
|
// is the memory region filled with a single character?
|
||||||
|
bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes);
|
Loading…
Reference in New Issue
Block a user