Skip to content

Commit f27fe86

Browse files
author
Mika Leppänen
committed
Corrected network name and PAN ID change on auth start
PAE supplicant did not detect correctly that network name or PAN ID was changed on authentication start. This causes the supplicant to use old keys and old BR EUI-64 during authentication, which resulted to BR EUI-64 mismatch on 4WH.
1 parent bcce0ed commit f27fe86

File tree

5 files changed

+52
-6
lines changed

5 files changed

+52
-6
lines changed

source/6LoWPAN/ws/ws_pae_auth.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,10 @@ void ws_pae_auth_forced_gc(protocol_interface_info_entry_t *interface_ptr)
470470
ws_pae_lib_supp_list_purge(&pae_auth->active_supp_list, 0, SUPPLICANT_NUMBER_TO_PURGE);
471471
}
472472

473-
int8_t ws_pae_auth_nw_info_set(protocol_interface_info_entry_t *interface_ptr, uint16_t pan_id, char *network_name)
473+
int8_t ws_pae_auth_nw_info_set(protocol_interface_info_entry_t *interface_ptr, uint16_t pan_id, char *network_name, bool updated)
474474
{
475+
(void) updated;
476+
475477
if (!interface_ptr || !network_name) {
476478
return -1;
477479
}

source/6LoWPAN/ws/ws_pae_auth.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,13 @@ void ws_pae_auth_forced_gc(protocol_interface_info_entry_t *interface_ptr);
174174
* \param interface_ptr interface
175175
* \param pan_id PAD ID
176176
* \param network_name network name
177+
* \param updated data has been updated
177178
*
178179
* \return < 0 failure
179180
* \return >= 0 success
180181
*
181182
*/
182-
int8_t ws_pae_auth_nw_info_set(protocol_interface_info_entry_t *interface_ptr, uint16_t pan_id, char *network_name);
183+
int8_t ws_pae_auth_nw_info_set(protocol_interface_info_entry_t *interface_ptr, uint16_t pan_id, char *network_name, bool updated);
183184

184185
/**
185186
* ws_pae_auth_gtk_hash_set GTK hash set callback

source/6LoWPAN/ws/ws_pae_controller.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ typedef int8_t ws_pae_br_addr_read(protocol_interface_info_entry_t *interface_pt
5252
typedef void ws_pae_gtks_updated(protocol_interface_info_entry_t *interface_ptr);
5353
typedef int8_t ws_pae_gtk_hash_update(protocol_interface_info_entry_t *interface_ptr, uint8_t *gtkhash);
5454
typedef int8_t ws_pae_nw_key_index_update(protocol_interface_info_entry_t *interface_ptr, uint8_t index);
55-
typedef int8_t ws_pae_nw_info_set(protocol_interface_info_entry_t *interface_ptr, uint16_t pan_id, char *network_name);
55+
typedef int8_t ws_pae_nw_info_set(protocol_interface_info_entry_t *interface_ptr, uint16_t pan_id, char *network_name, bool updated);
5656

5757
typedef struct {
5858
uint8_t gtk[GTK_LEN]; /**< GTK key */
@@ -290,20 +290,24 @@ int8_t ws_pae_controller_nw_info_set(protocol_interface_info_entry_t *interface_
290290
return -1;
291291
}
292292

293+
bool updated = false;
294+
293295
// Network name has been modified
294-
if (network_name && strncmp(controller->sec_keys_nw_info.network_name, network_name, 33) != 0) {
296+
if (network_name && strcmp(controller->sec_keys_nw_info.network_name, network_name) != 0) {
295297
strncpy(controller->sec_keys_nw_info.network_name, network_name, 32);
296298
controller->sec_keys_nw_info.updated = true;
299+
updated = true;
297300
}
298301

299302
// PAN ID has been modified
300303
if (pan_id != 0xffff && pan_id != controller->sec_keys_nw_info.new_pan_id) {
301304
controller->sec_keys_nw_info.new_pan_id = pan_id;
302305
controller->sec_keys_nw_info.updated = true;
306+
updated = true;
303307
}
304308

305309
if (controller->pae_nw_info_set) {
306-
controller->pae_nw_info_set(interface_ptr, pan_id, network_name);
310+
controller->pae_nw_info_set(interface_ptr, pan_id, network_name, updated);
307311
}
308312

309313
return 0;
@@ -803,7 +807,7 @@ int8_t ws_pae_controller_supp_init(protocol_interface_info_entry_t *interface_pt
803807
controller->pae_br_addr_read = ws_pae_supp_border_router_addr_read;
804808
controller->pae_gtk_hash_update = ws_pae_supp_gtk_hash_update;
805809
controller->pae_nw_key_index_update = ws_pae_supp_nw_key_index_update;
806-
controller->pae_nw_info_set = NULL;
810+
controller->pae_nw_info_set = ws_pae_supp_nw_info_set;
807811

808812
ws_pae_supp_cb_register(controller->interface_ptr, controller->auth_completed, controller->auth_next_target, ws_pae_controller_nw_key_check_and_insert, ws_pae_controller_active_nw_key_set, ws_pae_controller_gtk_hash_ptr_get, ws_pae_controller_nw_info_updated_check);
809813

source/6LoWPAN/ws/ws_pae_supp.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,31 @@ static int8_t ws_pae_supp_nw_keys_valid_check(pae_supp_t *pae_supp, uint16_t pan
524524
}
525525
}
526526

527+
int8_t ws_pae_supp_nw_info_set(protocol_interface_info_entry_t *interface_ptr, uint16_t pan_id, char *network_name, bool updated)
528+
{
529+
(void) pan_id;
530+
(void) network_name;
531+
532+
pae_supp_t *pae_supp = ws_pae_supp_get(interface_ptr);
533+
if (!pae_supp) {
534+
return -1;
535+
}
536+
537+
if (updated) {
538+
tr_info("Delete old keys, new PAN ID: %i network name: %s", pan_id, network_name);
539+
// Delete pair wise keys
540+
sec_prot_keys_pmk_delete(&pae_supp->entry.sec_keys);
541+
sec_prot_keys_ptk_delete(&pae_supp->entry.sec_keys);
542+
sec_prot_keys_ptk_eui_64_delete(&pae_supp->entry.sec_keys);
543+
// Delete GTKs
544+
sec_prot_keys_gtks_init(pae_supp->sec_keys_nw_info->gtks);
545+
sec_prot_keys_gtks_updated_set(pae_supp->sec_keys_nw_info->gtks);
546+
ws_pae_supp_nvm_update(pae_supp);
547+
}
548+
549+
return 0;
550+
}
551+
527552
void ws_pae_supp_cb_register(protocol_interface_info_entry_t *interface_ptr, ws_pae_supp_auth_completed *completed, ws_pae_supp_auth_next_target *auth_next_target, ws_pae_supp_nw_key_insert *nw_key_insert, ws_pae_supp_nw_key_index_set *nw_key_index_set, ws_pae_supp_gtk_hash_ptr_get *gtk_hash_ptr_get, ws_pae_supp_nw_info_updated *nw_info_updated)
528553
{
529554
pae_supp_t *pae_supp = ws_pae_supp_get(interface_ptr);

source/6LoWPAN/ws/ws_pae_supp.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,20 @@ int8_t ws_pae_supp_gtks_set(protocol_interface_info_entry_t *interface_ptr, sec_
173173
*/
174174
int8_t ws_pae_supp_eapol_target_remove(protocol_interface_info_entry_t *interface_ptr);
175175

176+
/**
177+
* ws_pae_auth_nw_info_set set network information
178+
*
179+
* \param interface_ptr interface
180+
* \param pan_id PAD ID
181+
* \param network_name network name
182+
* \param updated data has been updated
183+
*
184+
* \return < 0 failure
185+
* \return >= 0 success
186+
*
187+
*/
188+
int8_t ws_pae_supp_nw_info_set(protocol_interface_info_entry_t *interface_ptr, uint16_t pan_id, char *network_name, bool updated);
189+
176190
/**
177191
* ws_pae_supp_nw_key_index_set network send key index set callback
178192
*

0 commit comments

Comments
 (0)