Skip to content

Commit 1da209a

Browse files
committed
Fix dirty session keys.
1 parent 65af393 commit 1da209a

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
@@ -918,6 +918,7 @@ bool BaseChatMesh::removeContact(ContactInfo& contact) {
918918
nonce_at_last_persist[idx] = nonce_at_last_persist[idx + 1];
919919
idx++;
920920
}
921+
memset(&contacts[num_contacts], 0, sizeof(ContactInfo));
921922
return true; // Success
922923
}
923924

@@ -1057,6 +1058,7 @@ SessionKeyEntry* BaseChatMesh::allocateSessionKey(const uint8_t* pub_key) {
10571058

10581059
void BaseChatMesh::removeSessionKey(const uint8_t* pub_key) {
10591060
session_keys.remove(pub_key);
1061+
session_keys_dirty = true;
10601062
}
10611063

10621064
// --- Session key support (Phase 2 — initiator) ---
@@ -1313,6 +1315,8 @@ void BaseChatMesh::checkSessionKeyTimeouts() {
13131315
// All retries exhausted — clean up
13141316
memset(entry->ephemeral_prv, 0, PRV_KEY_SIZE);
13151317
memset(entry->ephemeral_pub, 0, PUB_KEY_SIZE);
1318+
memset(entry->session_key, 0, SESSION_KEY_SIZE);
1319+
memset(entry->prev_session_key, 0, SESSION_KEY_SIZE);
13161320
entry->state = SESSION_STATE_NONE;
13171321
entry->timeout_at = 0;
13181322
}

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)