]> nv-tegra.nvidia Code Review - linux-2.6.git/commitdiff
mac80211: use cipher suite selectors
authorJohannes Berg <johannes.berg@intel.com>
Tue, 10 Aug 2010 07:46:38 +0000 (09:46 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 16 Aug 2010 20:45:11 +0000 (16:45 -0400)
Currently, mac80211 translates the cfg80211
cipher suite selectors into ALG_* values.
That isn't all too useful, and some drivers
benefit from the distinction between WEP40
and WEP104 as well. Therefore, convert it
all to use the cipher suite selectors.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
31 files changed:
drivers/net/wireless/at76c50x-usb.c
drivers/net/wireless/ath/ar9170/main.c
drivers/net/wireless/ath/ath5k/base.c
drivers/net/wireless/ath/ath5k/pcu.c
drivers/net/wireless/ath/ath9k/common.c
drivers/net/wireless/ath/ath9k/htc_drv_main.c
drivers/net/wireless/ath/ath9k/main.c
drivers/net/wireless/b43/main.c
drivers/net/wireless/iwlwifi/iwl-agn-tx.c
drivers/net/wireless/iwlwifi/iwl-agn.c
drivers/net/wireless/iwlwifi/iwl-dev.h
drivers/net/wireless/iwlwifi/iwl-sta.c
drivers/net/wireless/iwlwifi/iwl3945-base.c
drivers/net/wireless/p54/main.c
drivers/net/wireless/p54/txrx.c
drivers/net/wireless/rt2x00/rt2500usb.c
drivers/net/wireless/rt2x00/rt2x00crypto.c
drivers/net/wireless/wl12xx/wl1251_main.c
drivers/net/wireless/wl12xx/wl1251_tx.c
drivers/net/wireless/wl12xx/wl1271_main.c
drivers/net/wireless/wl12xx/wl1271_tx.c
include/net/mac80211.h
net/mac80211/cfg.c
net/mac80211/debugfs_key.c
net/mac80211/driver-trace.h
net/mac80211/key.c
net/mac80211/key.h
net/mac80211/rx.c
net/mac80211/tx.c
net/mac80211/wep.c
net/mac80211/wpa.c

index d5140a87f0737d92adde6ce9bb725d679be16538..a267bf55574ce74ef5bc9d23d6a6f3d8e9d9ed75 100644 (file)
@@ -2061,11 +2061,12 @@ static int at76_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 
        int i;
 
-       at76_dbg(DBG_MAC80211, "%s(): cmd %d key->alg %d key->keyidx %d "
+       at76_dbg(DBG_MAC80211, "%s(): cmd %d key->cipher %d key->keyidx %d "
                 "key->keylen %d",
-                __func__, cmd, key->alg, key->keyidx, key->keylen);
+                __func__, cmd, key->cipher, key->keyidx, key->keylen);
 
-       if (key->alg != ALG_WEP)
+       if ((key->cipher != WLAN_CIPHER_SUITE_WEP40) &&
+           (key->cipher != WLAN_CIPHER_SUITE_WEP104))
                return -EOPNOTSUPP;
 
        key->hw_key_idx = key->keyidx;
index c67b05f3bcbdcace54e806ccdf69de5793766d0c..29d2253ad7e492ad2f3911d5077d709306e5824d 100644 (file)
@@ -1190,14 +1190,13 @@ static int ar9170_tx_prepare(struct ar9170 *ar, struct sk_buff *skb)
        if (info->control.hw_key) {
                icv = info->control.hw_key->icv_len;
 
-               switch (info->control.hw_key->alg) {
-               case ALG_WEP:
+               switch (info->control.hw_key->cipher) {
+               case WLAN_CIPHER_SUITE_WEP40:
+               case WLAN_CIPHER_SUITE_WEP104:
+               case WLAN_CIPHER_SUITE_TKIP:
                        keytype = AR9170_TX_MAC_ENCR_RC4;
                        break;
-               case ALG_TKIP:
-                       keytype = AR9170_TX_MAC_ENCR_RC4;
-                       break;
-               case ALG_CCMP:
+               case WLAN_CIPHER_SUITE_CCMP:
                        keytype = AR9170_TX_MAC_ENCR_AES;
                        break;
                default:
@@ -1778,17 +1777,17 @@ static int ar9170_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
        if ((!ar->vif) || (ar->disable_offload))
                return -EOPNOTSUPP;
 
-       switch (key->alg) {
-       case ALG_WEP:
-               if (key->keylen == WLAN_KEY_LEN_WEP40)
-                       ktype = AR9170_ENC_ALG_WEP64;
-               else
-                       ktype = AR9170_ENC_ALG_WEP128;
+       switch (key->cipher) {
+       case WLAN_CIPHER_SUITE_WEP40:
+               ktype = AR9170_ENC_ALG_WEP64;
+               break;
+       case WLAN_CIPHER_SUITE_WEP104:
+               ktype = AR9170_ENC_ALG_WEP128;
                break;
-       case ALG_TKIP:
+       case WLAN_CIPHER_SUITE_TKIP:
                ktype = AR9170_ENC_ALG_TKIP;
                break;
-       case ALG_CCMP:
+       case WLAN_CIPHER_SUITE_CCMP:
                ktype = AR9170_ENC_ALG_AESCCMP;
                break;
        default:
@@ -1827,7 +1826,7 @@ static int ar9170_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
                if (err)
                        goto out;
 
-               if (key->alg == ALG_TKIP) {
+               if (key->cipher == WLAN_CIPHER_SUITE_TKIP) {
                        err = ar9170_upload_key(ar, i, sta ? sta->addr : NULL,
                                                ktype, 1, key->key + 16, 16);
                        if (err)
@@ -1864,7 +1863,7 @@ static int ar9170_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
                        if (err)
                                goto out;
 
-                       if (key->alg == ALG_TKIP) {
+                       if (key->cipher == WLAN_CIPHER_SUITE_TKIP) {
                                err = ar9170_upload_key(ar, key->hw_key_idx,
                                                        NULL,
                                                        AR9170_ENC_ALG_NONE, 1,
index 373dcfec689c40c2bf1be9af2b9bddb7a15dcacb..a729b877467094481a71247f9c424b4980f61fcd 100644 (file)
@@ -3297,11 +3297,12 @@ ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
        if (sc->opmode == NL80211_IFTYPE_AP)
                return -EOPNOTSUPP;
 
-       switch (key->alg) {
-       case ALG_WEP:
-       case ALG_TKIP:
+       switch (key->cipher) {
+       case WLAN_CIPHER_SUITE_WEP40:
+       case WLAN_CIPHER_SUITE_WEP104:
+       case WLAN_CIPHER_SUITE_TKIP:
                break;
-       case ALG_CCMP:
+       case WLAN_CIPHER_SUITE_CCMP:
                if (sc->ah->ah_aes_support)
                        break;
 
index 86fdb6ddfaaa52d0abba9116c989438c0b44f851..af273358c7cbaf0cc3220c10a5a655b01f86fc92 100644 (file)
@@ -695,21 +695,18 @@ int ath5k_hw_reset_key(struct ath5k_hw *ah, u16 entry)
 static
 int ath5k_keycache_type(const struct ieee80211_key_conf *key)
 {
-       switch (key->alg) {
-       case ALG_TKIP:
+       switch (key->cipher) {
+       case WLAN_CIPHER_SUITE_TKIP:
                return AR5K_KEYTABLE_TYPE_TKIP;
-       case ALG_CCMP:
+       case WLAN_CIPHER_SUITE_CCMP:
                return AR5K_KEYTABLE_TYPE_CCM;
-       case ALG_WEP:
-               if (key->keylen == WLAN_KEY_LEN_WEP40)
-                       return AR5K_KEYTABLE_TYPE_40;
-               else if (key->keylen == WLAN_KEY_LEN_WEP104)
-                       return AR5K_KEYTABLE_TYPE_104;
-               return -EINVAL;
+       case WLAN_CIPHER_SUITE_WEP40:
+               return AR5K_KEYTABLE_TYPE_40;
+       case WLAN_CIPHER_SUITE_WEP104:
+               return AR5K_KEYTABLE_TYPE_104;
        default:
                return -EINVAL;
        }
-       return -EINVAL;
 }
 
 /*
@@ -728,7 +725,7 @@ int ath5k_hw_set_key(struct ath5k_hw *ah, u16 entry,
        bool is_tkip;
        const u8 *key_ptr;
 
-       is_tkip = (key->alg == ALG_TKIP);
+       is_tkip = (key->cipher == WLAN_CIPHER_SUITE_TKIP);
 
        /*
         * key->keylen comes in from mac80211 in bytes.
index c86f7d3593ab48a3c1c1248443f0f2f599a327f8..3100c87a4fcdfd72d9ace7690ef61b32429f5adf 100644 (file)
@@ -46,12 +46,17 @@ int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb)
        struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
 
        if (tx_info->control.hw_key) {
-               if (tx_info->control.hw_key->alg == ALG_WEP)
+               switch (tx_info->control.hw_key->cipher) {
+               case WLAN_CIPHER_SUITE_WEP40:
+               case WLAN_CIPHER_SUITE_WEP104:
                        return ATH9K_KEY_TYPE_WEP;
-               else if (tx_info->control.hw_key->alg == ALG_TKIP)
+               case WLAN_CIPHER_SUITE_TKIP:
                        return ATH9K_KEY_TYPE_TKIP;
-               else if (tx_info->control.hw_key->alg == ALG_CCMP)
+               case WLAN_CIPHER_SUITE_CCMP:
                        return ATH9K_KEY_TYPE_AES;
+               default:
+                       break;
+               }
        }
 
        return ATH9K_KEY_TYPE_CLEAR;
@@ -212,11 +217,11 @@ static int ath_reserve_key_cache_slot_tkip(struct ath_common *common)
 }
 
 static int ath_reserve_key_cache_slot(struct ath_common *common,
-                                     enum ieee80211_key_alg alg)
+                                     u32 cipher)
 {
        int i;
 
-       if (alg == ALG_TKIP)
+       if (cipher == WLAN_CIPHER_SUITE_TKIP)
                return ath_reserve_key_cache_slot_tkip(common);
 
        /* First, try to find slots that would not be available for TKIP. */
@@ -293,14 +298,15 @@ int ath9k_cmn_key_config(struct ath_common *common,
 
        memset(&hk, 0, sizeof(hk));
 
-       switch (key->alg) {
-       case ALG_WEP:
+       switch (key->cipher) {
+       case WLAN_CIPHER_SUITE_WEP40:
+       case WLAN_CIPHER_SUITE_WEP104:
                hk.kv_type = ATH9K_CIPHER_WEP;
                break;
-       case ALG_TKIP:
+       case WLAN_CIPHER_SUITE_TKIP:
                hk.kv_type = ATH9K_CIPHER_TKIP;
                break;
-       case ALG_CCMP:
+       case WLAN_CIPHER_SUITE_CCMP:
                hk.kv_type = ATH9K_CIPHER_AES_CCM;
                break;
        default:
@@ -316,7 +322,7 @@ int ath9k_cmn_key_config(struct ath_common *common,
                        memcpy(gmac, vif->addr, ETH_ALEN);
                        gmac[0] |= 0x01;
                        mac = gmac;
-                       idx = ath_reserve_key_cache_slot(common, key->alg);
+                       idx = ath_reserve_key_cache_slot(common, key->cipher);
                        break;
                case NL80211_IFTYPE_ADHOC:
                        if (!sta) {
@@ -326,7 +332,7 @@ int ath9k_cmn_key_config(struct ath_common *common,
                        memcpy(gmac, sta->addr, ETH_ALEN);
                        gmac[0] |= 0x01;
                        mac = gmac;
-                       idx = ath_reserve_key_cache_slot(common, key->alg);
+                       idx = ath_reserve_key_cache_slot(common, key->cipher);
                        break;
                default:
                        idx = key->keyidx;
@@ -348,13 +354,13 @@ int ath9k_cmn_key_config(struct ath_common *common,
                        return -EOPNOTSUPP;
                mac = sta->addr;
 
-               idx = ath_reserve_key_cache_slot(common, key->alg);
+               idx = ath_reserve_key_cache_slot(common, key->cipher);
        }
 
        if (idx < 0)
                return -ENOSPC; /* no free key cache entries */
 
-       if (key->alg == ALG_TKIP)
+       if (key->cipher == WLAN_CIPHER_SUITE_TKIP)
                ret = ath_setkey_tkip(common, idx, key->key, &hk, mac,
                                      vif->type == NL80211_IFTYPE_AP);
        else
@@ -364,7 +370,7 @@ int ath9k_cmn_key_config(struct ath_common *common,
                return -EIO;
 
        set_bit(idx, common->keymap);
-       if (key->alg == ALG_TKIP) {
+       if (key->cipher == WLAN_CIPHER_SUITE_TKIP) {
                set_bit(idx + 64, common->keymap);
                if (common->splitmic) {
                        set_bit(idx + 32, common->keymap);
@@ -389,7 +395,7 @@ void ath9k_cmn_key_delete(struct ath_common *common,
                return;
 
        clear_bit(key->hw_key_idx, common->keymap);
-       if (key->alg != ALG_TKIP)
+       if (key->cipher != WLAN_CIPHER_SUITE_TKIP)
                return;
 
        clear_bit(key->hw_key_idx + 64, common->keymap);
index 7d09b4b17bbd4b5e1146fa295ea6a22ffb571014..4e345be62435ff3d9c8cdaa5f1bf64df8d2f62ca 100644 (file)
@@ -1585,9 +1585,10 @@ static int ath9k_htc_set_key(struct ieee80211_hw *hw,
                        key->hw_key_idx = ret;
                        /* push IV and Michael MIC generation to stack */
                        key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
-                       if (key->alg == ALG_TKIP)
+                       if (key->cipher == WLAN_CIPHER_SUITE_TKIP)
                                key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
-                       if (priv->ah->sw_mgmt_crypto && key->alg == ALG_CCMP)
+                       if (priv->ah->sw_mgmt_crypto &&
+                           key->cipher == WLAN_CIPHER_SUITE_CCMP)
                                key->flags |= IEEE80211_KEY_FLAG_SW_MGMT;
                        ret = 0;
                }
index a3b0ea90439d129924331d09d81689408ca16078..1165f909ef04605edc283a50cf48cc58cd611781 100644 (file)
@@ -1782,9 +1782,10 @@ static int ath9k_set_key(struct ieee80211_hw *hw,
                        key->hw_key_idx = ret;
                        /* push IV and Michael MIC generation to stack */
                        key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
-                       if (key->alg == ALG_TKIP)
+                       if (key->cipher == WLAN_CIPHER_SUITE_TKIP)
                                key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
-                       if (sc->sc_ah->sw_mgmt_crypto && key->alg == ALG_CCMP)
+                       if (sc->sc_ah->sw_mgmt_crypto &&
+                           key->cipher == WLAN_CIPHER_SUITE_CCMP)
                                key->flags |= IEEE80211_KEY_FLAG_SW_MGMT;
                        ret = 0;
                }
index a3e2f2bfe3a78f65c24f21ef4171e71593aa321a..a1186525c70d03f33a936ff15dc90a6bda877e1a 100644 (file)
@@ -3759,17 +3759,17 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
        }
 
        err = -EINVAL;
-       switch (key->alg) {
-       case ALG_WEP:
-               if (key->keylen == WLAN_KEY_LEN_WEP40)
-                       algorithm = B43_SEC_ALGO_WEP40;
-               else
-                       algorithm = B43_SEC_ALGO_WEP104;
+       switch (key->cipher) {
+       case WLAN_CIPHER_SUITE_WEP40:
+               algorithm = B43_SEC_ALGO_WEP40;
+               break;
+       case WLAN_CIPHER_SUITE_WEP104:
+               algorithm = B43_SEC_ALGO_WEP104;
                break;
-       case ALG_TKIP:
+       case WLAN_CIPHER_SUITE_TKIP:
                algorithm = B43_SEC_ALGO_TKIP;
                break;
-       case ALG_CCMP:
+       case WLAN_CIPHER_SUITE_CCMP:
                algorithm = B43_SEC_ALGO_AES;
                break;
        default:
index 69155aa448fb80f8c042b212567679b905e20513..3fc982e879215d23412c9e97f2377cc259de2f0a 100644 (file)
@@ -470,8 +470,8 @@ static void iwlagn_tx_cmd_build_hwcrypto(struct iwl_priv *priv,
 {
        struct ieee80211_key_conf *keyconf = info->control.hw_key;
 
-       switch (keyconf->alg) {
-       case ALG_CCMP:
+       switch (keyconf->cipher) {
+       case WLAN_CIPHER_SUITE_CCMP:
                tx_cmd->sec_ctl = TX_CMD_SEC_CCM;
                memcpy(tx_cmd->key, keyconf->key, keyconf->keylen);
                if (info->flags & IEEE80211_TX_CTL_AMPDU)
@@ -479,20 +479,20 @@ static void iwlagn_tx_cmd_build_hwcrypto(struct iwl_priv *priv,
                IWL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n");
                break;
 
-       case ALG_TKIP:
+       case WLAN_CIPHER_SUITE_TKIP:
                tx_cmd->sec_ctl = TX_CMD_SEC_TKIP;
                ieee80211_get_tkip_key(keyconf, skb_frag,
                        IEEE80211_TKIP_P2_KEY, tx_cmd->key);
                IWL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n");
                break;
 
-       case ALG_WEP:
+       case WLAN_CIPHER_SUITE_WEP104:
+               tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128;
+               /* fall through */
+       case WLAN_CIPHER_SUITE_WEP40:
                tx_cmd->sec_ctl |= (TX_CMD_SEC_WEP |
                        (keyconf->keyidx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT);
 
-               if (keyconf->keylen == WEP_KEY_LEN_128)
-                       tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128;
-
                memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen);
 
                IWL_DEBUG_TX(priv, "Configuring packet for WEP encryption "
@@ -500,7 +500,7 @@ static void iwlagn_tx_cmd_build_hwcrypto(struct iwl_priv *priv,
                break;
 
        default:
-               IWL_ERR(priv, "Unknown encode alg %d\n", keyconf->alg);
+               IWL_ERR(priv, "Unknown encode cipher %x\n", keyconf->cipher);
                break;
        }
 }
index 43e078b8737825dfd51592e21d7882546c984501..21a52ae05c0df37e35f3773ecf1ee30ad8b25feb 100644 (file)
@@ -3389,7 +3389,9 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
         * in 1X mode.
         * In legacy wep mode, we use another host command to the uCode.
         */
-       if (key->alg == ALG_WEP && !sta && vif->type != NL80211_IFTYPE_AP) {
+       if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
+            key->cipher == WLAN_CIPHER_SUITE_WEP104) &&
+           !sta && vif->type != NL80211_IFTYPE_AP) {
                if (cmd == SET_KEY)
                        is_default_wep_key = !priv->key_mapping_key;
                else
index 599635547021e21cdd568ac0d7e4b5c7491fd817..149619fb1c07a4db896c19fe5de57e079635d5bf 100644 (file)
@@ -420,7 +420,7 @@ struct iwl_tid_data {
 };
 
 struct iwl_hw_key {
-       enum ieee80211_key_alg alg;
+       u32 cipher;
        int keylen;
        u8 keyidx;
        u8 key[32];
index 7e0829be5e783a0e49957a89414d61a413a79407..d5e8db37b86e6f442aa673015c7bded2be4b3f9a 100644 (file)
@@ -818,7 +818,7 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
 
        keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV;
        keyconf->hw_key_idx = HW_KEY_DEFAULT;
-       priv->stations[IWL_AP_ID].keyinfo.alg = ALG_WEP;
+       priv->stations[IWL_AP_ID].keyinfo.cipher = keyconf->cipher;
 
        priv->wep_keys[keyconf->keyidx].key_size = keyconf->keylen;
        memcpy(&priv->wep_keys[keyconf->keyidx].key, &keyconf->key,
@@ -856,7 +856,7 @@ static int iwl_set_wep_dynamic_key_info(struct iwl_priv *priv,
 
        spin_lock_irqsave(&priv->sta_lock, flags);
 
-       priv->stations[sta_id].keyinfo.alg = keyconf->alg;
+       priv->stations[sta_id].keyinfo.cipher = keyconf->cipher;
        priv->stations[sta_id].keyinfo.keylen = keyconf->keylen;
        priv->stations[sta_id].keyinfo.keyidx = keyconf->keyidx;
 
@@ -906,7 +906,7 @@ static int iwl_set_ccmp_dynamic_key_info(struct iwl_priv *priv,
        keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
 
        spin_lock_irqsave(&priv->sta_lock, flags);
-       priv->stations[sta_id].keyinfo.alg = keyconf->alg;
+       priv->stations[sta_id].keyinfo.cipher = keyconf->cipher;
        priv->stations[sta_id].keyinfo.keylen = keyconf->keylen;
 
        memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key,
@@ -955,7 +955,7 @@ static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv,
 
        spin_lock_irqsave(&priv->sta_lock, flags);
 
-       priv->stations[sta_id].keyinfo.alg = keyconf->alg;
+       priv->stations[sta_id].keyinfo.cipher = keyconf->cipher;
        priv->stations[sta_id].keyinfo.keylen = 16;
 
        if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK)
@@ -1090,24 +1090,26 @@ int iwl_set_dynamic_key(struct iwl_priv *priv,
        priv->key_mapping_key++;
        keyconf->hw_key_idx = HW_KEY_DYNAMIC;
 
-       switch (keyconf->alg) {
-       case ALG_CCMP:
+       switch (keyconf->cipher) {
+       case WLAN_CIPHER_SUITE_CCMP:
                ret = iwl_set_ccmp_dynamic_key_info(priv, keyconf, sta_id);
                break;
-       case ALG_TKIP:
+       case WLAN_CIPHER_SUITE_TKIP:
                ret = iwl_set_tkip_dynamic_key_info(priv, keyconf, sta_id);
                break;
-       case ALG_WEP:
+       case WLAN_CIPHER_SUITE_WEP40:
+       case WLAN_CIPHER_SUITE_WEP104:
                ret = iwl_set_wep_dynamic_key_info(priv, keyconf, sta_id);
                break;
        default:
                IWL_ERR(priv,
-                       "Unknown alg: %s alg = %d\n", __func__, keyconf->alg);
+                       "Unknown alg: %s cipher = %x\n", __func__,
+                       keyconf->cipher);
                ret = -EINVAL;
        }
 
-       IWL_DEBUG_WEP(priv, "Set dynamic key: alg= %d len=%d idx=%d sta=%d ret=%d\n",
-                     keyconf->alg, keyconf->keylen, keyconf->keyidx,
+       IWL_DEBUG_WEP(priv, "Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n",
+                     keyconf->cipher, keyconf->keylen, keyconf->keyidx,
                      sta_id, ret);
 
        return ret;
index b14eaf91c7c2bdc4c4bb10b0dc129f9c30eb71ab..faa2e0037e1075a0a3c13e452e5071e81d313c8b 100644 (file)
@@ -152,7 +152,7 @@ static int iwl3945_set_ccmp_dynamic_key_info(struct iwl_priv *priv,
        key_flags &= ~STA_KEY_FLG_INVALID;
 
        spin_lock_irqsave(&priv->sta_lock, flags);
-       priv->stations[sta_id].keyinfo.alg = keyconf->alg;
+       priv->stations[sta_id].keyinfo.cipher = keyconf->cipher;
        priv->stations[sta_id].keyinfo.keylen = keyconf->keylen;
        memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key,
               keyconf->keylen);
@@ -223,23 +223,25 @@ static int iwl3945_set_dynamic_key(struct iwl_priv *priv,
 
        keyconf->hw_key_idx = HW_KEY_DYNAMIC;
 
-       switch (keyconf->alg) {
-       case ALG_CCMP:
+       switch (keyconf->cipher) {
+       case WLAN_CIPHER_SUITE_CCMP:
                ret = iwl3945_set_ccmp_dynamic_key_info(priv, keyconf, sta_id);
                break;
-       case ALG_TKIP:
+       case WLAN_CIPHER_SUITE_TKIP:
                ret = iwl3945_set_tkip_dynamic_key_info(priv, keyconf, sta_id);
                break;
-       case ALG_WEP:
+       case WLAN_CIPHER_SUITE_WEP40:
+       case WLAN_CIPHER_SUITE_WEP104:
                ret = iwl3945_set_wep_dynamic_key_info(priv, keyconf, sta_id);
                break;
        default:
-               IWL_ERR(priv, "Unknown alg: %s alg = %d\n", __func__, keyconf->alg);
+               IWL_ERR(priv, "Unknown alg: %s alg=%x\n", __func__,
+                       keyconf->cipher);
                ret = -EINVAL;
        }
 
-       IWL_DEBUG_WEP(priv, "Set dynamic key: alg= %d len=%d idx=%d sta=%d ret=%d\n",
-                     keyconf->alg, keyconf->keylen, keyconf->keyidx,
+       IWL_DEBUG_WEP(priv, "Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n",
+                     keyconf->cipher, keyconf->keylen, keyconf->keyidx,
                      sta_id, ret);
 
        return ret;
@@ -255,10 +257,11 @@ static int iwl3945_remove_static_key(struct iwl_priv *priv)
 static int iwl3945_set_static_key(struct iwl_priv *priv,
                                struct ieee80211_key_conf *key)
 {
-       if (key->alg == ALG_WEP)
+       if (key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
+           key->cipher == WLAN_CIPHER_SUITE_WEP104)
                return -EOPNOTSUPP;
 
-       IWL_ERR(priv, "Static key invalid: alg %d\n", key->alg);
+       IWL_ERR(priv, "Static key invalid: cipher %x\n", key->cipher);
        return -EINVAL;
 }
 
@@ -370,23 +373,25 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
        struct iwl3945_tx_cmd *tx_cmd = (struct iwl3945_tx_cmd *)cmd->cmd.payload;
        struct iwl_hw_key *keyinfo = &priv->stations[sta_id].keyinfo;
 
-       switch (keyinfo->alg) {
-       case ALG_CCMP:
+       tx_cmd->sec_ctl = 0;
+
+       switch (keyinfo->cipher) {
+       case WLAN_CIPHER_SUITE_CCMP:
                tx_cmd->sec_ctl = TX_CMD_SEC_CCM;
                memcpy(tx_cmd->key, keyinfo->key, keyinfo->keylen);
                IWL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n");
                break;
 
-       case ALG_TKIP:
+       case WLAN_CIPHER_SUITE_TKIP:
                break;
 
-       case ALG_WEP:
-               tx_cmd->sec_ctl = TX_CMD_SEC_WEP |
+       case WLAN_CIPHER_SUITE_WEP104:
+               tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128;
+               /* fall through */
+       case WLAN_CIPHER_SUITE_WEP40:
+               tx_cmd->sec_ctl |= TX_CMD_SEC_WEP |
                    (info->control.hw_key->hw_key_idx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT;
 
-               if (keyinfo->keylen == 13)
-                       tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128;
-
                memcpy(&tx_cmd->key[3], keyinfo->key, keyinfo->keylen);
 
                IWL_DEBUG_TX(priv, "Configuring packet for WEP encryption "
@@ -394,7 +399,7 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
                break;
 
        default:
-               IWL_ERR(priv, "Unknown encode alg %d\n", keyinfo->alg);
+               IWL_ERR(priv, "Unknown encode cipher %x\n", keyinfo->cipher);
                break;
        }
 }
index 47db439b63bfd9d3f2b9330095b4c4b606160479..622d27b6d8f214a1e69b92b93c4c570a7b22b8df 100644 (file)
@@ -429,8 +429,8 @@ static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd,
 
        mutex_lock(&priv->conf_mutex);
        if (cmd == SET_KEY) {
-               switch (key->alg) {
-               case ALG_TKIP:
+               switch (key->cipher) {
+               case WLAN_CIPHER_SUITE_TKIP:
                        if (!(priv->privacy_caps & (BR_DESC_PRIV_CAP_MICHAEL |
                              BR_DESC_PRIV_CAP_TKIP))) {
                                ret = -EOPNOTSUPP;
@@ -439,7 +439,8 @@ static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd,
                        key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
                        algo = P54_CRYPTO_TKIPMICHAEL;
                        break;
-               case ALG_WEP:
+               case WLAN_CIPHER_SUITE_WEP40:
+               case WLAN_CIPHER_SUITE_WEP104:
                        if (!(priv->privacy_caps & BR_DESC_PRIV_CAP_WEP)) {
                                ret = -EOPNOTSUPP;
                                goto out_unlock;
@@ -447,7 +448,7 @@ static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd,
                        key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
                        algo = P54_CRYPTO_WEP;
                        break;
-               case ALG_CCMP:
+               case WLAN_CIPHER_SUITE_CCMP:
                        if (!(priv->privacy_caps & BR_DESC_PRIV_CAP_AESCCMP)) {
                                ret = -EOPNOTSUPP;
                                goto out_unlock;
index 427b46f558ed4f57b0066a2ae312be0d0e82c7ae..e53f8cec7798e923ef99ef92ea560d6075d1feba 100644 (file)
@@ -683,14 +683,15 @@ static void p54_tx_80211_header(struct p54_common *priv, struct sk_buff *skb,
        }
 }
 
-static u8 p54_convert_algo(enum ieee80211_key_alg alg)
+static u8 p54_convert_algo(u32 cipher)
 {
-       switch (alg) {
-       case ALG_WEP:
+       switch (cipher) {
+       case WLAN_CIPHER_SUITE_WEP40:
+       case WLAN_CIPHER_SUITE_WEP104:
                return P54_CRYPTO_WEP;
-       case ALG_TKIP:
+       case WLAN_CIPHER_SUITE_TKIP:
                return P54_CRYPTO_TKIPMICHAEL;
-       case ALG_CCMP:
+       case WLAN_CIPHER_SUITE_CCMP:
                return P54_CRYPTO_AESCCMP;
        default:
                return 0;
@@ -731,7 +732,7 @@ int p54_tx_80211(struct ieee80211_hw *dev, struct sk_buff *skb)
 
        if (info->control.hw_key) {
                crypt_offset = ieee80211_get_hdrlen_from_skb(skb);
-               if (info->control.hw_key->alg == ALG_TKIP) {
+               if (info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) {
                        u8 *iv = (u8 *)(skb->data + crypt_offset);
                        /*
                         * The firmware excepts that the IV has to have
@@ -827,10 +828,10 @@ int p54_tx_80211(struct ieee80211_hw *dev, struct sk_buff *skb)
        hdr->tries = ridx;
        txhdr->rts_rate_idx = 0;
        if (info->control.hw_key) {
-               txhdr->key_type = p54_convert_algo(info->control.hw_key->alg);
+               txhdr->key_type = p54_convert_algo(info->control.hw_key->cipher);
                txhdr->key_len = min((u8)16, info->control.hw_key->keylen);
                memcpy(txhdr->key, info->control.hw_key->key, txhdr->key_len);
-               if (info->control.hw_key->alg == ALG_TKIP) {
+               if (info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) {
                        /* reserve space for the MIC key */
                        len += 8;
                        memcpy(skb_put(skb, 8), &(info->control.hw_key->key
index cdaf93f48263c012649b30d6b72604ac0b853f64..97cf72f8bc125c3991138dd2b62c4fc5287f07dc 100644 (file)
@@ -355,7 +355,9 @@ static int rt2500usb_config_key(struct rt2x00_dev *rt2x00dev,
                 * it is known that not work at least on some hardware.
                 * SW crypto will be used in that case.
                 */
-               if (key->alg == ALG_WEP && key->keyidx != 0)
+               if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
+                    key->cipher == WLAN_CIPHER_SUITE_WEP104) &&
+                   key->keyidx != 0)
                        return -EOPNOTSUPP;
 
                /*
index 583dacd8d2419dadc08af51dbaa8d7f9e30b7760..5e9074bf2b8efbb7eac0ad72db70474604557a72 100644 (file)
 
 enum cipher rt2x00crypto_key_to_cipher(struct ieee80211_key_conf *key)
 {
-       switch (key->alg) {
-       case ALG_WEP:
-               if (key->keylen == WLAN_KEY_LEN_WEP40)
-                       return CIPHER_WEP64;
-               else
-                       return CIPHER_WEP128;
-       case ALG_TKIP:
+       switch (key->cipher) {
+       case WLAN_CIPHER_SUITE_WEP40:
+               return CIPHER_WEP64;
+       case WLAN_CIPHER_SUITE_WEP104:
+               return CIPHER_WEP128;
+       case WLAN_CIPHER_SUITE_TKIP:
                return CIPHER_TKIP;
-       case ALG_CCMP:
+       case WLAN_CIPHER_SUITE_CCMP:
                return CIPHER_AES;
        default:
                return CIPHER_NONE;
@@ -95,7 +94,7 @@ unsigned int rt2x00crypto_tx_overhead(struct rt2x00_dev *rt2x00dev,
                overhead += key->iv_len;
 
        if (!(key->flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)) {
-               if (key->alg == ALG_TKIP)
+               if (key->cipher == WLAN_CIPHER_SUITE_TKIP)
                        overhead += 8;
        }
 
index 861a5f33761e9ea94d15d355a360835a0766ade0..6d31c855fcfe0ecd1355d50bc0e798ea55ee5d25 100644 (file)
@@ -725,8 +725,9 @@ static int wl1251_set_key_type(struct wl1251 *wl,
                               struct ieee80211_key_conf *mac80211_key,
                               const u8 *addr)
 {
-       switch (mac80211_key->alg) {
-       case ALG_WEP:
+       switch (mac80211_key->cipher) {
+       case WLAN_CIPHER_SUITE_WEP40:
+       case WLAN_CIPHER_SUITE_WEP104:
                if (is_broadcast_ether_addr(addr))
                        key->key_type = KEY_WEP_DEFAULT;
                else
@@ -734,7 +735,7 @@ static int wl1251_set_key_type(struct wl1251 *wl,
 
                mac80211_key->hw_key_idx = mac80211_key->keyidx;
                break;
-       case ALG_TKIP:
+       case WLAN_CIPHER_SUITE_TKIP:
                if (is_broadcast_ether_addr(addr))
                        key->key_type = KEY_TKIP_MIC_GROUP;
                else
@@ -742,7 +743,7 @@ static int wl1251_set_key_type(struct wl1251 *wl,
 
                mac80211_key->hw_key_idx = mac80211_key->keyidx;
                break;
-       case ALG_CCMP:
+       case WLAN_CIPHER_SUITE_CCMP:
                if (is_broadcast_ether_addr(addr))
                        key->key_type = KEY_AES_GROUP;
                else
@@ -750,7 +751,7 @@ static int wl1251_set_key_type(struct wl1251 *wl,
                mac80211_key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
                break;
        default:
-               wl1251_error("Unknown key algo 0x%x", mac80211_key->alg);
+               wl1251_error("Unknown key cipher 0x%x", mac80211_key->cipher);
                return -EOPNOTSUPP;
        }
 
@@ -783,7 +784,7 @@ static int wl1251_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
        wl1251_debug(DEBUG_CRYPT, "CMD: 0x%x", cmd);
        wl1251_dump(DEBUG_CRYPT, "ADDR: ", addr, ETH_ALEN);
        wl1251_debug(DEBUG_CRYPT, "Key: algo:0x%x, id:%d, len:%d flags 0x%x",
-                    key->alg, key->keyidx, key->keylen, key->flags);
+                    key->cipher, key->keyidx, key->keylen, key->flags);
        wl1251_dump(DEBUG_CRYPT, "KEY: ", key->key, key->keylen);
 
        if (is_zero_ether_addr(addr)) {
index a38ec199187a99ee7ebb475d547b218b43b8f9fc..6634b3e27cfcf1c74a47fc698d348f6539cc03a4 100644 (file)
@@ -189,7 +189,7 @@ static int wl1251_tx_send_packet(struct wl1251 *wl, struct sk_buff *skb,
        tx_hdr = (struct tx_double_buffer_desc *) skb->data;
 
        if (control->control.hw_key &&
-           control->control.hw_key->alg == ALG_TKIP) {
+           control->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) {
                int hdrlen;
                __le16 fc;
                u16 length;
@@ -399,7 +399,7 @@ static void wl1251_tx_packet_cb(struct wl1251 *wl,
         */
        frame = skb_pull(skb, sizeof(struct tx_double_buffer_desc));
        if (info->control.hw_key &&
-           info->control.hw_key->alg == ALG_TKIP) {
+           info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) {
                hdrlen = ieee80211_get_hdrlen_from_skb(skb);
                memmove(frame + WL1251_TKIP_IV_SPACE, frame, hdrlen);
                skb_pull(skb, WL1251_TKIP_IV_SPACE);
index 9d68f0012f05af67317ff6cfc9668b833e1c9d00..30194c0f36a9bfc57c87830b831cf63ac0077084 100644 (file)
@@ -1439,7 +1439,7 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
        wl1271_debug(DEBUG_CRYPT, "CMD: 0x%x", cmd);
        wl1271_dump(DEBUG_CRYPT, "ADDR: ", addr, ETH_ALEN);
        wl1271_debug(DEBUG_CRYPT, "Key: algo:0x%x, id:%d, len:%d flags 0x%x",
-                    key_conf->alg, key_conf->keyidx,
+                    key_conf->cipher, key_conf->keyidx,
                     key_conf->keylen, key_conf->flags);
        wl1271_dump(DEBUG_CRYPT, "KEY: ", key_conf->key, key_conf->keylen);
 
@@ -1455,20 +1455,21 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
        if (ret < 0)
                goto out_unlock;
 
-       switch (key_conf->alg) {
-       case ALG_WEP:
+       switch (key_conf->cipher) {
+       case WLAN_CIPHER_SUITE_WEP40:
+       case WLAN_CIPHER_SUITE_WEP104:
                key_type = KEY_WEP;
 
                key_conf->hw_key_idx = key_conf->keyidx;
                break;
-       case ALG_TKIP:
+       case WLAN_CIPHER_SUITE_TKIP:
                key_type = KEY_TKIP;
 
                key_conf->hw_key_idx = key_conf->keyidx;
                tx_seq_32 = WL1271_TX_SECURITY_HI32(wl->tx_security_seq);
                tx_seq_16 = WL1271_TX_SECURITY_LO16(wl->tx_security_seq);
                break;
-       case ALG_CCMP:
+       case WLAN_CIPHER_SUITE_CCMP:
                key_type = KEY_AES;
 
                key_conf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
@@ -1476,7 +1477,7 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
                tx_seq_16 = WL1271_TX_SECURITY_LO16(wl->tx_security_seq);
                break;
        default:
-               wl1271_error("Unknown key algo 0x%x", key_conf->alg);
+               wl1271_error("Unknown key algo 0x%x", key_conf->cipher);
 
                ret = -EOPNOTSUPP;
                goto out_sleep;
index c592cc2e9fe88690bcfb97014a423489fbbedb6d..dc0b46c93c4b52aec49441dc518613cf6f762343 100644 (file)
@@ -193,7 +193,7 @@ static int wl1271_tx_frame(struct wl1271 *wl, struct sk_buff *skb)
        info = IEEE80211_SKB_CB(skb);
 
        if (info->control.hw_key &&
-           info->control.hw_key->alg == ALG_TKIP)
+           info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP)
                extra = WL1271_TKIP_IV_SPACE;
 
        if (info->control.hw_key) {
@@ -347,7 +347,7 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl,
 
        /* remove TKIP header space if present */
        if (info->control.hw_key &&
-           info->control.hw_key->alg == ALG_TKIP) {
+           info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) {
                int hdrlen = ieee80211_get_hdrlen_from_skb(skb);
                memmove(skb->data + WL1271_TKIP_IV_SPACE, skb->data, hdrlen);
                skb_pull(skb, WL1271_TKIP_IV_SPACE);
index 871ed1de736a0b2d5162acf67b978b853be64ef6..914c747ac3a099e68995e3190a55abc6230d7c1c 100644 (file)
@@ -788,20 +788,6 @@ static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif)
        return false;
 }
 
-/**
- * enum ieee80211_key_alg - key algorithm
- * @ALG_WEP: WEP40 or WEP104
- * @ALG_TKIP: TKIP
- * @ALG_CCMP: CCMP (AES)
- * @ALG_AES_CMAC: AES-128-CMAC
- */
-enum ieee80211_key_alg {
-       ALG_WEP,
-       ALG_TKIP,
-       ALG_CCMP,
-       ALG_AES_CMAC,
-};
-
 /**
  * enum ieee80211_key_flags - key flags
  *
@@ -839,7 +825,7 @@ enum ieee80211_key_flags {
  * @hw_key_idx: To be set by the driver, this is the key index the driver
  *     wants to be given when a frame is transmitted and needs to be
  *     encrypted in hardware.
- * @alg: The key algorithm.
+ * @cipher: The key's cipher suite selector.
  * @flags: key flags, see &enum ieee80211_key_flags.
  * @keyidx: the key index (0-3)
  * @keylen: key material length
@@ -852,7 +838,7 @@ enum ieee80211_key_flags {
  * @iv_len: The IV length for this key type
  */
 struct ieee80211_key_conf {
-       enum ieee80211_key_alg alg;
+       u32 cipher;
        u8 icv_len;
        u8 iv_len;
        u8 hw_key_idx;
index 19c6146010b7f2e29e05d8cf38f15bb44ac015db..9a35d9e7efd74e0575fe37fc3297883848a10069 100644 (file)
@@ -116,7 +116,6 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
 {
        struct ieee80211_sub_if_data *sdata;
        struct sta_info *sta = NULL;
-       enum ieee80211_key_alg alg;
        struct ieee80211_key *key;
        int err;
 
@@ -125,31 +124,20 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
 
        sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
+       /* reject WEP and TKIP keys if WEP failed to initialize */
        switch (params->cipher) {
        case WLAN_CIPHER_SUITE_WEP40:
-       case WLAN_CIPHER_SUITE_WEP104:
-               alg = ALG_WEP;
-               break;
        case WLAN_CIPHER_SUITE_TKIP:
-               alg = ALG_TKIP;
-               break;
-       case WLAN_CIPHER_SUITE_CCMP:
-               alg = ALG_CCMP;
-               break;
-       case WLAN_CIPHER_SUITE_AES_CMAC:
-               alg = ALG_AES_CMAC;
+       case WLAN_CIPHER_SUITE_WEP104:
+               if (IS_ERR(sdata->local->wep_tx_tfm))
+                       return -EINVAL;
                break;
        default:
-               return -EINVAL;
+               break;
        }
 
-       /* reject WEP and TKIP keys if WEP failed to initialize */
-       if ((alg == ALG_WEP || alg == ALG_TKIP) &&
-           IS_ERR(sdata->local->wep_tx_tfm))
-               return -EINVAL;
-
-       key = ieee80211_key_alloc(alg, key_idx, params->key_len, params->key,
-                                 params->seq_len, params->seq);
+       key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
+                                 params->key, params->seq_len, params->seq);
        if (IS_ERR(key))
                return PTR_ERR(key);
 
@@ -247,10 +235,10 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
 
        memset(&params, 0, sizeof(params));
 
-       switch (key->conf.alg) {
-       case ALG_TKIP:
-               params.cipher = WLAN_CIPHER_SUITE_TKIP;
+       params.cipher = key->conf.cipher;
 
+       switch (key->conf.cipher) {
+       case WLAN_CIPHER_SUITE_TKIP:
                iv32 = key->u.tkip.tx.iv32;
                iv16 = key->u.tkip.tx.iv16;
 
@@ -268,8 +256,7 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
                params.seq = seq;
                params.seq_len = 6;
                break;
-       case ALG_CCMP:
-               params.cipher = WLAN_CIPHER_SUITE_CCMP;
+       case WLAN_CIPHER_SUITE_CCMP:
                seq[0] = key->u.ccmp.tx_pn[5];
                seq[1] = key->u.ccmp.tx_pn[4];
                seq[2] = key->u.ccmp.tx_pn[3];
@@ -279,14 +266,7 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
                params.seq = seq;
                params.seq_len = 6;
                break;
-       case ALG_WEP:
-               if (key->conf.keylen == 5)
-                       params.cipher = WLAN_CIPHER_SUITE_WEP40;
-               else
-                       params.cipher = WLAN_CIPHER_SUITE_WEP104;
-               break;
-       case ALG_AES_CMAC:
-               params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
+       case WLAN_CIPHER_SUITE_AES_CMAC:
                seq[0] = key->u.aes_cmac.tx_pn[5];
                seq[1] = key->u.aes_cmac.tx_pn[4];
                seq[2] = key->u.aes_cmac.tx_pn[3];
index fa5e76e658ef058b5fb87c4d4647c5025a3e4d71..1647f8dc5cdab475d727c49060c1db0985aaa76d 100644 (file)
@@ -64,26 +64,13 @@ static ssize_t key_algorithm_read(struct file *file,
                                  char __user *userbuf,
                                  size_t count, loff_t *ppos)
 {
-       char *alg;
+       char buf[15];
        struct ieee80211_key *key = file->private_data;
+       u32 c = key->conf.cipher;
 
-       switch (key->conf.alg) {
-       case ALG_WEP:
-               alg = "WEP\n";
-               break;
-       case ALG_TKIP:
-               alg = "TKIP\n";
-               break;
-       case ALG_CCMP:
-               alg = "CCMP\n";
-               break;
-       case ALG_AES_CMAC:
-               alg = "AES-128-CMAC\n";
-               break;
-       default:
-               return 0;
-       }
-       return simple_read_from_buffer(userbuf, count, ppos, alg, strlen(alg));
+       sprintf(buf, "%.2x-%.2x-%.2x:%d\n",
+               c >> 24, (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff);
+       return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
 }
 KEY_OPS(algorithm);
 
@@ -95,21 +82,22 @@ static ssize_t key_tx_spec_read(struct file *file, char __user *userbuf,
        int len;
        struct ieee80211_key *key = file->private_data;
 
-       switch (key->conf.alg) {
-       case ALG_WEP:
+       switch (key->conf.cipher) {
+       case WLAN_CIPHER_SUITE_WEP40:
+       case WLAN_CIPHER_SUITE_WEP104:
                len = scnprintf(buf, sizeof(buf), "\n");
                break;
-       case ALG_TKIP:
+       case WLAN_CIPHER_SUITE_TKIP:
                len = scnprintf(buf, sizeof(buf), "%08x %04x\n",
                                key->u.tkip.tx.iv32,
                                key->u.tkip.tx.iv16);
                break;
-       case ALG_CCMP:
+       case WLAN_CIPHER_SUITE_CCMP:
                tpn = key->u.ccmp.tx_pn;
                len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n",
                                tpn[0], tpn[1], tpn[2], tpn[3], tpn[4], tpn[5]);
                break;
-       case ALG_AES_CMAC:
+       case WLAN_CIPHER_SUITE_AES_CMAC:
                tpn = key->u.aes_cmac.tx_pn;
                len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n",
                                tpn[0], tpn[1], tpn[2], tpn[3], tpn[4],
@@ -130,11 +118,12 @@ static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
        int i, len;
        const u8 *rpn;
 
-       switch (key->conf.alg) {
-       case ALG_WEP:
+       switch (key->conf.cipher) {
+       case WLAN_CIPHER_SUITE_WEP40:
+       case WLAN_CIPHER_SUITE_WEP104:
                len = scnprintf(buf, sizeof(buf), "\n");
                break;
-       case ALG_TKIP:
+       case WLAN_CIPHER_SUITE_TKIP:
                for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
                        p += scnprintf(p, sizeof(buf)+buf-p,
                                       "%08x %04x\n",
@@ -142,7 +131,7 @@ static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
                                       key->u.tkip.rx[i].iv16);
                len = p - buf;
                break;
-       case ALG_CCMP:
+       case WLAN_CIPHER_SUITE_CCMP:
                for (i = 0; i < NUM_RX_DATA_QUEUES + 1; i++) {
                        rpn = key->u.ccmp.rx_pn[i];
                        p += scnprintf(p, sizeof(buf)+buf-p,
@@ -152,7 +141,7 @@ static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
                }
                len = p - buf;
                break;
-       case ALG_AES_CMAC:
+       case WLAN_CIPHER_SUITE_AES_CMAC:
                rpn = key->u.aes_cmac.rx_pn;
                p += scnprintf(p, sizeof(buf)+buf-p,
                               "%02x%02x%02x%02x%02x%02x\n",
@@ -174,11 +163,11 @@ static ssize_t key_replays_read(struct file *file, char __user *userbuf,
        char buf[20];
        int len;
 
-       switch (key->conf.alg) {
-       case ALG_CCMP:
+       switch (key->conf.cipher) {
+       case WLAN_CIPHER_SUITE_CCMP:
                len = scnprintf(buf, sizeof(buf), "%u\n", key->u.ccmp.replays);
                break;
-       case ALG_AES_CMAC:
+       case WLAN_CIPHER_SUITE_AES_CMAC:
                len = scnprintf(buf, sizeof(buf), "%u\n",
                                key->u.aes_cmac.replays);
                break;
@@ -196,8 +185,8 @@ static ssize_t key_icverrors_read(struct file *file, char __user *userbuf,
        char buf[20];
        int len;
 
-       switch (key->conf.alg) {
-       case ALG_AES_CMAC:
+       switch (key->conf.cipher) {
+       case WLAN_CIPHER_SUITE_AES_CMAC:
                len = scnprintf(buf, sizeof(buf), "%u\n",
                                key->u.aes_cmac.icverrors);
                break;
index 5d5d2a97466837b75b14961bc3b14a48bd5d488e..b5a95582d816394ef01e8812b1bebc31b36f02b3 100644 (file)
@@ -336,7 +336,7 @@ TRACE_EVENT(drv_set_key,
                LOCAL_ENTRY
                VIF_ENTRY
                STA_ENTRY
-               __field(enum ieee80211_key_alg, alg)
+               __field(u32, cipher)
                __field(u8, hw_key_idx)
                __field(u8, flags)
                __field(s8, keyidx)
@@ -346,7 +346,7 @@ TRACE_EVENT(drv_set_key,
                LOCAL_ASSIGN;
                VIF_ASSIGN;
                STA_ASSIGN;
-               __entry->alg = key->alg;
+               __entry->cipher = key->cipher;
                __entry->flags = key->flags;
                __entry->keyidx = key->keyidx;
                __entry->hw_key_idx = key->hw_key_idx;
index d6dbc8ea4eadac1cc5653068b071e17d2990efc1..3203d1d3cd38957b45b504b40ef3e5890d709ed9 100644 (file)
@@ -227,9 +227,7 @@ static void __ieee80211_key_replace(struct ieee80211_sub_if_data *sdata,
        }
 }
 
-struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg,
-                                         int idx,
-                                         size_t key_len,
+struct ieee80211_key *ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
                                          const u8 *key_data,
                                          size_t seq_len, const u8 *seq)
 {
@@ -249,15 +247,16 @@ struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg,
        key->conf.flags = 0;
        key->flags = 0;
 
-       key->conf.alg = alg;
+       key->conf.cipher = cipher;
        key->conf.keyidx = idx;
        key->conf.keylen = key_len;
-       switch (alg) {
-       case ALG_WEP:
+       switch (cipher) {
+       case WLAN_CIPHER_SUITE_WEP40:
+       case WLAN_CIPHER_SUITE_WEP104:
                key->conf.iv_len = WEP_IV_LEN;
                key->conf.icv_len = WEP_ICV_LEN;
                break;
-       case ALG_TKIP:
+       case WLAN_CIPHER_SUITE_TKIP:
                key->conf.iv_len = TKIP_IV_LEN;
                key->conf.icv_len = TKIP_ICV_LEN;
                if (seq) {
@@ -269,7 +268,7 @@ struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg,
                        }
                }
                break;
-       case ALG_CCMP:
+       case WLAN_CIPHER_SUITE_CCMP:
                key->conf.iv_len = CCMP_HDR_LEN;
                key->conf.icv_len = CCMP_MIC_LEN;
                if (seq) {
@@ -279,7 +278,7 @@ struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg,
                                                seq[CCMP_PN_LEN - j - 1];
                }
                break;
-       case ALG_AES_CMAC:
+       case WLAN_CIPHER_SUITE_AES_CMAC:
                key->conf.iv_len = 0;
                key->conf.icv_len = sizeof(struct ieee80211_mmie);
                if (seq)
@@ -290,7 +289,7 @@ struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg,
        memcpy(key->conf.key, key_data, key_len);
        INIT_LIST_HEAD(&key->list);
 
-       if (alg == ALG_CCMP) {
+       if (cipher == WLAN_CIPHER_SUITE_CCMP) {
                /*
                 * Initialize AES key state here as an optimization so that
                 * it does not need to be initialized for every packet.
@@ -303,7 +302,7 @@ struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg,
                }
        }
 
-       if (alg == ALG_AES_CMAC) {
+       if (cipher == WLAN_CIPHER_SUITE_AES_CMAC) {
                /*
                 * Initialize AES key state here as an optimization so that
                 * it does not need to be initialized for every packet.
@@ -328,9 +327,9 @@ static void __ieee80211_key_destroy(struct ieee80211_key *key)
        if (key->local)
                ieee80211_key_disable_hw_accel(key);
 
-       if (key->conf.alg == ALG_CCMP)
+       if (key->conf.cipher == WLAN_CIPHER_SUITE_CCMP)
                ieee80211_aes_key_free(key->u.ccmp.tfm);
-       if (key->conf.alg == ALG_AES_CMAC)
+       if (key->conf.cipher == WLAN_CIPHER_SUITE_AES_CMAC)
                ieee80211_aes_cmac_key_free(key->u.aes_cmac.tfm);
        if (key->local)
                ieee80211_debugfs_key_remove(key);
index b665bbb7a4711a7bcef6b7c27b41fd331d458d34..53b5ce12536f629bc4fb99365662ca0c2047bfb2 100644 (file)
@@ -123,9 +123,7 @@ struct ieee80211_key {
        struct ieee80211_key_conf conf;
 };
 
-struct ieee80211_key *ieee80211_key_alloc(enum ieee80211_key_alg alg,
-                                         int idx,
-                                         size_t key_len,
+struct ieee80211_key *ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
                                          const u8 *key_data,
                                          size_t seq_len, const u8 *seq);
 /*
index f24a0a1cff1a1d517cc090e24928db4305b09af8..ad2427021b264422ed4aa55d3a2b34d3632a3461 100644 (file)
@@ -961,7 +961,8 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
                 * pairwise or station-to-station keys, but for WEP we allow
                 * using a key index as well.
                 */
-               if (rx->key && rx->key->conf.alg != ALG_WEP &&
+               if (rx->key && rx->key->conf.cipher != WLAN_CIPHER_SUITE_WEP40 &&
+                   rx->key->conf.cipher != WLAN_CIPHER_SUITE_WEP104 &&
                    !is_multicast_ether_addr(hdr->addr1))
                        rx->key = NULL;
        }
@@ -977,8 +978,9 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
                return RX_DROP_UNUSABLE;
        /* the hdr variable is invalid now! */
 
-       switch (rx->key->conf.alg) {
-       case ALG_WEP:
+       switch (rx->key->conf.cipher) {
+       case WLAN_CIPHER_SUITE_WEP40:
+       case WLAN_CIPHER_SUITE_WEP104:
                /* Check for weak IVs if possible */
                if (rx->sta && ieee80211_is_data(fc) &&
                    (!(status->flag & RX_FLAG_IV_STRIPPED) ||
@@ -988,13 +990,13 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
 
                result = ieee80211_crypto_wep_decrypt(rx);
                break;
-       case ALG_TKIP:
+       case WLAN_CIPHER_SUITE_TKIP:
                result = ieee80211_crypto_tkip_decrypt(rx);
                break;
-       case ALG_CCMP:
+       case WLAN_CIPHER_SUITE_CCMP:
                result = ieee80211_crypto_ccmp_decrypt(rx);
                break;
-       case ALG_AES_CMAC:
+       case WLAN_CIPHER_SUITE_AES_CMAC:
                result = ieee80211_crypto_aes_cmac_decrypt(rx);
                break;
        }
@@ -1291,7 +1293,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
                /* This is the first fragment of a new frame. */
                entry = ieee80211_reassemble_add(rx->sdata, frag, seq,
                                                 rx->queue, &(rx->skb));
-               if (rx->key && rx->key->conf.alg == ALG_CCMP &&
+               if (rx->key && rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP &&
                    ieee80211_has_protected(fc)) {
                        int queue = ieee80211_is_mgmt(fc) ?
                                NUM_RX_DATA_QUEUES : rx->queue;
@@ -1320,7 +1322,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
                int i;
                u8 pn[CCMP_PN_LEN], *rpn;
                int queue;
-               if (!rx->key || rx->key->conf.alg != ALG_CCMP)
+               if (!rx->key || rx->key->conf.cipher != WLAN_CIPHER_SUITE_CCMP)
                        return RX_DROP_UNUSABLE;
                memcpy(pn, entry->last_pn, CCMP_PN_LEN);
                for (i = CCMP_PN_LEN - 1; i >= 0; i--) {
index c54db966926b455dc3d72ae0f71b7c71d3204861..bc4fefc916634bbfbfb65b18edf886e28e222509 100644 (file)
@@ -543,15 +543,16 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
                tx->key->tx_rx_count++;
                /* TODO: add threshold stuff again */
 
-               switch (tx->key->conf.alg) {
-               case ALG_WEP:
+               switch (tx->key->conf.cipher) {
+               case WLAN_CIPHER_SUITE_WEP40:
+               case WLAN_CIPHER_SUITE_WEP104:
                        if (ieee80211_is_auth(hdr->frame_control))
                                break;
-               case ALG_TKIP:
+               case WLAN_CIPHER_SUITE_TKIP:
                        if (!ieee80211_is_data_present(hdr->frame_control))
                                tx->key = NULL;
                        break;
-               case ALG_CCMP:
+               case WLAN_CIPHER_SUITE_CCMP:
                        if (!ieee80211_is_data_present(hdr->frame_control) &&
                            !ieee80211_use_mfp(hdr->frame_control, tx->sta,
                                               tx->skb))
@@ -561,7 +562,7 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
                                           IEEE80211_KEY_FLAG_SW_MGMT) &&
                                        ieee80211_is_mgmt(hdr->frame_control);
                        break;
-               case ALG_AES_CMAC:
+               case WLAN_CIPHER_SUITE_AES_CMAC:
                        if (!ieee80211_is_mgmt(hdr->frame_control))
                                tx->key = NULL;
                        break;
@@ -949,14 +950,15 @@ ieee80211_tx_h_encrypt(struct ieee80211_tx_data *tx)
        if (!tx->key)
                return TX_CONTINUE;
 
-       switch (tx->key->conf.alg) {
-       case ALG_WEP:
+       switch (tx->key->conf.cipher) {
+       case WLAN_CIPHER_SUITE_WEP40:
+       case WLAN_CIPHER_SUITE_WEP104:
                return ieee80211_crypto_wep_encrypt(tx);
-       case ALG_TKIP:
+       case WLAN_CIPHER_SUITE_TKIP:
                return ieee80211_crypto_tkip_encrypt(tx);
-       case ALG_CCMP:
+       case WLAN_CIPHER_SUITE_CCMP:
                return ieee80211_crypto_ccmp_encrypt(tx);
-       case ALG_AES_CMAC:
+       case WLAN_CIPHER_SUITE_AES_CMAC:
                return ieee80211_crypto_aes_cmac_encrypt(tx);
        }
 
index 9ebc8d8a1f5b20d3e6872610042128848ec0a4a8..f27484c22b9f40bf3876825b451e63670523ea39 100644 (file)
@@ -240,7 +240,7 @@ static int ieee80211_wep_decrypt(struct ieee80211_local *local,
 
        keyidx = skb->data[hdrlen + 3] >> 6;
 
-       if (!key || keyidx != key->conf.keyidx || key->conf.alg != ALG_WEP)
+       if (!key || keyidx != key->conf.keyidx)
                return -1;
 
        klen = 3 + key->conf.keylen;
index 8d59d27d887e3a0b96d9d995e3138595f0a13c79..b08ad94b56da606be4433cab9df2da81ce9f482c 100644 (file)
@@ -36,8 +36,8 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx)
        int tail;
 
        hdr = (struct ieee80211_hdr *)skb->data;
-       if (!tx->key || tx->key->conf.alg != ALG_TKIP || skb->len < 24 ||
-           !ieee80211_is_data_present(hdr->frame_control))
+       if (!tx->key || tx->key->conf.cipher != WLAN_CIPHER_SUITE_TKIP ||
+           skb->len < 24 || !ieee80211_is_data_present(hdr->frame_control))
                return TX_CONTINUE;
 
        hdrlen = ieee80211_hdrlen(hdr->frame_control);
@@ -94,7 +94,7 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
        if (status->flag & RX_FLAG_MMIC_STRIPPED)
                return RX_CONTINUE;
 
-       if (!rx->key || rx->key->conf.alg != ALG_TKIP ||
+       if (!rx->key || rx->key->conf.cipher != WLAN_CIPHER_SUITE_TKIP ||
            !ieee80211_has_protected(hdr->frame_control) ||
            !ieee80211_is_data_present(hdr->frame_control))
                return RX_CONTINUE;