Skip to content

Commit 7994d95

Browse files
author
Mika Leppänen
committed
If PMK and PTK are not set do not store keys to NVM
On border router do not allocate new supplicant data to NVM if both PTK and PMK are not set.
1 parent 40dc215 commit 7994d95

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

source/6LoWPAN/ws/ws_pae_key_storage.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,17 @@ int8_t ws_pae_key_storage_supp_write(const void *instance, supp_entry_t *pae_sup
360360
uint8_t *eui_64 = pae_supp->addr.eui_64;
361361

362362
key_storage_array_t *key_storage_array;
363-
sec_prot_keys_storage_t *key_storage = ws_pae_key_storage_get(instance, eui_64, &key_storage_array, true);
363+
// Check if entry exists
364+
sec_prot_keys_storage_t *key_storage = ws_pae_key_storage_get(instance, eui_64, &key_storage_array, false);
365+
if (key_storage == NULL) {
366+
// Do not allocate new storage if PMK and PTK are not set
367+
if (!pae_supp->sec_keys.pmk_set && !pae_supp->sec_keys.ptk_set) {
368+
tr_info("KeyS PMK and PTK not set, skip storing, eui64: %s", tr_array(eui_64, 8));
369+
return -1;
370+
}
371+
// Allocate new empty entry
372+
key_storage = ws_pae_key_storage_get(instance, eui_64, &key_storage_array, true);
373+
}
364374

365375
// If cannot find existing or empty storage and there is room for storages tries to allocate more storage
366376
if (key_storage == NULL && key_storage_params.storages_empty > 0) {

0 commit comments

Comments
 (0)