Skip to content

Commit d3253c2

Browse files
committed
Fix dirty session keys.
1 parent a901550 commit d3253c2

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
@@ -909,6 +909,7 @@ bool BaseChatMesh::removeContact(ContactInfo& contact) {
909909
nonce_at_last_persist[idx] = nonce_at_last_persist[idx + 1];
910910
idx++;
911911
}
912+
memset(&contacts[num_contacts], 0, sizeof(ContactInfo));
912913
return true; // Success
913914
}
914915

@@ -1048,6 +1049,7 @@ SessionKeyEntry* BaseChatMesh::allocateSessionKey(const uint8_t* pub_key) {
10481049

10491050
void BaseChatMesh::removeSessionKey(const uint8_t* pub_key) {
10501051
session_keys.remove(pub_key);
1052+
session_keys_dirty = true;
10511053
}
10521054

10531055
// --- Session key support (Phase 2 — initiator) ---
@@ -1304,6 +1306,8 @@ void BaseChatMesh::checkSessionKeyTimeouts() {
13041306
// All retries exhausted — clean up
13051307
memset(entry->ephemeral_prv, 0, PRV_KEY_SIZE);
13061308
memset(entry->ephemeral_pub, 0, PUB_KEY_SIZE);
1309+
memset(entry->session_key, 0, SESSION_KEY_SIZE);
1310+
memset(entry->prev_session_key, 0, SESSION_KEY_SIZE);
13071311
entry->state = SESSION_STATE_NONE;
13081312
entry->timeout_at = 0;
13091313
}

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)