aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-tx.c
diff options
context:
space:
mode:
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>2008-05-15 01:54:09 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-05-21 21:48:01 -0400
commitccc038abe4cb00cf56aeae5b1df47fcc4ed4136c (patch)
tree0c35fec8a1c9e7179f9b756d30c3f8af02d9bfa5 /drivers/net/wireless/iwlwifi/iwl-tx.c
parenta98410139a2ef6553ae5d73bf12bb9a68d0b38b9 (diff)
iwlwifi: clean up and bug fix for security
This patch cleans up code in security. 1) uses the new pointer to ieee80211_key_conf passed with the tx_control. 2) resolves bug reported by Mirco Tischler (sends ADD_STA in ASYNC mode) 3) resolves bug reported by Volker Braun regarding dynamic WEP 4) drops a WEP packet which has been garbaged by firmware. This can happen upon rekeying. Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-tx.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c41
1 files changed, 12 insertions, 29 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index a37ced58c661..f32cddabdf64 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -639,16 +639,12 @@ static void iwl_tx_cmd_build_hwcrypto(struct iwl_priv *priv,
639 struct sk_buff *skb_frag, 639 struct sk_buff *skb_frag,
640 int sta_id) 640 int sta_id)
641{ 641{
642 struct iwl_hw_key *keyinfo = &priv->stations[sta_id].keyinfo; 642 struct ieee80211_key_conf *keyconf = ctl->hw_key;
643 struct iwl_wep_key *wepkey;
644 int keyidx = 0;
645 643
646 BUG_ON(ctl->hw_key->hw_key_idx > 3); 644 switch (keyconf->alg) {
647
648 switch (keyinfo->alg) {
649 case ALG_CCMP: 645 case ALG_CCMP:
650 tx_cmd->sec_ctl = TX_CMD_SEC_CCM; 646 tx_cmd->sec_ctl = TX_CMD_SEC_CCM;
651 memcpy(tx_cmd->key, keyinfo->key, keyinfo->keylen); 647 memcpy(tx_cmd->key, keyconf->key, keyconf->keylen);
652 if (ctl->flags & IEEE80211_TXCTL_AMPDU) 648 if (ctl->flags & IEEE80211_TXCTL_AMPDU)
653 tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; 649 tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK;
654 IWL_DEBUG_TX("tx_cmd with aes hwcrypto\n"); 650 IWL_DEBUG_TX("tx_cmd with aes hwcrypto\n");
@@ -656,39 +652,26 @@ static void iwl_tx_cmd_build_hwcrypto(struct iwl_priv *priv,
656 652
657 case ALG_TKIP: 653 case ALG_TKIP:
658 tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; 654 tx_cmd->sec_ctl = TX_CMD_SEC_TKIP;
659 ieee80211_get_tkip_key(keyinfo->conf, skb_frag, 655 ieee80211_get_tkip_key(keyconf, skb_frag,
660 IEEE80211_TKIP_P2_KEY, tx_cmd->key); 656 IEEE80211_TKIP_P2_KEY, tx_cmd->key);
661 IWL_DEBUG_TX("tx_cmd with tkip hwcrypto\n"); 657 IWL_DEBUG_TX("tx_cmd with tkip hwcrypto\n");
662 break; 658 break;
663 659
664 case ALG_WEP: 660 case ALG_WEP:
665 wepkey = &priv->wep_keys[ctl->hw_key->hw_key_idx];
666 tx_cmd->sec_ctl = 0;
667 if (priv->default_wep_key) {
668 /* the WEP key was sent as static */
669 keyidx = ctl->hw_key->hw_key_idx;
670 memcpy(&tx_cmd->key[3], wepkey->key,
671 wepkey->key_size);
672 if (wepkey->key_size == WEP_KEY_LEN_128)
673 tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128;
674 } else {
675 /* the WEP key was sent as dynamic */
676 keyidx = keyinfo->keyidx;
677 memcpy(&tx_cmd->key[3], keyinfo->key,
678 keyinfo->keylen);
679 if (keyinfo->keylen == WEP_KEY_LEN_128)
680 tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128;
681 }
682
683 tx_cmd->sec_ctl |= (TX_CMD_SEC_WEP | 661 tx_cmd->sec_ctl |= (TX_CMD_SEC_WEP |
684 (keyidx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT); 662 (keyconf->keyidx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT);
663
664 if (keyconf->keylen == WEP_KEY_LEN_128)
665 tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128;
666
667 memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen);
685 668
686 IWL_DEBUG_TX("Configuring packet for WEP encryption " 669 IWL_DEBUG_TX("Configuring packet for WEP encryption "
687 "with key %d\n", keyidx); 670 "with key %d\n", keyconf->keyidx);
688 break; 671 break;
689 672
690 default: 673 default:
691 printk(KERN_ERR "Unknown encode alg %d\n", keyinfo->alg); 674 printk(KERN_ERR "Unknown encode alg %d\n", keyconf->alg);
692 break; 675 break;
693 } 676 }
694} 677}