diff options
author | Janusz.Dziedzic@tieto.com <Janusz.Dziedzic@tieto.com> | 2012-05-09 01:11:20 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-05-16 12:46:37 -0400 |
commit | ee70108fa2a7688dc67bfedaeb0c8c46a221effb (patch) | |
tree | 69c9a607c144a79c72632c836eae3e2f5a884fd6 | |
parent | 40bbc21a2c2bc432735a085d572f3cb3732cf64c (diff) |
mac80211: Add IV-room in the skb for TKIP and WEP
Add IV-room in skb also for TKIP and WEP.
Extend patch: "mac80211: support adding IV-room in the skb for CCMP keys"
Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | include/net/mac80211.h | 2 | ||||
-rw-r--r-- | net/mac80211/wep.c | 14 | ||||
-rw-r--r-- | net/mac80211/wpa.c | 8 |
3 files changed, 19 insertions, 5 deletions
diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 4d6e6c6818d0..60e3766d3739 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h | |||
@@ -939,7 +939,7 @@ static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif) | |||
939 | * CCMP key if it requires CCMP encryption of management frames (MFP) to | 939 | * CCMP key if it requires CCMP encryption of management frames (MFP) to |
940 | * be done in software. | 940 | * be done in software. |
941 | * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver | 941 | * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver |
942 | * for a CCMP key if space should be prepared for the IV, but the IV | 942 | * if space should be prepared for the IV, but the IV |
943 | * itself should not be generated. Do not set together with | 943 | * itself should not be generated. Do not set together with |
944 | * @IEEE80211_KEY_FLAG_GENERATE_IV on the same key. | 944 | * @IEEE80211_KEY_FLAG_GENERATE_IV on the same key. |
945 | */ | 945 | */ |
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c index 7aa31bbfaa3b..e904401684da 100644 --- a/net/mac80211/wep.c +++ b/net/mac80211/wep.c | |||
@@ -92,6 +92,7 @@ static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local, | |||
92 | int keylen, int keyidx) | 92 | int keylen, int keyidx) |
93 | { | 93 | { |
94 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | 94 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
95 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
95 | unsigned int hdrlen; | 96 | unsigned int hdrlen; |
96 | u8 *newhdr; | 97 | u8 *newhdr; |
97 | 98 | ||
@@ -104,6 +105,12 @@ static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local, | |||
104 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | 105 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
105 | newhdr = skb_push(skb, WEP_IV_LEN); | 106 | newhdr = skb_push(skb, WEP_IV_LEN); |
106 | memmove(newhdr, newhdr + WEP_IV_LEN, hdrlen); | 107 | memmove(newhdr, newhdr + WEP_IV_LEN, hdrlen); |
108 | |||
109 | /* the HW only needs room for the IV, but not the actual IV */ | ||
110 | if (info->control.hw_key && | ||
111 | (info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) | ||
112 | return newhdr + hdrlen; | ||
113 | |||
107 | ieee80211_wep_get_iv(local, keylen, keyidx, newhdr + hdrlen); | 114 | ieee80211_wep_get_iv(local, keylen, keyidx, newhdr + hdrlen); |
108 | return newhdr + hdrlen; | 115 | return newhdr + hdrlen; |
109 | } | 116 | } |
@@ -313,14 +320,15 @@ ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx) | |||
313 | static int wep_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) | 320 | static int wep_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) |
314 | { | 321 | { |
315 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 322 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
323 | struct ieee80211_key_conf *hw_key = info->control.hw_key; | ||
316 | 324 | ||
317 | if (!info->control.hw_key) { | 325 | if (!hw_key) { |
318 | if (ieee80211_wep_encrypt(tx->local, skb, tx->key->conf.key, | 326 | if (ieee80211_wep_encrypt(tx->local, skb, tx->key->conf.key, |
319 | tx->key->conf.keylen, | 327 | tx->key->conf.keylen, |
320 | tx->key->conf.keyidx)) | 328 | tx->key->conf.keyidx)) |
321 | return -1; | 329 | return -1; |
322 | } else if (info->control.hw_key->flags & | 330 | } else if ((hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) || |
323 | IEEE80211_KEY_FLAG_GENERATE_IV) { | 331 | (hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) { |
324 | if (!ieee80211_wep_add_iv(tx->local, skb, | 332 | if (!ieee80211_wep_add_iv(tx->local, skb, |
325 | tx->key->conf.keylen, | 333 | tx->key->conf.keylen, |
326 | tx->key->conf.keyidx)) | 334 | tx->key->conf.keyidx)) |
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c index 0ae23c60968c..4d05ad9403ae 100644 --- a/net/mac80211/wpa.c +++ b/net/mac80211/wpa.c | |||
@@ -183,7 +183,8 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) | |||
183 | u8 *pos; | 183 | u8 *pos; |
184 | 184 | ||
185 | if (info->control.hw_key && | 185 | if (info->control.hw_key && |
186 | !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV)) { | 186 | !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) && |
187 | !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) { | ||
187 | /* hwaccel - with no need for software-generated IV */ | 188 | /* hwaccel - with no need for software-generated IV */ |
188 | return 0; | 189 | return 0; |
189 | } | 190 | } |
@@ -204,6 +205,11 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) | |||
204 | memmove(pos, pos + TKIP_IV_LEN, hdrlen); | 205 | memmove(pos, pos + TKIP_IV_LEN, hdrlen); |
205 | pos += hdrlen; | 206 | pos += hdrlen; |
206 | 207 | ||
208 | /* the HW only needs room for the IV, but not the actual IV */ | ||
209 | if (info->control.hw_key && | ||
210 | (info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) | ||
211 | return 0; | ||
212 | |||
207 | /* Increase IV for the frame */ | 213 | /* Increase IV for the frame */ |
208 | spin_lock_irqsave(&key->u.tkip.txlock, flags); | 214 | spin_lock_irqsave(&key->u.tkip.txlock, flags); |
209 | key->u.tkip.tx.iv16++; | 215 | key->u.tkip.tx.iv16++; |