Skip to content

Commit 0ad301a

Browse files
committed
Fix dirty session keys.
1 parent c0e5000 commit 0ad301a

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
@@ -1000,6 +1000,7 @@ bool BaseChatMesh::removeContact(ContactInfo& contact) {
10001000
nonce_at_last_persist[idx] = nonce_at_last_persist[idx + 1];
10011001
idx++;
10021002
}
1003+
memset(&contacts[num_contacts], 0, sizeof(ContactInfo));
10031004
return true; // Success
10041005
}
10051006

@@ -1139,6 +1140,7 @@ SessionKeyEntry* BaseChatMesh::allocateSessionKey(const uint8_t* pub_key) {
11391140

11401141
void BaseChatMesh::removeSessionKey(const uint8_t* pub_key) {
11411142
session_keys.remove(pub_key);
1143+
session_keys_dirty = true;
11421144
}
11431145

11441146
// --- Session key support (Phase 2 — initiator) ---
@@ -1395,6 +1397,8 @@ void BaseChatMesh::checkSessionKeyTimeouts() {
13951397
// All retries exhausted — clean up
13961398
memset(entry->ephemeral_prv, 0, PRV_KEY_SIZE);
13971399
memset(entry->ephemeral_pub, 0, PUB_KEY_SIZE);
1400+
memset(entry->session_key, 0, SESSION_KEY_SIZE);
1401+
memset(entry->prev_session_key, 0, SESSION_KEY_SIZE);
13981402
entry->state = SESSION_STATE_NONE;
13991403
entry->timeout_at = 0;
14001404
}

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)