]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
FILS: Parse and report received FILS HLP Containers from response
authorJouni Malinen <jouni@qca.qualcomm.com>
Tue, 31 Jan 2017 19:21:24 +0000 (21:21 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 1 Feb 2017 16:17:39 +0000 (18:17 +0200)
The new FILS-HLP-RX control interface event is now used to report
received FILS HLP responses from (Re)Association Response frame as a
response to the HLP requests configured with FILS_HLP_REQ_ADD.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/common/wpa_ctrl.h
src/rsn_supp/wpa.c
src/rsn_supp/wpa.h
src/rsn_supp/wpa_i.h
wpa_supplicant/wpas_glue.c

index 766a3fa1e7e78b6e693e5193d98b7c5e6b19b8bb..4649eab95289aeb94a7d9eaab3319cd070d49dee 100644 (file)
@@ -300,6 +300,10 @@ extern "C" {
 /* PMKSA cache entry removed; parameters: <BSSID> <network_id> */
 #define PMKSA_CACHE_REMOVED "PMKSA-CACHE-REMOVED "
 
+/* FILS HLP Container receive; parameters: dst=<addr> src=<addr> frame=<hexdump>
+ */
+#define FILS_HLP_RX "FILS-HLP-RX "
+
 /* BSS command information masks */
 
 #define WPA_BSS_MASK_ALL               0xFFFDFFFF
index 696ea04a309bf12d7aff1984c5f24bca36f056c8..88a66a51a83da331557fa35be93975eaaa9ae5ea 100644 (file)
@@ -3564,6 +3564,71 @@ struct wpabuf * fils_build_assoc_req(struct wpa_sm *sm, const u8 **kek,
 }
 
 
+static void fils_process_hlp_resp(struct wpa_sm *sm, const u8 *resp, size_t len)
+{
+       const u8 *pos, *end;
+
+       wpa_hexdump(MSG_MSGDUMP, "FILS: HLP response", resp, len);
+       if (len < 2 * ETH_ALEN)
+               return;
+       pos = resp + 2 * ETH_ALEN;
+       end = resp + len;
+       if (end - pos >= 6 &&
+           os_memcmp(pos, "\xaa\xaa\x03\x00\x00\x00", 6) == 0)
+               pos += 6; /* Remove SNAP/LLC header */
+       wpa_sm_fils_hlp_rx(sm, resp, resp + ETH_ALEN, pos, end - pos);
+}
+
+
+static void fils_process_hlp_container(struct wpa_sm *sm, const u8 *pos,
+                                      size_t len)
+{
+       const u8 *end = pos + len;
+       u8 *tmp, *tmp_pos;
+
+       /* Check if there are any FILS HLP Container elements */
+       while (end - pos >= 2) {
+               if (2 + pos[1] > end - pos)
+                       return;
+               if (pos[0] == WLAN_EID_EXTENSION &&
+                   pos[1] >= 1 + 2 * ETH_ALEN &&
+                   pos[2] == WLAN_EID_EXT_FILS_HLP_CONTAINER)
+                       break;
+               pos += 2 + pos[1];
+       }
+       if (end - pos < 2)
+               return; /* No FILS HLP Container elements */
+
+       tmp = os_malloc(end - pos);
+       if (!tmp)
+               return;
+
+       while (end - pos >= 2) {
+               if (2 + pos[1] > end - pos ||
+                   pos[0] != WLAN_EID_EXTENSION ||
+                   pos[1] < 1 + 2 * ETH_ALEN ||
+                   pos[2] != WLAN_EID_EXT_FILS_HLP_CONTAINER)
+                       break;
+               tmp_pos = tmp;
+               os_memcpy(tmp_pos, pos + 3, pos[1] - 1);
+               tmp_pos += pos[1] - 1;
+               pos += 2 + pos[1];
+
+               /* Add possible fragments */
+               while (end - pos >= 2 && pos[0] == WLAN_EID_FRAGMENT &&
+                      2 + pos[1] <= end - pos) {
+                       os_memcpy(tmp_pos, pos + 2, pos[1]);
+                       tmp_pos += pos[1];
+                       pos += 2 + pos[1];
+               }
+
+               fils_process_hlp_resp(sm, tmp, tmp_pos - tmp);
+       }
+
+       os_free(tmp);
+}
+
+
 int fils_process_assoc_resp(struct wpa_sm *sm, const u8 *resp, size_t len)
 {
        const struct ieee80211_mgmt *mgmt;
@@ -3705,7 +3770,8 @@ int fils_process_assoc_resp(struct wpa_sm *sm, const u8 *resp, size_t len)
        /* TK is not needed anymore in supplicant */
        os_memset(sm->ptk.tk, 0, WPA_TK_MAX_LEN);
 
-       /* TODO: FILS HLP Container */
+       /* FILS HLP Container */
+       fils_process_hlp_container(sm, ie_start, end - ie_start);
 
        /* TODO: FILS IP Address Assignment */
 
index f0eeec8101b8c0cb9173e38f20ab80c041764cce..bde8c78c57b6a44d6e52c2c6005bd1f1765074fa 100644 (file)
@@ -79,6 +79,8 @@ struct wpa_sm_ctx {
                                  const u8 *kck, size_t kck_len,
                                  const u8 *replay_ctr);
        int (*key_mgmt_set_pmk)(void *ctx, const u8 *pmk, size_t pmk_len);
+       void (*fils_hlp_rx)(void *ctx, const u8 *dst, const u8 *src,
+                           const u8 *pkt, size_t pkt_len);
 };
 
 
index 491fc986a995cae05502f3f30f8b350661985e0b..ab54a18f5d557183e54151c8d7be86e89208f866 100644 (file)
@@ -365,6 +365,15 @@ static inline int wpa_sm_key_mgmt_set_pmk(struct wpa_sm *sm,
        return sm->ctx->key_mgmt_set_pmk(sm->ctx->ctx, pmk, pmk_len);
 }
 
+static inline void wpa_sm_fils_hlp_rx(struct wpa_sm *sm,
+                                     const u8 *dst, const u8 *src,
+                                     const u8 *pkt, size_t pkt_len)
+{
+       if (sm->ctx->fils_hlp_rx)
+               sm->ctx->fils_hlp_rx(sm->ctx->ctx, dst, src, pkt, pkt_len);
+}
+
+
 int wpa_eapol_key_send(struct wpa_sm *sm, struct wpa_ptk *ptk,
                       int ver, const u8 *dest, u16 proto,
                       u8 *msg, size_t msg_len, u8 *key_mic);
index 16ffc7f606888181fc1ae969c4d9e2539f4e31dd..0d753a9c0f4763ad080c0dbdc2eafe41e2374fa0 100644 (file)
@@ -1090,6 +1090,7 @@ int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s)
 
 
 #ifndef CONFIG_NO_WPA
+
 static void wpa_supplicant_set_rekey_offload(void *ctx,
                                             const u8 *kek, size_t kek_len,
                                             const u8 *kck, size_t kck_len,
@@ -1113,6 +1114,25 @@ static int wpa_supplicant_key_mgmt_set_pmk(void *ctx, const u8 *pmk,
        else
                return 0;
 }
+
+
+static void wpa_supplicant_fils_hlp_rx(void *ctx, const u8 *dst, const u8 *src,
+                                      const u8 *pkt, size_t pkt_len)
+{
+       struct wpa_supplicant *wpa_s = ctx;
+       char *hex;
+       size_t hexlen;
+
+       hexlen = pkt_len * 2 + 1;
+       hex = os_malloc(hexlen);
+       if (!hex)
+               return;
+       wpa_snprintf_hex(hex, hexlen, pkt, pkt_len);
+       wpa_msg(wpa_s, MSG_INFO, FILS_HLP_RX "dst=" MACSTR " src=" MACSTR
+               " frame=%s", MAC2STR(dst), MAC2STR(src), hex);
+       os_free(hex);
+}
+
 #endif /* CONFIG_NO_WPA */
 
 
@@ -1162,6 +1182,7 @@ int wpa_supplicant_init_wpa(struct wpa_supplicant *wpa_s)
 #endif /* CONFIG_TDLS */
        ctx->set_rekey_offload = wpa_supplicant_set_rekey_offload;
        ctx->key_mgmt_set_pmk = wpa_supplicant_key_mgmt_set_pmk;
+       ctx->fils_hlp_rx = wpa_supplicant_fils_hlp_rx;
 
        wpa_s->wpa = wpa_sm_init(ctx);
        if (wpa_s->wpa == NULL) {