Bind incoming UDP INIT identity to the authenticated key

This commit is contained in:
evgeny committed 2026-10-23 23:17:25 +02:00
1 parent 2f6ff9303e
commit 5ccd47dd17
2 files changed
+7 -1

No files matched your search

+6
View File
@@ -2441,6 +2441,12 @@ static void etcp_process_packet(struct ETCP_SOCKET* e_sock, uint8_t* data,
struct ETCP_INIT_REQUEST_PKT* req = (struct ETCP_INIT_REQUEST_PKT*)pkt->data;
peer_id = wire_read64(req->node_id);
uint64_t authenticated_id = sc_derive_node_id_from_pubkey(sc.peer_public_key);
if (peer_id != authenticated_id) {
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "INIT sender ID mismatch: claimed=%016llx authenticated=%016llx from=%s",
(unsigned long long)peer_id, (unsigned long long)authenticated_id, sockaddr_storage_to_str(&addr).str);
errorcode = 7; goto ec_fr;
}
uint64_t reset_id = wire_read64(req->reset_id);
uint16_t mtu = wire_read16(req->mtu);
uint16_t src_port = wire_read16(req->src_port);
+1 -1
View File
@@ -94,7 +94,7 @@ static inline unsigned etcp_ack_section_size(uint8_t count) {
// INIT внутри шифрованного тела, до padding: запрос — 67 байт, ответ — 64 байта.
// Каждая сторона передаёт свою эпоху reset_id; смена известной эпохи подтверждается через etcp_session.
// INIT REQUEST: client → server. Проверить всё 67-байтовое тело до чтения полей и изменения транспорта; padding допустим.
// INIT REQUEST: client → server. До изменения транспорта проверить 67-байтовое тело и node_id по X25519-ключу; padding допустим.
struct ETCP_INIT_REQUEST_PKT {
uint8_t code; // 0: ETCP_INIT_REQUEST (0x02) или ETCP_INIT_REQUEST_NOINIT (0x04)
uint8_t node_id[8]; // 1: sender node_id (big-endian)