aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/wext.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-05-25 23:01:24 -0400
committerJohn W. Linville <linville@tuxdriver.com>2007-06-11 14:28:44 -0400
commit90a42210f275e1f828eb6c08bf8252c2d6a774e0 (patch)
tree7530def8af573622c4d2a3223eb8774ee76a0405 /drivers/net/wireless/libertas/wext.c
parent45f43de829981e9b9de56d6098d00d511b4fb56c (diff)
[PATCH] libertas: Make WPA work through supplicant handshake
Fix WPA so it works up through the supplicant 4-Way handshake process. Doesn't successfully pass traffic yet; may be problems installing the GTK to the firmware. - RSN needs to be enabled before the association command is sent - Use keys from the association request not the adapter structure - cmd_act_mac_strict_protection_enable != IW_AUTH_DROP_UNENCRYPTED - Fix network filtering logic in is_network_compatible() WPA helpers Signed-off-by: Dan Williams <dcbw@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/wext.c')
-rw-r--r--drivers/net/wireless/libertas/wext.c92
1 files changed, 64 insertions, 28 deletions
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index 40dd08018b49..2edc10c3327f 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -1498,6 +1498,8 @@ static void disable_wep(struct assoc_request *assoc_req)
1498{ 1498{
1499 int i; 1499 int i;
1500 1500
1501 lbs_deb_enter(LBS_DEB_WEXT);
1502
1501 /* Set Open System auth mode */ 1503 /* Set Open System auth mode */
1502 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; 1504 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1503 1505
@@ -1508,6 +1510,27 @@ static void disable_wep(struct assoc_request *assoc_req)
1508 1510
1509 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags); 1511 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1510 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags); 1512 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1513
1514 lbs_deb_leave(LBS_DEB_WEXT);
1515}
1516
1517static void disable_wpa(struct assoc_request *assoc_req)
1518{
1519 lbs_deb_enter(LBS_DEB_WEXT);
1520
1521 memset(&assoc_req->wpa_mcast_key, 0, sizeof (struct WLAN_802_11_KEY));
1522 assoc_req->wpa_mcast_key.flags = KEY_INFO_WPA_MCAST;
1523 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
1524
1525 memset(&assoc_req->wpa_unicast_key, 0, sizeof (struct WLAN_802_11_KEY));
1526 assoc_req->wpa_unicast_key.flags = KEY_INFO_WPA_UNICAST;
1527 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
1528
1529 assoc_req->secinfo.WPAenabled = 0;
1530 assoc_req->secinfo.WPA2enabled = 0;
1531 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1532
1533 lbs_deb_leave(LBS_DEB_WEXT);
1511} 1534}
1512 1535
1513/** 1536/**
@@ -1540,6 +1563,7 @@ static int wlan_set_encode(struct net_device *dev,
1540 1563
1541 if (dwrq->flags & IW_ENCODE_DISABLED) { 1564 if (dwrq->flags & IW_ENCODE_DISABLED) {
1542 disable_wep (assoc_req); 1565 disable_wep (assoc_req);
1566 disable_wpa (assoc_req);
1543 goto out; 1567 goto out;
1544 } 1568 }
1545 1569
@@ -1641,6 +1665,7 @@ static int wlan_get_encodeext(struct net_device *dev,
1641 if ( adapter->secinfo.wep_enabled 1665 if ( adapter->secinfo.wep_enabled
1642 && !adapter->secinfo.WPAenabled 1666 && !adapter->secinfo.WPAenabled
1643 && !adapter->secinfo.WPA2enabled) { 1667 && !adapter->secinfo.WPA2enabled) {
1668 /* WEP */
1644 ext->alg = IW_ENCODE_ALG_WEP; 1669 ext->alg = IW_ENCODE_ALG_WEP;
1645 ext->key_len = adapter->wep_keys[index].len; 1670 ext->key_len = adapter->wep_keys[index].len;
1646 key = &adapter->wep_keys[index].key[0]; 1671 key = &adapter->wep_keys[index].key[0];
@@ -1648,8 +1673,27 @@ static int wlan_get_encodeext(struct net_device *dev,
1648 && (adapter->secinfo.WPAenabled || 1673 && (adapter->secinfo.WPAenabled ||
1649 adapter->secinfo.WPA2enabled)) { 1674 adapter->secinfo.WPA2enabled)) {
1650 /* WPA */ 1675 /* WPA */
1651 ext->alg = IW_ENCODE_ALG_TKIP; 1676 struct WLAN_802_11_KEY * pkey = NULL;
1652 ext->key_len = 0; 1677
1678 if ( adapter->wpa_mcast_key.len
1679 && (adapter->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED))
1680 pkey = &adapter->wpa_mcast_key;
1681 else if ( adapter->wpa_unicast_key.len
1682 && (adapter->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED))
1683 pkey = &adapter->wpa_unicast_key;
1684
1685 if (pkey) {
1686 if (pkey->type == KEY_TYPE_ID_AES) {
1687 ext->alg = IW_ENCODE_ALG_CCMP;
1688 } else {
1689 ext->alg = IW_ENCODE_ALG_TKIP;
1690 }
1691 ext->key_len = pkey->len;
1692 key = &pkey->key[0];
1693 } else {
1694 ext->alg = IW_ENCODE_ALG_TKIP;
1695 ext->key_len = 0;
1696 }
1653 } else { 1697 } else {
1654 goto out; 1698 goto out;
1655 } 1699 }
@@ -1704,6 +1748,7 @@ static int wlan_set_encodeext(struct net_device *dev,
1704 1748
1705 if ((alg == IW_ENCODE_ALG_NONE) || (dwrq->flags & IW_ENCODE_DISABLED)) { 1749 if ((alg == IW_ENCODE_ALG_NONE) || (dwrq->flags & IW_ENCODE_DISABLED)) {
1706 disable_wep (assoc_req); 1750 disable_wep (assoc_req);
1751 disable_wpa (assoc_req);
1707 } else if (alg == IW_ENCODE_ALG_WEP) { 1752 } else if (alg == IW_ENCODE_ALG_WEP) {
1708 u16 is_default = 0, index, set_tx_key = 0; 1753 u16 is_default = 0, index, set_tx_key = 0;
1709 1754
@@ -1739,7 +1784,6 @@ static int wlan_set_encodeext(struct net_device *dev,
1739 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags); 1784 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1740 if (set_tx_key) 1785 if (set_tx_key)
1741 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags); 1786 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
1742
1743 } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) { 1787 } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) {
1744 struct WLAN_802_11_KEY * pkey; 1788 struct WLAN_802_11_KEY * pkey;
1745 1789
@@ -1756,28 +1800,35 @@ static int wlan_set_encodeext(struct net_device *dev,
1756 goto out; 1800 goto out;
1757 } 1801 }
1758 1802
1759 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) 1803 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
1760 pkey = &assoc_req->wpa_mcast_key; 1804 pkey = &assoc_req->wpa_mcast_key;
1761 else 1805 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
1806 } else {
1762 pkey = &assoc_req->wpa_unicast_key; 1807 pkey = &assoc_req->wpa_unicast_key;
1808 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
1809 }
1763 1810
1764 memset(pkey, 0, sizeof (struct WLAN_802_11_KEY)); 1811 memset(pkey, 0, sizeof (struct WLAN_802_11_KEY));
1765 memcpy(pkey->key, ext->key, ext->key_len); 1812 memcpy(pkey->key, ext->key, ext->key_len);
1766 pkey->len = ext->key_len; 1813 pkey->len = ext->key_len;
1767 pkey->flags = KEY_INFO_WPA_ENABLED; 1814 if (pkey->len)
1815 pkey->flags |= KEY_INFO_WPA_ENABLED;
1768 1816
1817 /* Do this after zeroing key structure */
1769 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { 1818 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
1770 pkey->flags |= KEY_INFO_WPA_MCAST; 1819 pkey->flags |= KEY_INFO_WPA_MCAST;
1771 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
1772 } else { 1820 } else {
1773 pkey->flags |= KEY_INFO_WPA_UNICAST; 1821 pkey->flags |= KEY_INFO_WPA_UNICAST;
1774 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
1775 } 1822 }
1776 1823
1777 if (alg == IW_ENCODE_ALG_TKIP) 1824 if (alg == IW_ENCODE_ALG_TKIP) {
1778 pkey->type = KEY_TYPE_ID_TKIP; 1825 pkey->type = KEY_TYPE_ID_TKIP;
1779 else if (alg == IW_ENCODE_ALG_CCMP) 1826 } else if (alg == IW_ENCODE_ALG_CCMP) {
1780 pkey->type = KEY_TYPE_ID_AES; 1827 pkey->type = KEY_TYPE_ID_AES;
1828 } else {
1829 ret = -EINVAL;
1830 goto out;
1831 }
1781 1832
1782 /* If WPA isn't enabled yet, do that now */ 1833 /* If WPA isn't enabled yet, do that now */
1783 if ( assoc_req->secinfo.WPAenabled == 0 1834 if ( assoc_req->secinfo.WPAenabled == 0
@@ -1904,6 +1955,7 @@ static int wlan_set_auth(struct net_device *dev,
1904 case IW_AUTH_CIPHER_PAIRWISE: 1955 case IW_AUTH_CIPHER_PAIRWISE:
1905 case IW_AUTH_CIPHER_GROUP: 1956 case IW_AUTH_CIPHER_GROUP:
1906 case IW_AUTH_KEY_MGMT: 1957 case IW_AUTH_KEY_MGMT:
1958 case IW_AUTH_DROP_UNENCRYPTED:
1907 /* 1959 /*
1908 * libertas does not use these parameters 1960 * libertas does not use these parameters
1909 */ 1961 */
@@ -1913,6 +1965,7 @@ static int wlan_set_auth(struct net_device *dev,
1913 if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) { 1965 if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) {
1914 assoc_req->secinfo.WPAenabled = 0; 1966 assoc_req->secinfo.WPAenabled = 0;
1915 assoc_req->secinfo.WPA2enabled = 0; 1967 assoc_req->secinfo.WPA2enabled = 0;
1968 disable_wpa (assoc_req);
1916 } 1969 }
1917 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) { 1970 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) {
1918 assoc_req->secinfo.WPAenabled = 1; 1971 assoc_req->secinfo.WPAenabled = 1;
@@ -1927,17 +1980,6 @@ static int wlan_set_auth(struct net_device *dev,
1927 updated = 1; 1980 updated = 1;
1928 break; 1981 break;
1929 1982
1930 case IW_AUTH_DROP_UNENCRYPTED:
1931 if (dwrq->value) {
1932 adapter->currentpacketfilter |=
1933 cmd_act_mac_strict_protection_enable;
1934 } else {
1935 adapter->currentpacketfilter &=
1936 ~cmd_act_mac_strict_protection_enable;
1937 }
1938 updated = 1;
1939 break;
1940
1941 case IW_AUTH_80211_AUTH_ALG: 1983 case IW_AUTH_80211_AUTH_ALG:
1942 if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) { 1984 if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) {
1943 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; 1985 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
@@ -1963,6 +2005,7 @@ static int wlan_set_auth(struct net_device *dev,
1963 } else { 2005 } else {
1964 assoc_req->secinfo.WPAenabled = 0; 2006 assoc_req->secinfo.WPAenabled = 0;
1965 assoc_req->secinfo.WPA2enabled = 0; 2007 assoc_req->secinfo.WPA2enabled = 0;
2008 disable_wpa (assoc_req);
1966 } 2009 }
1967 updated = 1; 2010 updated = 1;
1968 break; 2011 break;
@@ -2008,13 +2051,6 @@ static int wlan_get_auth(struct net_device *dev,
2008 dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED; 2051 dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED;
2009 break; 2052 break;
2010 2053
2011 case IW_AUTH_DROP_UNENCRYPTED:
2012 dwrq->value = 0;
2013 if (adapter->currentpacketfilter &
2014 cmd_act_mac_strict_protection_enable)
2015 dwrq->value = 1;
2016 break;
2017
2018 case IW_AUTH_80211_AUTH_ALG: 2054 case IW_AUTH_80211_AUTH_ALG:
2019 dwrq->value = adapter->secinfo.auth_mode; 2055 dwrq->value = adapter->secinfo.auth_mode;
2020 break; 2056 break;