hostapd: update to 20120326
[openwrt/svn-archive/archive.git] / package / hostapd / patches / 320-madwifi_key_fixes.patch
1 --- a/src/drivers/driver_madwifi.c
2 +++ b/src/drivers/driver_madwifi.c
3 @@ -439,8 +439,14 @@ wpa_driver_madwifi_set_key(const char *i
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 + if ((!addr || !memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN)) &&
11 + drv->wext)
12 + return wpa_driver_wext_set_key(ifname, drv->wext, alg, addr,
13 + key_idx, set_tx, seq, seq_len,
14 + key, key_len);
15 + }
16 else if (alg == WPA_ALG_TKIP)
17 cipher = IEEE80211_CIPHER_TKIP;
18 else if (alg == WPA_ALG_CCMP)
19 @@ -459,7 +465,9 @@ wpa_driver_madwifi_set_key(const char *i
20
21 memset(&wk, 0, sizeof(wk));
22 wk.ik_type = cipher;
23 - wk.ik_flags = IEEE80211_KEY_RECV | IEEE80211_KEY_XMIT;
24 + wk.ik_flags = IEEE80211_KEY_RECV;
25 + if (set_tx)
26 + wk.ik_flags |= IEEE80211_KEY_XMIT;
27 if (addr == NULL || is_broadcast_ether_addr(addr)) {
28 memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN);
29 wk.ik_keyix = key_idx;
30 @@ -471,6 +479,20 @@ wpa_driver_madwifi_set_key(const char *i
31 wk.ik_keylen = key_len;
32 memcpy(wk.ik_keydata, key, key_len);
33
34 +#ifdef WORDS_BIGENDIAN
35 +#define WPA_KEY_RSC_LEN 8
36 + {
37 + size_t i;
38 + u8 tmp[WPA_KEY_RSC_LEN];
39 + os_memset(tmp, 0, sizeof(tmp));
40 + for (i = 0; i < seq_len; i++)
41 + tmp[WPA_KEY_RSC_LEN - i - 1] = seq[i];
42 + os_memcpy(&wk.ik_keyrsc, tmp, WPA_KEY_RSC_LEN);
43 + }
44 +#else /* WORDS_BIGENDIAN */
45 + os_memcpy(&wk.ik_keyrsc, seq, seq_len);
46 +#endif /* WORDS_BIGENDIAN */
47 +
48 ret = set80211priv(drv, IEEE80211_IOCTL_SETKEY, &wk, sizeof(wk));
49 if (ret < 0) {
50 wpa_printf(MSG_DEBUG, "%s: Failed to set key (addr %s"