]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
FILS: Advertise ERP domain in FILS Indication element
authorJouni Malinen <jouni@qca.qualcomm.com>
Wed, 2 Sep 2015 13:33:42 +0000 (16:33 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 10 Oct 2016 18:11:46 +0000 (21:11 +0300)
Calculate the hashed realm from hostapd erp_domain configuration
parameter and add this to the FILS Indication element when ERP is
enabled.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/ap/ieee802_11_shared.c
src/common/wpa_common.c
src/common/wpa_common.h

index b470c6ea42e86caae0bb52667d49cc65cd5708a8..97b1d67ee21d4d70fa52f55814c293812c1fdf9c 100644 (file)
@@ -613,7 +613,11 @@ u8 * hostapd_eid_fils_indic(struct hostapd_data *hapd, u8 *eid, int hessid)
        *pos++ = WLAN_EID_FILS_INDICATION;
        len = pos++;
        /* TODO: B0..B2: Number of Public Key Identifiers */
-       /* TODO: B3..B5: Number of Realm Identifiers */
+       if (hapd->conf->erp_domain) {
+               /* TODO: Support for setting multiple domain identifiers */
+               /* B3..B5: Number of Realm Identifiers */
+               fils_info |= BIT(3);
+       }
        /* TODO: B6: FILS IP Address Configuration */
        if (hapd->conf->fils_cache_id_set)
                fils_info |= BIT(7);
@@ -634,6 +638,13 @@ u8 * hostapd_eid_fils_indic(struct hostapd_data *hapd, u8 *eid, int hessid)
                os_memcpy(pos, hapd->conf->hessid, ETH_ALEN);
                pos += ETH_ALEN;
        }
+       if (hapd->conf->erp_domain) {
+               u16 hash;
+
+               hash = fils_domain_name_hash(hapd->conf->erp_domain);
+               WPA_PUT_LE16(pos, hash);
+               pos += 2;
+       }
        *len = pos - len - 1;
 #endif /* CONFIG_FILS */
 
index 9a7bc7502fc8187e388cd7d49b81dd9c31483688..e909c3375c51fa619cbdbfc9fc5f953f757ef44f 100644 (file)
@@ -9,6 +9,7 @@
 #include "includes.h"
 
 #include "common.h"
+#include "utils/crc32.h"
 #include "crypto/md5.h"
 #include "crypto/sha1.h"
 #include "crypto/sha256.h"
@@ -1755,3 +1756,25 @@ int wpa_select_ap_group_cipher(int wpa, int wpa_pairwise, int rsn_pairwise)
                return WPA_CIPHER_CCMP_256;
        return WPA_CIPHER_CCMP;
 }
+
+
+#ifdef CONFIG_FILS
+u16 fils_domain_name_hash(const char *domain)
+{
+       char buf[255], *wpos = buf;
+       const char *pos = domain;
+       size_t len;
+       u32 crc;
+
+       for (len = 0; len < sizeof(buf) && *pos; len++) {
+               if (isalpha(*pos) && isupper(*pos))
+                       *wpos++ = tolower(*pos);
+               else
+                       *wpos++ = *pos;
+               pos++;
+       }
+
+       crc = crc32((const u8 *) buf, len);
+       return crc & 0xffff;
+}
+#endif /* CONFIG_FILS */
index 25be93918fc197e4e8da8385e27b1c6d48ea9e47..ea8f7590ab830a35371477509f7f843f1e8afff0 100644 (file)
@@ -455,5 +455,6 @@ int wpa_parse_cipher(const char *value);
 int wpa_write_ciphers(char *start, char *end, int ciphers, const char *delim);
 int wpa_select_ap_group_cipher(int wpa, int wpa_pairwise, int rsn_pairwise);
 unsigned int wpa_mic_len(int akmp);
+u16 fils_domain_name_hash(const char *domain);
 
 #endif /* WPA_COMMON_H */