Skip to content

Commit 420c5be

Browse files
author
Mika Leppänen
committed
Disabled initial EAPOL-Key retry on GTK lifetime mismatch
If supplicant notices that GTK has been removed by authenticator (i.e. removed from GTK hash), before the expected expiry determined by GTK lifetime, it initiates two way handshake to check the GTK status. Since everything is up to date, it is not required that authenticator reacts to initial EAPOL-Key message. Changed retry logic so that for lifetime mismatch, supplicant sends EAPOL-Key message only once and does not retry it.
1 parent 25ae74e commit 420c5be

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

source/6LoWPAN/ws/ws_pae_supp.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ int8_t ws_pae_supp_gtk_hash_update(protocol_interface_info_entry_t *interface_pt
274274
}
275275

276276
// Check GTK hashes and initiate EAPOL procedure if mismatch is detected */
277-
if (sec_prot_keys_gtks_hash_update(&pae_supp->gtks, gtkhash)) {
278-
277+
gtk_mismatch_e mismatch = sec_prot_keys_gtks_hash_update(&pae_supp->gtks, gtkhash);
278+
if (mismatch > GTK_NO_MISMATCH) {
279279
tr_info("GTK hash update %s %s %s %s",
280280
trace_array(&gtkhash[0], 8),
281281
trace_array(&gtkhash[8], 8),
@@ -284,10 +284,16 @@ int8_t ws_pae_supp_gtk_hash_update(protocol_interface_info_entry_t *interface_pt
284284

285285
// Mismatch, initiate EAPOL
286286
if (!pae_supp->auth_trickle_running) {
287+
uint8_t timer_expirations = 3;
288+
// For GTK lifetime mismatch send only once
289+
if (mismatch == GTK_LIFETIME_MISMATCH) {
290+
timer_expirations = 1;
291+
}
292+
287293
pae_supp->auth_trickle_params.Imin = pae_supp->timer_settings->gtk_request_imin;
288294
pae_supp->auth_trickle_params.Imax = pae_supp->timer_settings->gtk_request_imax;
289295
pae_supp->auth_trickle_params.k = 0;
290-
pae_supp->auth_trickle_params.TimerExpirations = 3;
296+
pae_supp->auth_trickle_params.TimerExpirations = timer_expirations;
291297

292298
// Starts trickle
293299
trickle_start(&pae_supp->auth_trickle_timer, &pae_supp->auth_trickle_params);

source/Security/protocols/sec_prot_keys.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,11 @@ void sec_prot_keys_gtks_hash_generate(sec_prot_gtk_keys_t *gtks, uint8_t *gtkhas
552552
}
553553
}
554554

555-
bool sec_prot_keys_gtks_hash_update(sec_prot_gtk_keys_t *gtks, uint8_t *gtkhash)
555+
gtk_mismatch_e sec_prot_keys_gtks_hash_update(sec_prot_gtk_keys_t *gtks, uint8_t *gtkhash)
556556
{
557557
uint8_t *gtk_hash_ptr = gtkhash;
558558

559-
bool mismatch = false;
559+
gtk_mismatch_e mismatch = GTK_NO_MISMATCH;
560560

561561
for (uint8_t i = 0; i < GTK_NUM; i++, gtk_hash_ptr += 8) {
562562
// If hash is not set, stop using the key
@@ -565,7 +565,9 @@ bool sec_prot_keys_gtks_hash_update(sec_prot_gtk_keys_t *gtks, uint8_t *gtkhash)
565565
uint32_t lifetime = sec_prot_keys_gtk_lifetime_get(gtks, i);
566566
if (lifetime > GTK_EXPIRE_MISMATCH_TIME) {
567567
tr_info("GTK mismatch %i expired time, lifetime: %"PRIu32"", i, lifetime);
568-
mismatch = true;
568+
if (mismatch < GTK_LIFETIME_MISMATCH) {
569+
mismatch = GTK_LIFETIME_MISMATCH;
570+
}
569571
}
570572
sec_prot_keys_gtk_clear(gtks, i);
571573
}
@@ -576,7 +578,9 @@ bool sec_prot_keys_gtks_hash_update(sec_prot_gtk_keys_t *gtks, uint8_t *gtkhash)
576578
if (!gtk) {
577579
// Hash set but GTK is not known, set mismatch
578580
tr_info("GTK mismatch: %i", i);
579-
mismatch = true;
581+
if (mismatch < GTK_HASH_MISMATCH) {
582+
mismatch = GTK_HASH_MISMATCH;
583+
}
580584
continue;
581585
}
582586

@@ -588,7 +592,9 @@ bool sec_prot_keys_gtks_hash_update(sec_prot_gtk_keys_t *gtks, uint8_t *gtkhash)
588592
} else {
589593
// Hash does not match, set mismatch and delete key
590594
tr_info("GTK mismatch: %i", i);
591-
mismatch = true;
595+
if (mismatch < GTK_HASH_MISMATCH) {
596+
mismatch = GTK_HASH_MISMATCH;
597+
}
592598
sec_prot_keys_gtk_clear(gtks, i);
593599
}
594600
}

source/Security/protocols/sec_prot_keys.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ typedef struct {
9191
bool ptk_mismatch: 1; /**< Remote PTK mismatch reported */
9292
} sec_prot_keys_t;
9393

94+
/*
95+
* GTK mismatch types, list is ordered according to priority of mismatch i.e. if there
96+
* are both hash and lifetime mismatch, hash has greater priority
97+
*/
98+
typedef enum {
99+
GTK_NO_MISMATCH = 0,
100+
GTK_LIFETIME_MISMATCH,
101+
GTK_HASH_MISMATCH,
102+
} gtk_mismatch_e;
103+
94104
/**
95105
* sec_prot_keys_create allocates memory for security keys
96106
*
@@ -607,10 +617,10 @@ void sec_prot_keys_gtks_hash_generate(sec_prot_gtk_keys_t *gtks, uint8_t *gtk_ha
607617
* \param gtks GTK keys
608618
* \param gtk_hash GTK hash
609619
*
610-
* \return GTK mismatch detected or or no mismatch
620+
* \return GTK mismatch type or no mismatch
611621
*
612622
*/
613-
bool sec_prot_keys_gtks_hash_update(sec_prot_gtk_keys_t *gtks, uint8_t *gtk_hash);
623+
gtk_mismatch_e sec_prot_keys_gtks_hash_update(sec_prot_gtk_keys_t *gtks, uint8_t *gtkhash);
614624

615625
/**
616626
* sec_prot_keys_gtk_hash_empty checks if GTK hash field is empty

0 commit comments

Comments
 (0)