Sign exact join credentials during admission and preservation

This commit is contained in:
evgeny committed 2026-11-03 15:57:53 +01:00
1 parent 7c0814345d
commit 08a233eeed
3 files changed
+5 -4

No files matched your search

+1 -1
View File
@@ -131,7 +131,7 @@ int chat_core_create_channel(struct UTUN_INSTANCE* inst, const struct chat_chann
bytes = member_sync_build_join_msg(req->x25519_pubkey, req->ed25519_pubkey, inst->node_id,
inst->my_keys.public_key, timestamp, body, sizeof(body));
if (bytes < 0 || sc_ed25519_sign(inst->my_ed25519_privkey, body, (size_t)bytes, join) != SC_OK ||
member_sync_sign_pubkey(req->ed25519_privkey, inst->my_keys.public_key, root) < 0) {
member_sync_sign_join(req->ed25519_privkey, join, root) < 0) {
DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "channel create: root JOIN/invitation signing failed ch=%s", req->channel_id); return -1;
}
if (chat_core_name_userinfo(inst->name, profile, sizeof(profile))) return -1;
+1 -1
View File
@@ -218,7 +218,7 @@ int chat_join_process_request(struct UTUN_INSTANCE* inst, uint64_t group_id,
/* 3. добавить мембера + подписать его pubkey (дерево приглашений) */
uint8_t tree_sig[64];
if (member_sync_sign_pubkey(inst->my_ed25519_privkey, m.x25519, tree_sig) != 0) {
if (member_sync_sign_join(inst->my_ed25519_privkey, m.join_sig, tree_sig) != 0) {
DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "%s: process_request sign_pubkey FAILED nid=0x%016llx", CJ_ID, (unsigned long long)m.node_id);
return CHAT_CONNECT_ERROR;
}
+3 -2
View File
@@ -108,7 +108,7 @@ int group_policy_apply(sqlite3* db, const char* channel, const struct group_poli
struct gp_member {
uint64_t node, signer;
uint8_t x[32], ed[32], valid, admin, previous, allowed, keep;
uint8_t x[32], ed[32], join[64], valid, admin, previous, allowed, keep;
size_t child, sibling; /* Индексы + 1, 0 — конец списка детей. */
char name[128];
};
@@ -150,6 +150,7 @@ static int gp_load(struct UTUN_INSTANCE* inst, const char* ch, struct gp_member*
if (!m.x25519 || !m.ed25519 || !m.join_sig || !m.signature) { rc = SQLITE_NOMEM; goto done; }
memcpy(p->x, m.x25519, 32);
memcpy(p->ed, m.ed25519, 32);
memcpy(p->join, m.join_sig, 64);
int verified = member_sync_verify_local_record(db, ch, &m);
if (verified < 0) goto done;
int tree = member_sync_verify_signature(db, ch, &m);
@@ -313,7 +314,7 @@ int group_policy_command(struct UTUN_INSTANCE* inst, const char* channel, int al
transaction = 1;
for (size_t i = 0; i < count; i++) if (m[i].keep && m[i].signer) {
uint8_t signature[64];
if (member_sync_sign_pubkey(key, m[i].x, signature) ||
if (member_sync_sign_join(key, m[i].join, signature) ||
member_sync_put(inst, channel, m[i].node, m[i].x, m[i].ed, NULL, 0, NULL, 0, NULL, NULL, NULL, 0, 0, signature) < 0) goto done;
}
if (policy.version == INT64_MAX) { error = "version_exhausted"; goto done; }