]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
ERP: Update client identity based on EAP-Initiate/Re-auth
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 4 Sep 2015 21:04:21 +0000 (00:04 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 22 Oct 2016 20:13:17 +0000 (23:13 +0300)
Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/ap/ieee802_1x.c
src/eap_server/eap.h
src/eap_server/eap_server.c

index 80ff996948f9e3c9d93063df0cde3164abf146dd..c6d000a2d997a82c0cabe6d1af18ded3e832b3a8 100644 (file)
@@ -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;
index 69eaab8de946b4b0dfc960038974cf93978b4fc6..93eab62107caa697c9702ff727263053a988464f 100644 (file)
@@ -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 */
index 84ecafc7ca3e5db2b4e333079da523e66ccfeb37..08cc171870fbb786f39a5dba2fb6de61b67d537e 100644 (file)
@@ -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()