Skip to content

Commit 535c005

Browse files
author
Mika Leppänen
committed
Corrected EAPOL key reuse on supplicant bootstrap restart
Validates that there is PMK, PTK and a GTK entry.
1 parent 01058c0 commit 535c005

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

source/6LoWPAN/ws/ws_pae_supp.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,12 @@ static int8_t ws_pae_supp_nw_keys_valid_check(pae_supp_t *pae_supp, uint16_t pan
469469
return -1;
470470
}
471471

472-
/* Checks if keys matches to PAN ID, and call inserts function that will update the
473-
network keys as needed */
474-
if (pan_id == pae_supp->sec_keys_nw_info.key_pan_id) {
472+
/* Checks if keys match to PAN ID and that needed keys exists (PMK, PTK and a GTK),
473+
and calls inserts function that will update the network keys as needed */
474+
if ((pan_id == pae_supp->sec_keys_nw_info.key_pan_id) &&
475+
(sec_prot_keys_gtk_count(pae_supp->sec_keys_nw_info.gtks) > 0) &&
476+
(sec_prot_keys_pmk_get(&pae_supp->entry.sec_keys) != NULL) &&
477+
(sec_prot_keys_ptk_get(&pae_supp->entry.sec_keys) != NULL)) {
475478
tr_debug("Existing keys used, counter %i", pae_supp->nw_keys_used_cnt);
476479
if (pae_supp->nw_key_insert(pae_supp->interface_ptr, pae_supp->sec_keys_nw_info.gtks) >= 0) {
477480
tr_debug("Keys inserted");

source/Security/protocols/sec_prot_keys.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,4 +765,17 @@ int8_t sec_prot_keys_gtk_install_index_get(sec_prot_gtk_keys_t *gtks)
765765
return install_index;
766766
}
767767

768+
uint8_t sec_prot_keys_gtk_count(sec_prot_gtk_keys_t *gtks)
769+
{
770+
uint8_t count = 0;
771+
772+
for (uint8_t i = 0; i < GTK_NUM; i++) {
773+
if (sec_prot_keys_gtk_is_set(gtks, i)) {
774+
count++;
775+
}
776+
}
777+
778+
return count;
779+
}
780+
768781
#endif /* HAVE_WS */

source/Security/protocols/sec_prot_keys.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,4 +721,14 @@ void sec_prot_keys_gtk_install_order_update(sec_prot_gtk_keys_t *gtks);
721721
*/
722722
int8_t sec_prot_keys_gtk_install_index_get(sec_prot_gtk_keys_t *gtks);
723723

724+
/**
725+
* sec_prot_keys_gtk_count counts GTK keys
726+
*
727+
* \param gtks GTK keys
728+
*
729+
* \return count of keys, 0 for no keys
730+
*
731+
*/
732+
uint8_t sec_prot_keys_gtk_count(sec_prot_gtk_keys_t *gtks);
733+
724734
#endif /* SEC_PROT_KEYS_H_ */

0 commit comments

Comments
 (0)