From 1a293c436a7c7f0aeb1d5eb4d6ff4e36180bcfd4 Mon Sep 17 00:00:00 2001 From: evgeny Date: Mon, 26 Oct 2026 19:35:45 +0100 Subject: [PATCH] Diagnose admin key derivation failures without exposing secrets --- src/chat/chat_admin.c | 3 ++- tests/test_chat_admin.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/chat/chat_admin.c b/src/chat/chat_admin.c index 404875aed..998142fa6 100644 --- a/src/chat/chat_admin.c +++ b/src/chat/chat_admin.c @@ -32,10 +32,11 @@ static int ed25519_pub_from_priv(const uint8_t priv[32], uint8_t pub[32]) { EVP_PKEY* pkey = EVP_PKEY_new_raw_private_key(EVP_PKEY_ED25519, NULL, priv, 32); - if (!pkey) return -1; + if (!pkey) { DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "%s: Ed25519 private key initialization failed", CA_ID); return -1; } size_t plen = 32; int ok = EVP_PKEY_get_raw_public_key(pkey, pub, &plen) == 1 && plen == 32; EVP_PKEY_free(pkey); + if (!ok) DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "%s: Ed25519 public key derivation failed bytes=%zu", CA_ID, plen); return ok ? 0 : -1; } diff --git a/tests/test_chat_admin.c b/tests/test_chat_admin.c index b0f06db26..7f6f9d6ab 100644 --- a/tests/test_chat_admin.c +++ b/tests/test_chat_admin.c @@ -124,7 +124,7 @@ static void cleanup(struct fixture* f) { chat_event_set_handler(f->inst, NULL); active = NULL; utun_instance_destroy(f->inst); uasync_destroy(f->ua, 0); } -/* Доставка собственной расшифрованной записи через зарегистрированный callback; сеть здесь не подменяется тестом отправки. */ +/* Доставка собственной расшифрованной записи через callback; сетевой путь и шифрование проверяются отдельно. */ static void receive(struct fixture* f, uint64_t group, const uint8_t ed[32], const uint8_t x[32]) { struct ll_entry* e = ll_alloc_lldgram(ROUTER_SVC_HDR_SIZE + 72); assert(e); e->len = ROUTER_SVC_HDR_SIZE + 72; memset(e->dgram, 0, e->len); @@ -212,6 +212,6 @@ int main(void) { test_faults(); test_sql_and_replay(); test_outer_transaction(); test_rollback_failure(); for (unsigned i = SAVEPOINT; i < FAULTS; i++) assert(hits[i] == (i == FINALIZE || i == RELEASE ? 3 : 2)); assert(rollback_hits == 1 && u_get_allocated_count() == baseline); - DEBUG_INFO(DEBUG_CATEGORY_CHAT_SYNC, "PASS admin: NULL context, 22 injected failures, no tracked allocations remain"); + DEBUG_INFO(DEBUG_CATEGORY_CHAT_SYNC, "PASS admin: NULL context, 22 SQL/crypto faults + rollback fault, allocations restored"); return 0; }