Skip to content

Commit e9759e8

Browse files
author
Mika Leppänen
committed
Added trigger to authenticator to re-start delayed EAP-TLS
If authenticator has delayed supplicant EAP-TLS negotiation because limit for simultaneous EAP-TLS negotiations has been reached, authenticator can now continue delayed EAP-TLS negotiation. There is time window (60 seconds after original request) when the continue is made. This ensures that supplicant is still waiting for EAP-TLS to start when authenticator triggers the negotiation.
1 parent 30c538a commit e9759e8

File tree

3 files changed

+82
-12
lines changed

3 files changed

+82
-12
lines changed

source/6LoWPAN/ws/ws_pae_auth.c

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
// Maximum number of simultaneous EAP-TLS negotiations
6060
#define MAX_SIMULTANEOUS_EAP_TLS_NEGOTIATIONS 3
6161

62+
/* If EAP-TLS is delayed due to simultaneous negotiations limit, defines how
63+
long to wait for previous negotiation to complete */
64+
#define EAP_TLS_NEGOTIATION_TRIGGER_TIMEOUT 60 * 10 // 60 seconds
65+
6266
typedef struct {
6367
ns_list_link_t link; /**< Link */
6468
kmp_service_t *kmp_service; /**< KMP service */
@@ -100,6 +104,7 @@ static kmp_api_t *ws_pae_auth_kmp_incoming_ind(kmp_service_t *service, kmp_type_
100104
static void ws_pae_auth_kmp_api_create_confirm(kmp_api_t *kmp, kmp_result_e result);
101105
static void ws_pae_auth_kmp_api_create_indication(kmp_api_t *kmp, kmp_type_e type, kmp_addr_t *addr);
102106
static void ws_pae_auth_kmp_api_finished_indication(kmp_api_t *kmp, kmp_result_e result, kmp_sec_keys_t *sec_keys);
107+
static void ws_pae_auth_next_kmp_trigger(pae_auth_t *pae_auth, supp_entry_t *supp_entry);
103108
static kmp_type_e ws_pae_auth_next_protocol_get(supp_entry_t *supp_entry);
104109
static kmp_api_t *ws_pae_auth_kmp_create_and_start(kmp_service_t *service, kmp_type_e type, supp_entry_t *supp_entry);
105110
static void ws_pae_auth_kmp_api_finished(kmp_api_t *kmp);
@@ -834,6 +839,20 @@ static void ws_pae_auth_kmp_api_finished_indication(kmp_api_t *kmp, kmp_result_e
834839
// Should not be possible
835840
return;
836841
}
842+
kmp_service_t *service = kmp_api_service_get(kmp);
843+
pae_auth_t *pae_auth = ws_pae_auth_by_kmp_service_get(service);
844+
if (!pae_auth) {
845+
// Should not be possible
846+
return;
847+
}
848+
849+
ws_pae_auth_next_kmp_trigger(pae_auth, supp_entry);
850+
}
851+
852+
static void ws_pae_auth_next_kmp_trigger(pae_auth_t *pae_auth, supp_entry_t *supp_entry)
853+
{
854+
// Disables KMP retry timer
855+
supp_entry->retry_ticks = 0;
837856

838857
// Get next protocol based on what keys supplicant has
839858
kmp_type_e next_type = ws_pae_auth_next_protocol_get(supp_entry);
@@ -846,19 +865,17 @@ static void ws_pae_auth_kmp_api_finished_indication(kmp_api_t *kmp, kmp_result_e
846865
// Increases waiting time for supplicant authentication
847866
ws_pae_lib_supp_timer_ticks_set(supp_entry, WAIT_FOR_AUTHENTICATION_TICKS);
848867

849-
kmp_service_t *service = kmp_api_service_get(kmp);
850-
pae_auth_t *pae_auth = ws_pae_auth_by_kmp_service_get(service);
851-
if (!pae_auth) {
852-
return;
853-
}
854-
855868
if (next_type == IEEE_802_1X_MKA) {
856869
/* For EAP-TLS, limits the number of ongoing negotiations. If limit
857-
is reached, supplicant must re-send initial EAPOL-Key to try again
858-
using its trickle schedule */
870+
is reached, authenticator does not initiate EAP-TLS right away.
871+
If previous EAP-TLS negotiation completes before negotiation
872+
trigger timeout, authenticator initiates EAP-TLS towards
873+
supplicant. Otherwise supplicant must re-send initial EAPOL-Key
874+
to try again using its trickle schedule */
859875
uint16_t ongoing_eap_tls_cnt = ws_pae_lib_supp_list_kmp_count(&pae_auth->active_supp_list, IEEE_802_1X_MKA);
860876
if (ongoing_eap_tls_cnt >= MAX_SIMULTANEOUS_EAP_TLS_NEGOTIATIONS) {
861-
tr_info("EAP-TLS max ongoing reached, count %i, ignored: eui-64: %s", ongoing_eap_tls_cnt, trace_array(kmp_address_eui_64_get(supp_entry->addr), 8));
877+
supp_entry->retry_ticks = EAP_TLS_NEGOTIATION_TRIGGER_TIMEOUT;
878+
tr_info("EAP-TLS max ongoing reached, count %i, delayed: eui-64: %s", ongoing_eap_tls_cnt, trace_array(kmp_address_eui_64_get(supp_entry->addr), 8));
862879
return;
863880
}
864881
}
@@ -877,7 +894,7 @@ static void ws_pae_auth_kmp_api_finished_indication(kmp_api_t *kmp, kmp_result_e
877894
return;
878895
}
879896
// Create TLS instance */
880-
if (ws_pae_auth_kmp_create_and_start(service, TLS_PROT, supp_entry) == NULL) {
897+
if (ws_pae_auth_kmp_create_and_start(pae_auth->kmp_service, TLS_PROT, supp_entry) == NULL) {
881898
ws_pae_lib_kmp_list_delete(&supp_entry->kmp_list, new_kmp);
882899
return;
883900
}
@@ -970,8 +987,25 @@ static void ws_pae_auth_kmp_api_finished(kmp_api_t *kmp)
970987
return;
971988
}
972989

990+
pae_auth_t *pae_auth = NULL;
991+
supp_entry_t *retry_supp = NULL;
992+
// When EAP-TLS completes check if there are other supplicants that have requested it lately
993+
if (kmp_api_type_get(kmp) == IEEE_802_1X_MKA) {
994+
kmp_service_t *service = kmp_api_service_get(kmp);
995+
pae_auth = ws_pae_auth_by_kmp_service_get(service);
996+
if (pae_auth) {
997+
retry_supp = ws_pae_lib_supp_list_entry_retry_timer_get(&pae_auth->active_supp_list);
998+
}
999+
}
1000+
9731001
// Delete KMP
9741002
ws_pae_lib_kmp_list_delete(&supp_entry->kmp_list, kmp);
1003+
1004+
if (retry_supp) {
1005+
tr_info("PAE next KMP trigger, eui-64: %s", trace_array(kmp_address_eui_64_get(retry_supp->addr), 8));
1006+
ws_pae_auth_next_kmp_trigger(pae_auth, retry_supp);
1007+
}
1008+
9751009
}
9761010

9771011
#endif /* HAVE_PAE_AUTH */

source/6LoWPAN/ws/ws_pae_lib.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ void ws_pae_lib_supp_init(supp_entry_t *entry)
228228
entry->addr = 0;
229229
memset(&entry->sec_keys, 0, sizeof(sec_prot_keys_t));
230230
entry->ticks = 0;
231+
entry->retry_ticks = 0;
231232
entry->active = true;
232233
entry->access_revoked = false;
233234
}
@@ -250,9 +251,17 @@ bool ws_pae_lib_supp_timer_update(supp_entry_t *entry, uint16_t ticks, ws_pae_li
250251
entry->ticks -= ticks;
251252
} else {
252253
entry->ticks = 0;
254+
entry->retry_ticks = 0;
253255
}
254256
}
255257

258+
// Updates retry timer
259+
if (entry->retry_ticks > ticks) {
260+
entry->retry_ticks -= ticks;
261+
} else {
262+
entry->retry_ticks = 0;
263+
}
264+
256265
return keep_timer_running;
257266
}
258267

@@ -322,4 +331,20 @@ uint16_t ws_pae_lib_supp_list_kmp_count(supp_list_t *supp_list, kmp_type_e type)
322331
return kmp_count;
323332
}
324333

334+
supp_entry_t *ws_pae_lib_supp_list_entry_retry_timer_get(supp_list_t *supp_list)
335+
{
336+
supp_entry_t *retry_supp = NULL;
337+
338+
ns_list_foreach(supp_entry_t, entry, supp_list) {
339+
// Finds entry with shortest timeout i.e. oldest one
340+
if (entry->retry_ticks > 0) {
341+
if (!retry_supp || retry_supp->retry_ticks > entry->retry_ticks) {
342+
retry_supp = entry;
343+
}
344+
}
345+
}
346+
347+
return retry_supp;
348+
}
349+
325350
#endif /* HAVE_WS */

source/6LoWPAN/ws/ws_pae_lib.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ typedef struct {
3636
kmp_addr_t *addr; /**< EUI-64 (Relay IP address, Relay port) */
3737
sec_prot_keys_t sec_keys; /**< Security keys */
3838
uint32_t ticks; /**< Ticks */
39-
bool active; /**< Is active */
40-
bool access_revoked; /**< Nodes access is revoked */
39+
uint16_t retry_ticks; /**< Retry ticks */
40+
bool active : 1; /**< Is active */
41+
bool access_revoked : 1; /**< Nodes access is revoked */
4142
ns_list_link_t link; /**< Link */
4243
} supp_entry_t;
4344

@@ -290,4 +291,14 @@ void ws_pae_lib_supp_list_to_inactive(supp_list_t *active_supp_list, supp_list_t
290291
*/
291292
uint16_t ws_pae_lib_supp_list_kmp_count(supp_list_t *supp_list, kmp_type_e type);
292293

294+
/**
295+
* ws_pae_lib_supp_list_entry_retry_timer_get checks if some supplicant has retry timer running
296+
*
297+
* \param supp_list list of supplicants
298+
*
299+
* \return supplicant with retry timer running or NULL if no supplicants with timer running
300+
*
301+
*/
302+
supp_entry_t *ws_pae_lib_supp_list_entry_retry_timer_get(supp_list_t *supp_list);
303+
293304
#endif /* WS_PAE_AUTH_H_ */

0 commit comments

Comments
 (0)