Skip to content

Commit 95a2d8e

Browse files
committed
Fix dirty session keys.
1 parent af403d0 commit 95a2d8e

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
@@ -980,6 +980,7 @@ bool BaseChatMesh::removeContact(ContactInfo& contact) {
980980
nonce_at_last_persist[idx] = nonce_at_last_persist[idx + 1];
981981
idx++;
982982
}
983+
memset(&contacts[num_contacts], 0, sizeof(ContactInfo));
983984
return true; // Success
984985
}
985986

@@ -1119,6 +1120,7 @@ SessionKeyEntry* BaseChatMesh::allocateSessionKey(const uint8_t* pub_key) {
11191120

11201121
void BaseChatMesh::removeSessionKey(const uint8_t* pub_key) {
11211122
session_keys.remove(pub_key);
1123+
session_keys_dirty = true;
11221124
}
11231125

11241126
// --- Session key support (Phase 2 — initiator) ---
@@ -1375,6 +1377,8 @@ void BaseChatMesh::checkSessionKeyTimeouts() {
13751377
// All retries exhausted — clean up
13761378
memset(entry->ephemeral_prv, 0, PRV_KEY_SIZE);
13771379
memset(entry->ephemeral_pub, 0, PUB_KEY_SIZE);
1380+
memset(entry->session_key, 0, SESSION_KEY_SIZE);
1381+
memset(entry->prev_session_key, 0, SESSION_KEY_SIZE);
13781382
entry->state = SESSION_STATE_NONE;
13791383
entry->timeout_at = 0;
13801384
}

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)