Skip to content

Commit 22c3213

Browse files
committed
Fix dirty session keys.
1 parent e7dcfba commit 22c3213

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/helpers/BaseChatMesh.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,7 @@ bool BaseChatMesh::removeContact(ContactInfo& contact) {
976976
nonce_at_last_persist[idx] = nonce_at_last_persist[idx + 1];
977977
idx++;
978978
}
979+
memset(&contacts[num_contacts], 0, sizeof(ContactInfo));
979980
return true; // Success
980981
}
981982

@@ -1115,6 +1116,7 @@ SessionKeyEntry* BaseChatMesh::allocateSessionKey(const uint8_t* pub_key) {
11151116

11161117
void BaseChatMesh::removeSessionKey(const uint8_t* pub_key) {
11171118
session_keys.remove(pub_key);
1119+
session_keys_dirty = true;
11181120
}
11191121

11201122
// --- Session key support (Phase 2 — initiator) ---
@@ -1371,6 +1373,8 @@ void BaseChatMesh::checkSessionKeyTimeouts() {
13711373
// All retries exhausted — clean up
13721374
memset(entry->ephemeral_prv, 0, PRV_KEY_SIZE);
13731375
memset(entry->ephemeral_pub, 0, PUB_KEY_SIZE);
1376+
memset(entry->session_key, 0, SESSION_KEY_SIZE);
1377+
memset(entry->prev_session_key, 0, SESSION_KEY_SIZE);
13741378
entry->state = SESSION_STATE_NONE;
13751379
entry->timeout_at = 0;
13761380
}

src/helpers/ClientACL.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ bool ClientACL::applyPermissions(const mesh::LocalIdentity& self_id, const uint8
223223
nonce_at_last_persist[i] = nonce_at_last_persist[i + 1];
224224
i++;
225225
}
226+
memset(&clients[num_clients], 0, sizeof(ClientInfo));
226227
} else {
227228
if (key_len < PUB_KEY_SIZE) return false; // need complete pubkey when adding/modifying
228229

@@ -460,6 +461,7 @@ SessionKeyEntry* ClientACL::allocateSessionKey(const uint8_t* pub_key) {
460461

461462
void ClientACL::removeSessionKey(const uint8_t* pub_key) {
462463
session_keys.remove(pub_key);
464+
_session_keys_dirty = true;
463465
}
464466

465467
void ClientACL::loadSessionKeys() {

0 commit comments

Comments
 (0)