Skip to content

Commit 3fc1ae2

Browse files
author
Mika Leppänen
committed
BR EUI-64 is now selected for 4WH using PMKID on 4WH Message 1
When 4WH starts and PMKID is validated the BR EUI-64 used on validation can be either from previous succesful 4WH authentication with the BR (PTK EUI-64) or it can be received from EAPOL target during TLS or 4WH. In case BR EUI-64 has changed since last succesful 4WH, the PMKID is now validated against both the PTK EUI-64 and the received EUI-64. If either one matches to PMKID that is used for the 4WH negotiation.
1 parent af8438e commit 3fc1ae2

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

source/Security/protocols/fwh_sec_prot/auth_fwh_sec_prot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ static int8_t auth_fwh_sec_prot_message_send(sec_prot_t *prot, fwh_sec_prot_msg_
234234
switch (msg) {
235235
case FWH_MESSAGE_1: {
236236
uint8_t pmkid[PMKID_LEN];
237-
if (sec_prot_lib_pmkid_generate(prot, pmkid, true) < 0) {
237+
if (sec_prot_lib_pmkid_generate(prot, pmkid, true, false, NULL) < 0) {
238238
ns_dyn_mem_free(kde_start);
239239
return -1;
240240
}

source/Security/protocols/fwh_sec_prot/supp_fwh_sec_prot.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ static int8_t supp_fwh_sec_prot_ptk_generate(sec_prot_t *prot, sec_prot_keys_t *
473473
fwh_sec_prot_int_t *data = fwh_sec_prot_get(prot);
474474

475475
uint8_t local_eui64[8];
476-
prot->addr_get(prot, local_eui64, data->remote_eui64);
476+
prot->addr_get(prot, local_eui64, NULL);
477477

478478
uint8_t *remote_nonce = data->recv_eapol_pdu.msg.key.key_nonce;
479479
if (!remote_nonce) {
@@ -553,11 +553,24 @@ static int8_t supp_fwh_kde_handle(sec_prot_t *prot)
553553
if (kde_pmkid_read(kde, kde_len, recv_pmkid) < 0) {
554554
goto error;
555555
}
556-
if (sec_prot_lib_pmkid_generate(prot, calc_pmkid, false) < 0) {
556+
/* Fix the used EUI-64 for the length of the 4WH handshake using the PMKID. Try
557+
* first primary BR EUI-64 (e.g. validated by PTK procedure) for PMKID.
558+
*/
559+
if (sec_prot_lib_pmkid_generate(prot, calc_pmkid, false, false, data->remote_eui64) < 0) {
557560
goto error;
558561
}
562+
// If PMKID is not valid
559563
if (memcmp(recv_pmkid, calc_pmkid, PMKID_LEN) != 0) {
560-
goto error;
564+
tr_info("PMKID mismatch, 1st EUI-64: %s", tr_array(data->remote_eui64, 8));
565+
// Try alternate EUI-64 (e.g. received during security handshake)
566+
if (sec_prot_lib_pmkid_generate(prot, calc_pmkid, false, true, data->remote_eui64) < 0) {
567+
goto error;
568+
}
569+
// If PMKID is not valid, fail
570+
if (memcmp(recv_pmkid, calc_pmkid, PMKID_LEN) != 0) {
571+
tr_error("PMKID mismatch, 2nd EUI-64: %s", tr_array(data->remote_eui64, 8));
572+
goto error;
573+
}
561574
}
562575
}
563576
break;

source/Security/protocols/key_sec_prot/key_sec_prot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static int8_t key_sec_prot_initial_key_send(sec_prot_t *prot, sec_prot_keys_t *s
171171
uint8_t *pmk = sec_prot_keys_pmk_get(sec_keys);
172172
uint8_t pmkid[PMKID_LEN];
173173
if (pmk) {
174-
if (sec_prot_lib_pmkid_generate(prot, pmkid, false) >= 0) {
174+
if (sec_prot_lib_pmkid_generate(prot, pmkid, false, false, NULL) >= 0) {
175175
kde_len += KDE_PMKID_LEN;
176176
} else {
177177
pmk = NULL;
@@ -270,7 +270,7 @@ static int8_t key_sec_prot_receive(sec_prot_t *prot, void *pdu, uint16_t size)
270270
if (kde_pmkid_read(kde, kde_len, remote_keyid) >= 0) {
271271
tr_debug("recv PMKID: %s", trace_array(remote_keyid, 16));
272272
uint8_t pmkid[PMKID_LEN];
273-
if (sec_prot_lib_pmkid_generate(prot, pmkid, true) >= 0) {
273+
if (sec_prot_lib_pmkid_generate(prot, pmkid, true, false, NULL) >= 0) {
274274
if (memcmp(remote_keyid, pmkid, PMKID_LEN) == 0) {
275275
prot->sec_keys->pmk_mismatch = false;
276276
}

source/Security/protocols/sec_prot_lib.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ int8_t sec_prot_lib_mic_validate(uint8_t *ptk, uint8_t *mic, uint8_t *pdu, uint8
445445
return 0;
446446
}
447447

448-
int8_t sec_prot_lib_pmkid_generate(sec_prot_t *prot, uint8_t *pmkid, bool is_auth)
448+
int8_t sec_prot_lib_pmkid_generate(sec_prot_t *prot, uint8_t *pmkid, bool is_auth, bool alt_remote_eui64_use, uint8_t *used_remote_eui64)
449449
{
450450
uint8_t *pmk = sec_prot_keys_pmk_get(prot->sec_keys);
451451
if (!pmk) {
@@ -456,14 +456,22 @@ int8_t sec_prot_lib_pmkid_generate(sec_prot_t *prot, uint8_t *pmkid, bool is_aut
456456
uint8_t remote_eui64[8];
457457
// Tries to get the EUI-64 that is validated by PTK procedure or bound to supplicant entry
458458
uint8_t *remote_eui64_ptr = sec_prot_keys_ptk_eui_64_get(prot->sec_keys);
459-
if (remote_eui64_ptr) {
459+
if (remote_eui64_ptr && !alt_remote_eui64_use) {
460460
memcpy(remote_eui64, remote_eui64_ptr, 8);
461461
prot->addr_get(prot, local_eui64, NULL);
462462
} else {
463+
// If request is for alternative EUI-64, but PTK EUI-64 is not present, returns failure
464+
if (alt_remote_eui64_use && !remote_eui64_ptr) {
465+
return -1;
466+
}
463467
// If validated EUI-64 is not present, use the remote EUI-64
464468
prot->addr_get(prot, local_eui64, remote_eui64);
465469
}
466470

471+
if (used_remote_eui64 != NULL) {
472+
memcpy(used_remote_eui64, remote_eui64, 8);
473+
}
474+
467475
if (is_auth) {
468476
return sec_prot_lib_pmkid_calc(pmk, local_eui64, remote_eui64, pmkid);
469477
} else {

source/Security/protocols/sec_prot_lib.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,13 @@ int8_t sec_prot_lib_mic_validate(uint8_t *ptk, uint8_t *mic, uint8_t *pdu, uint8
162162
* \param prot security protocol
163163
* \param pmkid PMK ID
164164
* \param is_auth set for authenticator
165+
* \param alt_remote_eui64_use use alternative remote EUI-64 if available
166+
* \param used_remote_eui64 remote EUI-64 used on PMKID generation
165167
*
166168
* \return < 0 failure
167169
* \return >= 0 success
168170
*/
169-
int8_t sec_prot_lib_pmkid_generate(sec_prot_t *prot, uint8_t *pmkid, bool is_auth);
171+
int8_t sec_prot_lib_pmkid_generate(sec_prot_t *prot, uint8_t *pmkid, bool is_auth, bool alt_remote_eui64_use, uint8_t *used_remote_eui64);
170172

171173
/**
172174
* sec_prot_lib_ptkid_generate generate PTK ID from PTK

0 commit comments

Comments
 (0)