aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2013-12-30 17:33:39 (GMT)
committerJouni Malinen <j@w1.fi>2013-12-31 07:16:27 (GMT)
commit4848a38d85bcfdc84a94143fe4437ac588f7e107 (patch)
treec21083d9cca4ca8681efd2f06a3f4c6fe6182004 /src
parentde4ed4a89b1fedadddbe96af9ec83f5eaeb11991 (diff)
downloadhostap-4848a38d85bcfdc84a94143fe4437ac588f7e107.zip
hostap-4848a38d85bcfdc84a94143fe4437ac588f7e107.tar.gz
hostap-4848a38d85bcfdc84a94143fe4437ac588f7e107.tar.bz2
Get rid of duplicated cipher suite and AKM definitions
WPA_CIPHER_* and CIPHER_* are used for the exact same set of cipher suites with the main difference being that the WPA_CIPHER_* version is suitable to be used as a bitfield. Similarly, WPA_KEY_MGMT_* and KEY_MGMT_* have similar design for AKMs. There is no need to maintain two separate copies of the definitions since the bitfield compatible version can be used for both needs. Get rid of the CIPHER_* and KEY_MGMT_* versions to clean up the implementation by getting rid of unnecessary mapping functions. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'src')
-rw-r--r--src/common/defs.h36
-rw-r--r--src/common/wpa_common.c24
-rw-r--r--src/common/wpa_common.h1
-rw-r--r--src/drivers/driver.h12
-rw-r--r--src/drivers/driver_bsd.c6
-rw-r--r--src/drivers/driver_ndis.c26
-rw-r--r--src/drivers/driver_nl80211.c71
-rw-r--r--src/drivers/driver_wext.c26
8 files changed, 57 insertions, 145 deletions
diff --git a/src/common/defs.h b/src/common/defs.h
index c995631..d776f83 100644
--- a/src/common/defs.h
+++ b/src/common/defs.h
@@ -134,42 +134,6 @@ enum wpa_alg {
};
/**
- * enum wpa_cipher - Cipher suites
- */
-enum wpa_cipher {
- CIPHER_NONE,
- CIPHER_WEP40,
- CIPHER_TKIP,
- CIPHER_CCMP,
- CIPHER_WEP104,
- CIPHER_GCMP,
- CIPHER_SMS4,
- CIPHER_GCMP_256,
- CIPHER_CCMP_256
-};
-
-/**
- * enum wpa_key_mgmt - Key management suites
- */
-enum wpa_key_mgmt {
- KEY_MGMT_802_1X,
- KEY_MGMT_PSK,
- KEY_MGMT_NONE,
- KEY_MGMT_802_1X_NO_WPA,
- KEY_MGMT_WPA_NONE,
- KEY_MGMT_FT_802_1X,
- KEY_MGMT_FT_PSK,
- KEY_MGMT_802_1X_SHA256,
- KEY_MGMT_PSK_SHA256,
- KEY_MGMT_WPS,
- KEY_MGMT_SAE,
- KEY_MGMT_FT_SAE,
- KEY_MGMT_WAPI_PSK,
- KEY_MGMT_WAPI_CERT,
- KEY_MGMT_CCKM
-};
-
-/**
* enum wpa_states - wpa_supplicant state
*
* These enumeration values are used to indicate the current wpa_supplicant
diff --git a/src/common/wpa_common.c b/src/common/wpa_common.c
index 4f9ef82..37b265d 100644
--- a/src/common/wpa_common.c
+++ b/src/common/wpa_common.c
@@ -1151,30 +1151,6 @@ int wpa_cipher_to_alg(int cipher)
}
-enum wpa_cipher wpa_cipher_to_suite_driver(int cipher)
-{
- switch (cipher) {
- case WPA_CIPHER_NONE:
- return CIPHER_NONE;
- case WPA_CIPHER_WEP40:
- return CIPHER_WEP40;
- case WPA_CIPHER_WEP104:
- return CIPHER_WEP104;
- case WPA_CIPHER_CCMP:
- return CIPHER_CCMP;
- case WPA_CIPHER_GCMP:
- return CIPHER_GCMP;
- case WPA_CIPHER_CCMP_256:
- return CIPHER_CCMP_256;
- case WPA_CIPHER_GCMP_256:
- return CIPHER_GCMP_256;
- case WPA_CIPHER_TKIP:
- default:
- return CIPHER_TKIP;
- }
-}
-
-
int wpa_cipher_valid_pairwise(int cipher)
{
return cipher == WPA_CIPHER_CCMP_256 ||
diff --git a/src/common/wpa_common.h b/src/common/wpa_common.h
index d3f61a2..62505f1 100644
--- a/src/common/wpa_common.h
+++ b/src/common/wpa_common.h
@@ -403,7 +403,6 @@ int wpa_ft_parse_ies(const u8 *ies, size_t ies_len, struct wpa_ft_ies *parse);
int wpa_cipher_key_len(int cipher);
int wpa_cipher_rsc_len(int cipher);
int wpa_cipher_to_alg(int cipher);
-enum wpa_cipher wpa_cipher_to_suite_driver(int cipher);
int wpa_cipher_valid_pairwise(int cipher);
u32 wpa_cipher_to_suite(int proto, int cipher);
int rsn_cipher_put_suites(u8 *pos, int ciphers);
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index f8623d3..eecb736 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -442,25 +442,25 @@ struct wpa_driver_associate_params {
unsigned int wpa_proto;
/**
- * pairwise_suite - Selected pairwise cipher suite
+ * pairwise_suite - Selected pairwise cipher suite (WPA_CIPHER_*)
*
* This is usually ignored if @wpa_ie is used.
*/
- enum wpa_cipher pairwise_suite;
+ unsigned int pairwise_suite;
/**
- * group_suite - Selected group cipher suite
+ * group_suite - Selected group cipher suite (WPA_CIPHER_*)
*
* This is usually ignored if @wpa_ie is used.
*/
- enum wpa_cipher group_suite;
+ unsigned int group_suite;
/**
- * key_mgmt_suite - Selected key management suite
+ * key_mgmt_suite - Selected key management suite (WPA_KEY_MGMT_*)
*
* This is usually ignored if @wpa_ie is used.
*/
- enum wpa_key_mgmt key_mgmt_suite;
+ unsigned int key_mgmt_suite;
/**
* auth_alg - Allowed authentication algorithms
diff --git a/src/drivers/driver_bsd.c b/src/drivers/driver_bsd.c
index fb6402d..7f5e231 100644
--- a/src/drivers/driver_bsd.c
+++ b/src/drivers/driver_bsd.c
@@ -1110,9 +1110,9 @@ wpa_driver_bsd_associate(void *priv, struct wpa_driver_associate_params *params)
if (wpa_driver_bsd_set_wpa_ie(drv, params->wpa_ie, params->wpa_ie_len) < 0)
return -1;
- privacy = !(params->pairwise_suite == CIPHER_NONE &&
- params->group_suite == CIPHER_NONE &&
- params->key_mgmt_suite == KEY_MGMT_NONE &&
+ privacy = !(params->pairwise_suite == WPA_CIPHER_NONE &&
+ params->group_suite == WPA_CIPHER_NONE &&
+ params->key_mgmt_suite == WPA_KEY_MGMT_NONE &&
params->wpa_ie_len == 0);
wpa_printf(MSG_DEBUG, "%s: set PRIVACY %u", __func__, privacy);
diff --git a/src/drivers/driver_ndis.c b/src/drivers/driver_ndis.c
index 4656c1b..4953af6 100644
--- a/src/drivers/driver_ndis.c
+++ b/src/drivers/driver_ndis.c
@@ -1074,8 +1074,8 @@ wpa_driver_ndis_associate(void *priv,
/* Try to continue anyway */
}
- if (params->key_mgmt_suite == KEY_MGMT_NONE ||
- params->key_mgmt_suite == KEY_MGMT_802_1X_NO_WPA) {
+ if (params->key_mgmt_suite == WPA_KEY_MGMT_NONE ||
+ params->key_mgmt_suite == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
/* Re-set WEP keys if static WEP configuration is used. */
int i;
for (i = 0; i < 4; i++) {
@@ -1102,12 +1102,12 @@ wpa_driver_ndis_associate(void *priv,
priv_mode = Ndis802_11PrivFilterAcceptAll;
} else if (params->wpa_ie[0] == WLAN_EID_RSN) {
priv_mode = Ndis802_11PrivFilter8021xWEP;
- if (params->key_mgmt_suite == KEY_MGMT_PSK)
+ if (params->key_mgmt_suite == WPA_KEY_MGMT_PSK)
auth_mode = Ndis802_11AuthModeWPA2PSK;
else
auth_mode = Ndis802_11AuthModeWPA2;
#ifdef CONFIG_WPS
- } else if (params->key_mgmt_suite == KEY_MGMT_WPS) {
+ } else if (params->key_mgmt_suite == WPA_KEY_MGMT_WPS) {
auth_mode = Ndis802_11AuthModeOpen;
priv_mode = Ndis802_11PrivFilterAcceptAll;
if (params->wps == WPS_MODE_PRIVACY) {
@@ -1129,35 +1129,35 @@ wpa_driver_ndis_associate(void *priv,
#endif /* CONFIG_WPS */
} else {
priv_mode = Ndis802_11PrivFilter8021xWEP;
- if (params->key_mgmt_suite == KEY_MGMT_WPA_NONE)
+ if (params->key_mgmt_suite == WPA_KEY_MGMT_WPA_NONE)
auth_mode = Ndis802_11AuthModeWPANone;
- else if (params->key_mgmt_suite == KEY_MGMT_PSK)
+ else if (params->key_mgmt_suite == WPA_KEY_MGMT_PSK)
auth_mode = Ndis802_11AuthModeWPAPSK;
else
auth_mode = Ndis802_11AuthModeWPA;
}
switch (params->pairwise_suite) {
- case CIPHER_CCMP:
+ case WPA_CIPHER_CCMP:
encr = Ndis802_11Encryption3Enabled;
break;
- case CIPHER_TKIP:
+ case WPA_CIPHER_TKIP:
encr = Ndis802_11Encryption2Enabled;
break;
- case CIPHER_WEP40:
- case CIPHER_WEP104:
+ case WPA_CIPHER_WEP40:
+ case WPA_CIPHER_WEP104:
encr = Ndis802_11Encryption1Enabled;
break;
- case CIPHER_NONE:
+ case WPA_CIPHER_NONE:
#ifdef CONFIG_WPS
if (params->wps == WPS_MODE_PRIVACY) {
encr = Ndis802_11Encryption1Enabled;
break;
}
#endif /* CONFIG_WPS */
- if (params->group_suite == CIPHER_CCMP)
+ if (params->group_suite == WPA_CIPHER_CCMP)
encr = Ndis802_11Encryption3Enabled;
- else if (params->group_suite == CIPHER_TKIP)
+ else if (params->group_suite == WPA_CIPHER_TKIP)
encr = Ndis802_11Encryption2Enabled;
else
encr = Ndis802_11EncryptionDisabled;
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 2eed9f8..7c865ea 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -5270,33 +5270,6 @@ static int wpa_cipher_to_cipher_suites(unsigned int ciphers, u32 suites[],
}
-static u32 cipher_to_cipher_suite(enum wpa_cipher cipher)
-{
- switch (cipher) {
- case CIPHER_SMS4:
- return WLAN_CIPHER_SUITE_SMS4;
- case CIPHER_WEP40:
- return WLAN_CIPHER_SUITE_WEP40;
- case CIPHER_WEP104:
- return WLAN_CIPHER_SUITE_WEP104;
- case CIPHER_CCMP:
- return WLAN_CIPHER_SUITE_CCMP;
- case CIPHER_GCMP:
- return WLAN_CIPHER_SUITE_GCMP;
- case CIPHER_CCMP_256:
- return WLAN_CIPHER_SUITE_CCMP_256;
- case CIPHER_GCMP_256:
- return WLAN_CIPHER_SUITE_GCMP_256;
- case CIPHER_TKIP:
- return WLAN_CIPHER_SUITE_TKIP;
- case CIPHER_NONE:
- return 0;
- }
-
- return 0;
-}
-
-
static int wpa_driver_nl80211_set_key(const char *ifname, struct i802_bss *bss,
enum wpa_alg alg, const u8 *addr,
int key_idx, int set_tx,
@@ -8053,10 +8026,10 @@ retry:
NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, params->bssid);
}
- if (params->key_mgmt_suite == KEY_MGMT_802_1X ||
- params->key_mgmt_suite == KEY_MGMT_PSK ||
- params->key_mgmt_suite == KEY_MGMT_802_1X_SHA256 ||
- params->key_mgmt_suite == KEY_MGMT_PSK_SHA256) {
+ if (params->key_mgmt_suite == WPA_KEY_MGMT_IEEE8021X ||
+ params->key_mgmt_suite == WPA_KEY_MGMT_PSK ||
+ params->key_mgmt_suite == WPA_KEY_MGMT_IEEE8021X_SHA256 ||
+ params->key_mgmt_suite == WPA_KEY_MGMT_PSK_SHA256) {
wpa_printf(MSG_DEBUG, " * control port");
NLA_PUT_FLAG(msg, NL80211_ATTR_CONTROL_PORT);
}
@@ -8183,37 +8156,37 @@ skip_auth_type:
NLA_PUT_U32(msg, NL80211_ATTR_WPA_VERSIONS, ver);
}
- if (params->pairwise_suite != CIPHER_NONE) {
+ if (params->pairwise_suite != WPA_CIPHER_NONE) {
NLA_PUT_U32(msg, NL80211_ATTR_CIPHER_SUITES_PAIRWISE,
- cipher_to_cipher_suite(params->pairwise_suite));
+ wpa_cipher_to_cipher_suite(params->pairwise_suite));
}
- if (params->group_suite != CIPHER_NONE) {
+ if (params->group_suite != WPA_CIPHER_NONE) {
NLA_PUT_U32(msg, NL80211_ATTR_CIPHER_SUITE_GROUP,
- cipher_to_cipher_suite(params->group_suite));
+ wpa_cipher_to_cipher_suite(params->group_suite));
}
- if (params->key_mgmt_suite == KEY_MGMT_802_1X ||
- params->key_mgmt_suite == KEY_MGMT_PSK ||
- params->key_mgmt_suite == KEY_MGMT_FT_802_1X ||
- params->key_mgmt_suite == KEY_MGMT_FT_PSK ||
- params->key_mgmt_suite == KEY_MGMT_CCKM) {
+ if (params->key_mgmt_suite == WPA_KEY_MGMT_IEEE8021X ||
+ params->key_mgmt_suite == WPA_KEY_MGMT_PSK ||
+ params->key_mgmt_suite == WPA_KEY_MGMT_FT_IEEE8021X ||
+ params->key_mgmt_suite == WPA_KEY_MGMT_FT_PSK ||
+ params->key_mgmt_suite == WPA_KEY_MGMT_CCKM) {
int mgmt = WLAN_AKM_SUITE_PSK;
switch (params->key_mgmt_suite) {
- case KEY_MGMT_CCKM:
+ case WPA_KEY_MGMT_CCKM:
mgmt = WLAN_AKM_SUITE_CCKM;
break;
- case KEY_MGMT_802_1X:
+ case WPA_KEY_MGMT_IEEE8021X:
mgmt = WLAN_AKM_SUITE_8021X;
break;
- case KEY_MGMT_FT_802_1X:
+ case WPA_KEY_MGMT_FT_IEEE8021X:
mgmt = WLAN_AKM_SUITE_FT_8021X;
break;
- case KEY_MGMT_FT_PSK:
+ case WPA_KEY_MGMT_FT_PSK:
mgmt = WLAN_AKM_SUITE_FT_PSK;
break;
- case KEY_MGMT_PSK:
+ case WPA_KEY_MGMT_PSK:
default:
mgmt = WLAN_AKM_SUITE_PSK;
break;
@@ -8362,14 +8335,14 @@ static int wpa_driver_nl80211_associate(
NLA_PUT(msg, NL80211_ATTR_IE, params->wpa_ie_len,
params->wpa_ie);
- if (params->pairwise_suite != CIPHER_NONE) {
- u32 cipher = cipher_to_cipher_suite(params->pairwise_suite);
+ if (params->pairwise_suite != WPA_CIPHER_NONE) {
+ u32 cipher = wpa_cipher_to_cipher_suite(params->pairwise_suite);
wpa_printf(MSG_DEBUG, " * pairwise=0x%x", cipher);
NLA_PUT_U32(msg, NL80211_ATTR_CIPHER_SUITES_PAIRWISE, cipher);
}
- if (params->group_suite != CIPHER_NONE) {
- u32 cipher = cipher_to_cipher_suite(params->group_suite);
+ if (params->group_suite != WPA_CIPHER_NONE) {
+ u32 cipher = wpa_cipher_to_cipher_suite(params->group_suite);
wpa_printf(MSG_DEBUG, " * group=0x%x", cipher);
NLA_PUT_U32(msg, NL80211_ATTR_CIPHER_SUITE_GROUP, cipher);
}
diff --git a/src/drivers/driver_wext.c b/src/drivers/driver_wext.c
index 6803582..e5734bd 100644
--- a/src/drivers/driver_wext.c
+++ b/src/drivers/driver_wext.c
@@ -1938,15 +1938,15 @@ static int wpa_driver_wext_set_gen_ie(void *priv, const u8 *ie,
int wpa_driver_wext_cipher2wext(int cipher)
{
switch (cipher) {
- case CIPHER_NONE:
+ case WPA_CIPHER_NONE:
return IW_AUTH_CIPHER_NONE;
- case CIPHER_WEP40:
+ case WPA_CIPHER_WEP40:
return IW_AUTH_CIPHER_WEP40;
- case CIPHER_TKIP:
+ case WPA_CIPHER_TKIP:
return IW_AUTH_CIPHER_TKIP;
- case CIPHER_CCMP:
+ case WPA_CIPHER_CCMP:
return IW_AUTH_CIPHER_CCMP;
- case CIPHER_WEP104:
+ case WPA_CIPHER_WEP104:
return IW_AUTH_CIPHER_WEP104;
default:
return 0;
@@ -1957,10 +1957,10 @@ int wpa_driver_wext_cipher2wext(int cipher)
int wpa_driver_wext_keymgmt2wext(int keymgmt)
{
switch (keymgmt) {
- case KEY_MGMT_802_1X:
- case KEY_MGMT_802_1X_NO_WPA:
+ case WPA_KEY_MGMT_IEEE8021X:
+ case WPA_KEY_MGMT_IEEE8021X_NO_WPA:
return IW_AUTH_KEY_MGMT_802_1X;
- case KEY_MGMT_PSK:
+ case WPA_KEY_MGMT_PSK:
return IW_AUTH_KEY_MGMT_PSK;
default:
return 0;
@@ -2077,9 +2077,9 @@ int wpa_driver_wext_associate(void *priv,
if (wpa_driver_wext_set_auth_param(drv,
IW_AUTH_KEY_MGMT, value) < 0)
ret = -1;
- value = params->key_mgmt_suite != KEY_MGMT_NONE ||
- params->pairwise_suite != CIPHER_NONE ||
- params->group_suite != CIPHER_NONE ||
+ value = params->key_mgmt_suite != WPA_KEY_MGMT_NONE ||
+ params->pairwise_suite != WPA_CIPHER_NONE ||
+ params->group_suite != WPA_CIPHER_NONE ||
params->wpa_ie_len;
if (wpa_driver_wext_set_auth_param(drv,
IW_AUTH_PRIVACY_INVOKED, value) < 0)
@@ -2088,8 +2088,8 @@ int wpa_driver_wext_associate(void *priv,
/* Allow unencrypted EAPOL messages even if pairwise keys are set when
* not using WPA. IEEE 802.1X specifies that these frames are not
* encrypted, but WPA encrypts them when pairwise keys are in use. */
- if (params->key_mgmt_suite == KEY_MGMT_802_1X ||
- params->key_mgmt_suite == KEY_MGMT_PSK)
+ if (params->key_mgmt_suite == WPA_KEY_MGMT_IEEE8021X ||
+ params->key_mgmt_suite == WPA_KEY_MGMT_PSK)
allow_unencrypted_eapol = 0;
else
allow_unencrypted_eapol = 1;