ERP: Update client identity based on EAP-Initiate/Re-auth
Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
f00b9b8864
commit
a6228b8ed6
3 changed files with 40 additions and 0 deletions
|
@ -316,6 +316,7 @@ static void ieee802_1x_learn_identity(struct hostapd_data *hapd,
|
|||
hdr->code != EAP_CODE_INITIATE))
|
||||
return;
|
||||
|
||||
eap_erp_update_identity(sm->eap, eap, len);
|
||||
identity = eap_get_identity(sm->eap, &identity_len);
|
||||
if (identity == NULL)
|
||||
return;
|
||||
|
|
|
@ -153,5 +153,6 @@ void eap_server_clear_identity(struct eap_sm *sm);
|
|||
void eap_server_mschap_rx_callback(struct eap_sm *sm, const char *source,
|
||||
const u8 *username, size_t username_len,
|
||||
const u8 *challenge, const u8 *response);
|
||||
void eap_erp_update_identity(struct eap_sm *sm, const u8 *eap, size_t len);
|
||||
|
||||
#endif /* EAP_H */
|
||||
|
|
|
@ -1968,6 +1968,44 @@ const u8 * eap_get_identity(struct eap_sm *sm, size_t *len)
|
|||
}
|
||||
|
||||
|
||||
void eap_erp_update_identity(struct eap_sm *sm, const u8 *eap, size_t len)
|
||||
{
|
||||
#ifdef CONFIG_ERP
|
||||
const struct eap_hdr *hdr;
|
||||
const u8 *pos, *end;
|
||||
struct erp_tlvs parse;
|
||||
|
||||
if (len < sizeof(*hdr) + 1)
|
||||
return;
|
||||
hdr = (const struct eap_hdr *) eap;
|
||||
end = eap + len;
|
||||
pos = (const u8 *) (hdr + 1);
|
||||
if (hdr->code != EAP_CODE_INITIATE || *pos != EAP_ERP_TYPE_REAUTH)
|
||||
return;
|
||||
pos++;
|
||||
if (pos + 3 > end)
|
||||
return;
|
||||
|
||||
/* Skip Flags and SEQ */
|
||||
pos += 3;
|
||||
|
||||
if (erp_parse_tlvs(pos, end, &parse, 1) < 0 || !parse.keyname)
|
||||
return;
|
||||
wpa_hexdump_ascii(MSG_DEBUG,
|
||||
"EAP: Update identity based on EAP-Initiate/Re-auth keyName-NAI",
|
||||
parse.keyname, parse.keyname_len);
|
||||
os_free(sm->identity);
|
||||
sm->identity = os_malloc(parse.keyname_len);
|
||||
if (sm->identity) {
|
||||
os_memcpy(sm->identity, parse.keyname, parse.keyname_len);
|
||||
sm->identity_len = parse.keyname_len;
|
||||
} else {
|
||||
sm->identity_len = 0;
|
||||
}
|
||||
#endif /* CONFIG_ERP */
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* eap_get_interface - Get pointer to EAP-EAPOL interface data
|
||||
* @sm: Pointer to EAP state machine allocated with eap_server_sm_init()
|
||||
|
|
Loading…
Reference in a new issue