Skip to content

Commit 00fdf8d

Browse files
author
Mika Leppänen
committed
Added sending of initial EAPOL-key to original target during bootstrap
If during bootstrap, EAPOL key hash mismatch is detected after EAPOL authentication, but before bootstrap has completed, supplicant sends initial EAPOL-key message to original target of the EAPOL. Also when bootstrap is completed, supplicant checks for the EAPOL key hash mismatch, and if it is detected, supplicant triggers sending of the initial EAPOL-key to RPL parent. These changes should make recovering from the key mismatch faster if it happens during bootstrap.
1 parent 313794c commit 00fdf8d

File tree

5 files changed

+84
-12
lines changed

5 files changed

+84
-12
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,6 +2526,9 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
25262526
cur->ws_info->trickle_pas_running = false;
25272527
cur->ws_info->trickle_pcs_running = false;
25282528

2529+
// Indicate PAE controller that bootstrap is ready
2530+
ws_pae_controller_bootstrap_done(cur);
2531+
25292532
ws_bootstrap_advertise_start(cur);
25302533
ws_bootstrap_state_change(cur, ER_BOOTSRAP_DONE);
25312534
break;

source/6LoWPAN/ws/ws_pae_controller.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,25 @@ int8_t ws_pae_controller_authenticate(protocol_interface_info_entry_t *interface
182182
return 0;
183183
}
184184

185+
int8_t ws_pae_controller_bootstrap_done(protocol_interface_info_entry_t *interface_ptr)
186+
{
187+
pae_controller_t *controller = ws_pae_controller_get(interface_ptr);
188+
if (!controller) {
189+
return -1;
190+
}
191+
192+
#ifdef HAVE_PAE_SUPP
193+
// RPL parent is known, remove EAPOL target that what was set using the authenticate call */
194+
ws_pae_supp_eapol_target_remove(interface_ptr);
195+
196+
/* Trigger GTK hash update to supplicant, so it can check whether keys have been updated
197+
during bootstrap. Does nothing if GTKs are up to date. */
198+
ws_pae_supp_gtk_hash_update(interface_ptr, controller->gtkhash);
199+
#endif
200+
201+
return 0;
202+
}
203+
185204
int8_t ws_pae_controller_authenticator_start(protocol_interface_info_entry_t *interface_ptr, uint16_t local_port, const uint8_t *remote_addr, uint16_t remote_port)
186205
{
187206
(void) local_port;

source/6LoWPAN/ws/ws_pae_controller.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ int8_t ws_pae_controller_set_target(protocol_interface_info_entry_t *interface_p
4545
*/
4646
int8_t ws_pae_controller_authenticate(protocol_interface_info_entry_t *interface_ptr);
4747

48+
/**
49+
* ws_pae_controller_bootstrap_done indicates to PAE controller that bootstrap is ready
50+
*
51+
* \param interface_ptr interface
52+
*
53+
* \return < 0 failure
54+
* \return >= 0 success
55+
*
56+
*/
57+
int8_t ws_pae_controller_bootstrap_done(protocol_interface_info_entry_t *interface_ptr);
58+
4859
/**
4960
* ws_pae_controller_authenticator_start start PAE authenticator
5061
*

source/6LoWPAN/ws/ws_pae_supp.c

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ static void ws_pae_supp_address_set(pae_supp_t *pae_supp, kmp_addr_t *address)
166166
}
167167
}
168168

169+
static bool ws_pae_supp_address_is_set(pae_supp_t *pae_supp)
170+
{
171+
return pae_supp->entry_address_active;
172+
}
173+
169174
int8_t ws_pae_supp_authenticate(protocol_interface_info_entry_t *interface_ptr, uint16_t dest_pan_id, uint8_t *dest_eui_64)
170175
{
171176
pae_supp_t *pae_supp = ws_pae_supp_get(interface_ptr);
@@ -321,6 +326,9 @@ int8_t ws_pae_supp_gtk_hash_update(protocol_interface_info_entry_t *interface_pt
321326
ws_pae_supp_timer_start(pae_supp);
322327

323328
tr_info("GTK update start imin: %i, imax: %i, max mismatch: %i, tr time: %i", pae_supp->timer_settings->gtk_request_imin, pae_supp->timer_settings->gtk_request_imax, pae_supp->timer_settings->gtk_max_mismatch, pae_supp->auth_trickle_timer.t);
329+
} else {
330+
// If trickle is already running, set inconsistent heard to speed up the trickle
331+
trickle_inconsistent_heard(&pae_supp->auth_trickle_timer, &pae_supp->auth_trickle_params);
324332
}
325333
}
326334

@@ -346,6 +354,19 @@ int8_t ws_pae_supp_nw_key_index_update(protocol_interface_info_entry_t *interfac
346354
return 0;
347355
}
348356

357+
int8_t ws_pae_supp_eapol_target_remove(protocol_interface_info_entry_t *interface_ptr)
358+
{
359+
pae_supp_t *pae_supp = ws_pae_supp_get(interface_ptr);
360+
if (!pae_supp) {
361+
return -1;
362+
}
363+
364+
// Sets target/parent address to null
365+
ws_pae_supp_address_set(pae_supp, NULL);
366+
367+
return 0;
368+
}
369+
349370
static void ws_pae_supp_nvm_update(pae_supp_t *pae_supp)
350371
{
351372
// Check if NW info or GTKs have been changed
@@ -450,15 +471,21 @@ static int8_t ws_pae_supp_initial_key_send(pae_supp_t *pae_supp)
450471
if (!pae_supp->auth_requested) {
451472
// If not making initial authentication updates target (RPL parent) for each EAPOL-key message
452473
uint8_t parent_eui_64[8];
453-
if (ws_pae_supp_parent_eui_64_get(pae_supp->interface_ptr, parent_eui_64) < 0) {
474+
if (ws_pae_supp_parent_eui_64_get(pae_supp->interface_ptr, parent_eui_64) >= 0) {
475+
// Stores target/parent address
476+
kmp_address_init(KMP_ADDR_EUI_64, &pae_supp->target_addr, parent_eui_64);
477+
// Sets parent address in use
478+
ws_pae_supp_address_set(pae_supp, &pae_supp->target_addr);
479+
} else if (ws_pae_supp_address_is_set(pae_supp)) {
480+
/* If there is no RPL parent but there is target address from initial authentication
481+
bootstrap, tries to use it. This can happen if BR updates keys after EAPOL authentication
482+
but before bootstrap is completed and RPL parent is known */
483+
tr_info("EAPOL initial auth target used");
484+
} else {
485+
// No target, failure
454486
return -1;
455487
}
456488

457-
// Stores target/parent address
458-
kmp_address_init(KMP_ADDR_EUI_64, &pae_supp->target_addr, parent_eui_64);
459-
// Sets parent address in use
460-
ws_pae_supp_address_set(pae_supp, &pae_supp->target_addr);
461-
462489
ws_pae_lib_supp_timer_ticks_set(&pae_supp->entry, WAIT_FOR_REAUTHENTICATION_TICKS);
463490
tr_info("PAE wait for auth seconds: %i", WAIT_FOR_REAUTHENTICATION_TICKS / 10);
464491
}
@@ -758,10 +785,7 @@ void ws_pae_supp_fast_timer(uint16_t ticks)
758785

759786
// Checks whether timer needs to be active
760787
if (!pae_supp->initial_key_timer && !pae_supp->auth_trickle_running && !running) {
761-
762788
tr_debug("PAE idle");
763-
// Sets target/parent address to null
764-
ws_pae_supp_address_set(pae_supp, NULL);
765789
// If not already completed, restart bootstrap
766790
ws_pae_supp_authenticate_response(pae_supp, false);
767791

@@ -777,7 +801,9 @@ void ws_pae_supp_slow_timer(uint16_t seconds)
777801
// Checks whether initial EAPOL-Key message needs to be re-send or new GTK request to be sent
778802
if (pae_supp->auth_trickle_running) {
779803
if (trickle_timer(&pae_supp->auth_trickle_timer, &pae_supp->auth_trickle_params, seconds)) {
780-
ws_pae_supp_initial_key_send(pae_supp);
804+
if (ws_pae_supp_initial_key_send(pae_supp) < 0) {
805+
tr_info("EAPOL-Key send failed");
806+
}
781807
}
782808
// Maximum number of trickle expires, authentication fails
783809
if (!trickle_running(&pae_supp->auth_trickle_timer, &pae_supp->auth_trickle_params)) {
@@ -800,14 +826,15 @@ void ws_pae_supp_slow_timer(uint16_t seconds)
800826
pae_supp->initial_key_timer = 0;
801827

802828
// Sends initial EAPOL-Key message
803-
ws_pae_supp_initial_key_send(pae_supp);
829+
if (ws_pae_supp_initial_key_send(pae_supp) < 0) {
830+
tr_info("EAPOL-Key send failed");
831+
}
804832

805833
// Starts trickle
806834
pae_supp->auth_trickle_params = initial_eapol_key_trickle_params;
807835
trickle_start(&pae_supp->auth_trickle_timer, &pae_supp->auth_trickle_params);
808836
pae_supp->auth_trickle_running = true;
809837
}
810-
811838
}
812839
}
813840
}

source/6LoWPAN/ws/ws_pae_supp.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,17 @@ int8_t ws_pae_supp_gtk_hash_update(protocol_interface_info_entry_t *interface_pt
182182
*/
183183
int8_t ws_pae_supp_nw_key_index_update(protocol_interface_info_entry_t *interface_ptr, uint8_t index);
184184

185+
/**
186+
* ws_pae_supp_eapol_target_remove remove EAPOL target set using authentication start
187+
*
188+
* \param interface_ptr interface
189+
*
190+
* \return < 0 failure
191+
* \return >= 0 success
192+
*
193+
*/
194+
int8_t ws_pae_supp_eapol_target_remove(protocol_interface_info_entry_t *interface_ptr);
195+
185196
/**
186197
* ws_pae_supp_nw_key_index_set network send key index set callback
187198
*
@@ -238,6 +249,7 @@ void ws_pae_supp_cb_register(protocol_interface_info_entry_t *interface_ptr, ws_
238249
#define ws_pae_supp_border_router_addr_read NULL
239250
#define ws_pae_supp_gtk_hash_update NULL
240251
#define ws_pae_supp_nw_key_index_update NULL
252+
#define ws_pae_supp_eapol_target_remove(interface_ptr)
241253

242254
#endif
243255

0 commit comments

Comments
 (0)