aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorCedric Izoard <Cedric.Izoard@ceva-dsp.com>2015-03-17 06:47:33 -0400
committerJohannes Berg <johannes.berg@intel.com>2015-03-17 07:34:26 -0400
commitc7ef38e0ccca25050efed56a35df2e1e93c0b469 (patch)
tree041949d9e29d3f54936ccbd8de9b5c449ad5036e /net/mac80211
parent8a4988d13734f9340ba8b34467d8ea09347b55d5 (diff)
mac80211: Get IV len from key conf and not cipher scheme
When a key is installed using a cipher scheme, set a new internal key flag (KEY_FLAG_CIPHER_SCHEME) on it, to allow distinguishing such keys more easily. In particular, use this flag on the TX path instead of testing the sta->cipher_scheme pointer, as the station is NULL for broad-/multicast message, and use the key's iv_len instead of the cipher scheme information. Signed-off-by: Cedric Izoard <cedric.izoard@ceva-dsp.com> [add missing documentation, rewrite commit message] Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/key.c1
-rw-r--r--net/mac80211/key.h2
-rw-r--r--net/mac80211/wpa.c13
3 files changed, 9 insertions, 7 deletions
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index 0825d76edcfc..2291cd730091 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -492,6 +492,7 @@ ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
492 for (j = 0; j < len; j++) 492 for (j = 0; j < len; j++)
493 key->u.gen.rx_pn[i][j] = 493 key->u.gen.rx_pn[i][j] =
494 seq[len - j - 1]; 494 seq[len - j - 1];
495 key->flags |= KEY_FLAG_CIPHER_SCHEME;
495 } 496 }
496 } 497 }
497 memcpy(key->conf.key, key_data, key_len); 498 memcpy(key->conf.key, key_data, key_len);
diff --git a/net/mac80211/key.h b/net/mac80211/key.h
index d57a9915494f..c5a31835be0e 100644
--- a/net/mac80211/key.h
+++ b/net/mac80211/key.h
@@ -30,10 +30,12 @@ struct sta_info;
30 * @KEY_FLAG_UPLOADED_TO_HARDWARE: Indicates that this key is present 30 * @KEY_FLAG_UPLOADED_TO_HARDWARE: Indicates that this key is present
31 * in the hardware for TX crypto hardware acceleration. 31 * in the hardware for TX crypto hardware acceleration.
32 * @KEY_FLAG_TAINTED: Key is tainted and packets should be dropped. 32 * @KEY_FLAG_TAINTED: Key is tainted and packets should be dropped.
33 * @KEY_FLAG_CIPHER_SCHEME: This key is for a hardware cipher scheme
33 */ 34 */
34enum ieee80211_internal_key_flags { 35enum ieee80211_internal_key_flags {
35 KEY_FLAG_UPLOADED_TO_HARDWARE = BIT(0), 36 KEY_FLAG_UPLOADED_TO_HARDWARE = BIT(0),
36 KEY_FLAG_TAINTED = BIT(1), 37 KEY_FLAG_TAINTED = BIT(1),
38 KEY_FLAG_CIPHER_SCHEME = BIT(2),
37}; 39};
38 40
39enum ieee80211_internal_tkip_state { 41enum ieee80211_internal_tkip_state {
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index 75de6fac40d1..9d63d93c836e 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -780,9 +780,8 @@ ieee80211_crypto_cs_encrypt(struct ieee80211_tx_data *tx,
780 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 780 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
781 struct ieee80211_key *key = tx->key; 781 struct ieee80211_key *key = tx->key;
782 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 782 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
783 const struct ieee80211_cipher_scheme *cs = key->sta->cipher_scheme;
784 int hdrlen; 783 int hdrlen;
785 u8 *pos; 784 u8 *pos, iv_len = key->conf.iv_len;
786 785
787 if (info->control.hw_key && 786 if (info->control.hw_key &&
788 !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) { 787 !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) {
@@ -790,14 +789,14 @@ ieee80211_crypto_cs_encrypt(struct ieee80211_tx_data *tx,
790 return TX_CONTINUE; 789 return TX_CONTINUE;
791 } 790 }
792 791
793 if (unlikely(skb_headroom(skb) < cs->hdr_len && 792 if (unlikely(skb_headroom(skb) < iv_len &&
794 pskb_expand_head(skb, cs->hdr_len, 0, GFP_ATOMIC))) 793 pskb_expand_head(skb, iv_len, 0, GFP_ATOMIC)))
795 return TX_DROP; 794 return TX_DROP;
796 795
797 hdrlen = ieee80211_hdrlen(hdr->frame_control); 796 hdrlen = ieee80211_hdrlen(hdr->frame_control);
798 797
799 pos = skb_push(skb, cs->hdr_len); 798 pos = skb_push(skb, iv_len);
800 memmove(pos, pos + cs->hdr_len, hdrlen); 799 memmove(pos, pos + iv_len, hdrlen);
801 800
802 return TX_CONTINUE; 801 return TX_CONTINUE;
803} 802}
@@ -1217,7 +1216,7 @@ ieee80211_crypto_hw_encrypt(struct ieee80211_tx_data *tx)
1217 if (!info->control.hw_key) 1216 if (!info->control.hw_key)
1218 return TX_DROP; 1217 return TX_DROP;
1219 1218
1220 if (tx->key->sta->cipher_scheme) { 1219 if (tx->key->flags & KEY_FLAG_CIPHER_SCHEME) {
1221 res = ieee80211_crypto_cs_encrypt(tx, skb); 1220 res = ieee80211_crypto_cs_encrypt(tx, skb);
1222 if (res != TX_CONTINUE) 1221 if (res != TX_CONTINUE)
1223 return res; 1222 return res;