d6883ffce4888b5285ec41d363635cf5736bc9a7
[openwrt/svn-archive/archive.git] / package / hostapd / patches / 340-madwifi_key_fixes.patch
1 --- a/src/drivers/driver_madwifi.c
2 +++ b/src/drivers/driver_madwifi.c
3 @@ -438,9 +438,11 @@ madwifi_set_key(const char *ifname, void
4 wpa_printf(MSG_DEBUG, "%s: alg=%d addr=%s key_idx=%d",
5 __func__, alg, ether_sprintf(addr), key_idx);
6
7 - if (alg == WPA_ALG_WEP)
8 + if (alg == WPA_ALG_WEP) {
9 cipher = IEEE80211_CIPHER_WEP;
10 - else if (alg == WPA_ALG_TKIP)
11 + if (!addr || !memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN))
12 + return wpa_driver_wext_set_key(ifname, drv->wext, alg, addr, key_idx, set_tx, seq, seq_len, key, key_len);
13 + } else if (alg == WPA_ALG_TKIP)
14 cipher = IEEE80211_CIPHER_TKIP;
15 else if (alg == WPA_ALG_CCMP)
16 cipher = IEEE80211_CIPHER_AES_CCM;
17 @@ -464,15 +466,30 @@ madwifi_set_key(const char *ifname, void
18 memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
19 wk.ik_keyix = key_idx;
20 wk.ik_flags |= IEEE80211_KEY_DEFAULT;
21 + wk.ik_flags |= IEEE80211_KEY_GROUP;
22 } else if (!memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN)) {
23 + wk.ik_keyix = key_idx;
24 wk.ik_flags |= IEEE80211_KEY_GROUP;
25 - memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
26 + memset(wk.ik_macaddr, 0, IEEE80211_ADDR_LEN);
27 } else {
28 memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN);
29 wk.ik_keyix = IEEE80211_KEYIX_NONE;
30 }
31 wk.ik_keylen = key_len;
32 memcpy(wk.ik_keydata, key, key_len);
33 +#ifdef WORDS_BIGENDIAN
34 +#define WPA_KEY_RSC_LEN 8
35 + {
36 + size_t i;
37 + u8 tmp[WPA_KEY_RSC_LEN];
38 + os_memset(tmp, 0, sizeof(tmp));
39 + for (i = 0; i < seq_len; i++)
40 + tmp[WPA_KEY_RSC_LEN - i - 1] = seq[i];
41 + os_memcpy(&wk.ik_keyrsc, tmp, WPA_KEY_RSC_LEN);
42 + }
43 +#else /* WORDS_BIGENDIAN */
44 + os_memcpy(&wk.ik_keyrsc, seq, seq_len);
45 +#endif /* WORDS_BIGENDIAN */
46
47 ret = set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk));
48 if (ret < 0) {