]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
FILS: Fix hashed realm name derivation
authorJouni Malinen <j@w1.fi>
Sat, 17 Dec 2016 19:59:40 +0000 (21:59 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 17 Dec 2016 20:07:57 +0000 (22:07 +0200)
P802.11ai/D7.0 changed from CRC32 to SHA256 as the hash algorithm for
the FILS realm name. Update the implementation to match that change.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/ap/ieee802_11_shared.c
src/common/wpa_common.c
src/common/wpa_common.h

index 97b1d67ee21d4d70fa52f55814c293812c1fdf9c..d20ddc7440ac95a25d5f028f43849fbc7d971376 100644 (file)
@@ -639,10 +639,7 @@ u8 * hostapd_eid_fils_indic(struct hostapd_data *hapd, u8 *eid, int hessid)
                pos += ETH_ALEN;
        }
        if (hapd->conf->erp_domain) {
-               u16 hash;
-
-               hash = fils_domain_name_hash(hapd->conf->erp_domain);
-               WPA_PUT_LE16(pos, hash);
+               fils_domain_name_hash(hapd->conf->erp_domain, pos);
                pos += 2;
        }
        *len = pos - len - 1;
index a87210efbf577c7f973f2460da0380690d79fc9b..efc8a45f87a69f65de48dfa4f44910c861211785 100644 (file)
@@ -9,7 +9,6 @@
 #include "includes.h"
 
 #include "common.h"
-#include "utils/crc32.h"
 #include "crypto/md5.h"
 #include "crypto/sha1.h"
 #include "crypto/sha256.h"
@@ -1908,12 +1907,13 @@ int wpa_select_ap_group_cipher(int wpa, int wpa_pairwise, int rsn_pairwise)
 
 
 #ifdef CONFIG_FILS
-u16 fils_domain_name_hash(const char *domain)
+int fils_domain_name_hash(const char *domain, u8 *hash)
 {
        char buf[255], *wpos = buf;
        const char *pos = domain;
        size_t len;
-       u32 crc;
+       const u8 *addr[1];
+       u8 mac[SHA256_MAC_LEN];
 
        for (len = 0; len < sizeof(buf) && *pos; len++) {
                if (isalpha(*pos) && isupper(*pos))
@@ -1923,7 +1923,10 @@ u16 fils_domain_name_hash(const char *domain)
                pos++;
        }
 
-       crc = crc32((const u8 *) buf, len);
-       return crc & 0xffff;
+       addr[0] = (const u8 *) buf;
+       if (sha256_vector(1, addr, &len, mac) < 0)
+               return -1;
+       os_memcpy(hash, mac, 2);
+       return 0;
 }
 #endif /* CONFIG_FILS */
index 6d28417e860d462ac29939da0147b73538429e16..ce7479140f69a98bfbda11bf59d2f3f0f0a381de 100644 (file)
@@ -450,6 +450,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);
+int fils_domain_name_hash(const char *domain, u8 *hash);
 
 #endif /* WPA_COMMON_H */