1f0706e82SJiri Benc /* 2f0706e82SJiri Benc * Software WEP encryption implementation 3f0706e82SJiri Benc * Copyright 2002, Jouni Malinen <jkmaline@cc.hut.fi> 4f0706e82SJiri Benc * Copyright 2003, Instant802 Networks, Inc. 5f0706e82SJiri Benc * 6f0706e82SJiri Benc * This program is free software; you can redistribute it and/or modify 7f0706e82SJiri Benc * it under the terms of the GNU General Public License version 2 as 8f0706e82SJiri Benc * published by the Free Software Foundation. 9f0706e82SJiri Benc */ 10f0706e82SJiri Benc 11f0706e82SJiri Benc #include <linux/netdevice.h> 12f0706e82SJiri Benc #include <linux/types.h> 13f0706e82SJiri Benc #include <linux/random.h> 14f0706e82SJiri Benc #include <linux/compiler.h> 15f0706e82SJiri Benc #include <linux/crc32.h> 16f0706e82SJiri Benc #include <linux/crypto.h> 17f0706e82SJiri Benc #include <linux/err.h> 18f0706e82SJiri Benc #include <linux/mm.h> 1911763609SRalf Baechle #include <linux/scatterlist.h> 205a0e3ad6STejun Heo #include <linux/slab.h> 21860c6e6aSIvan Kuten #include <asm/unaligned.h> 22f0706e82SJiri Benc 23f0706e82SJiri Benc #include <net/mac80211.h> 24f0706e82SJiri Benc #include "ieee80211_i.h" 25f0706e82SJiri Benc #include "wep.h" 26f0706e82SJiri Benc 27f0706e82SJiri Benc 28f0706e82SJiri Benc int ieee80211_wep_init(struct ieee80211_local *local) 29f0706e82SJiri Benc { 30f0706e82SJiri Benc /* start WEP IV from a random value */ 31*4325f6caSJohannes Berg get_random_bytes(&local->wep_iv, IEEE80211_WEP_IV_LEN); 32f0706e82SJiri Benc 335f9f1812SFelix Fietkau local->wep_tx_tfm = crypto_alloc_cipher("arc4", 0, CRYPTO_ALG_ASYNC); 34088c8726SJohn W. Linville if (IS_ERR(local->wep_tx_tfm)) { 35088c8726SJohn W. Linville local->wep_rx_tfm = ERR_PTR(-EINVAL); 36023a04beSJeremy Fitzhardinge return PTR_ERR(local->wep_tx_tfm); 37088c8726SJohn W. Linville } 38f0706e82SJiri Benc 395f9f1812SFelix Fietkau local->wep_rx_tfm = crypto_alloc_cipher("arc4", 0, CRYPTO_ALG_ASYNC); 40f0706e82SJiri Benc if (IS_ERR(local->wep_rx_tfm)) { 415f9f1812SFelix Fietkau crypto_free_cipher(local->wep_tx_tfm); 42088c8726SJohn W. Linville local->wep_tx_tfm = ERR_PTR(-EINVAL); 43023a04beSJeremy Fitzhardinge return PTR_ERR(local->wep_rx_tfm); 44f0706e82SJiri Benc } 45f0706e82SJiri Benc 46f0706e82SJiri Benc return 0; 47f0706e82SJiri Benc } 48f0706e82SJiri Benc 49f0706e82SJiri Benc void ieee80211_wep_free(struct ieee80211_local *local) 50f0706e82SJiri Benc { 513473187dSJohn W. Linville if (!IS_ERR(local->wep_tx_tfm)) 525f9f1812SFelix Fietkau crypto_free_cipher(local->wep_tx_tfm); 533473187dSJohn W. Linville if (!IS_ERR(local->wep_rx_tfm)) 545f9f1812SFelix Fietkau crypto_free_cipher(local->wep_rx_tfm); 55f0706e82SJiri Benc } 56f0706e82SJiri Benc 57c6a1fa12SJohannes Berg static inline bool ieee80211_wep_weak_iv(u32 iv, int keylen) 58f0706e82SJiri Benc { 59c6a1fa12SJohannes Berg /* 60c6a1fa12SJohannes Berg * Fluhrer, Mantin, and Shamir have reported weaknesses in the 61f0706e82SJiri Benc * key scheduling algorithm of RC4. At least IVs (KeyByte + 3, 62c6a1fa12SJohannes Berg * 0xff, N) can be used to speedup attacks, so avoid using them. 63c6a1fa12SJohannes Berg */ 64f0706e82SJiri Benc if ((iv & 0xff00) == 0xff00) { 65f0706e82SJiri Benc u8 B = (iv >> 16) & 0xff; 66f0706e82SJiri Benc if (B >= 3 && B < 3 + keylen) 67c6a1fa12SJohannes Berg return true; 68f0706e82SJiri Benc } 69c6a1fa12SJohannes Berg return false; 70f0706e82SJiri Benc } 71f0706e82SJiri Benc 72f0706e82SJiri Benc 734f0d18e2SJohannes Berg static void ieee80211_wep_get_iv(struct ieee80211_local *local, 74c9cf0122SJohannes Berg int keylen, int keyidx, u8 *iv) 75f0706e82SJiri Benc { 76f0706e82SJiri Benc local->wep_iv++; 77c9cf0122SJohannes Berg if (ieee80211_wep_weak_iv(local->wep_iv, keylen)) 78f0706e82SJiri Benc local->wep_iv += 0x0100; 79f0706e82SJiri Benc 80f0706e82SJiri Benc if (!iv) 81f0706e82SJiri Benc return; 82f0706e82SJiri Benc 83f0706e82SJiri Benc *iv++ = (local->wep_iv >> 16) & 0xff; 84f0706e82SJiri Benc *iv++ = (local->wep_iv >> 8) & 0xff; 85f0706e82SJiri Benc *iv++ = local->wep_iv & 0xff; 86c9cf0122SJohannes Berg *iv++ = keyidx << 6; 87f0706e82SJiri Benc } 88f0706e82SJiri Benc 89f0706e82SJiri Benc 906a22a59dSJohannes Berg static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local, 91f0706e82SJiri Benc struct sk_buff *skb, 92c9cf0122SJohannes Berg int keylen, int keyidx) 93f0706e82SJiri Benc { 94f0706e82SJiri Benc struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 95ee70108fSJanusz.Dziedzic@tieto.com struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 9670217d7fSHarvey Harrison unsigned int hdrlen; 97f0706e82SJiri Benc u8 *newhdr; 98f0706e82SJiri Benc 9970217d7fSHarvey Harrison hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); 100f0706e82SJiri Benc 101*4325f6caSJohannes Berg if (WARN_ON(skb_tailroom(skb) < IEEE80211_WEP_ICV_LEN || 102*4325f6caSJohannes Berg skb_headroom(skb) < IEEE80211_WEP_IV_LEN)) 103f0706e82SJiri Benc return NULL; 104f0706e82SJiri Benc 10570217d7fSHarvey Harrison hdrlen = ieee80211_hdrlen(hdr->frame_control); 106*4325f6caSJohannes Berg newhdr = skb_push(skb, IEEE80211_WEP_IV_LEN); 107*4325f6caSJohannes Berg memmove(newhdr, newhdr + IEEE80211_WEP_IV_LEN, hdrlen); 108ee70108fSJanusz.Dziedzic@tieto.com 109ee70108fSJanusz.Dziedzic@tieto.com /* the HW only needs room for the IV, but not the actual IV */ 110ee70108fSJanusz.Dziedzic@tieto.com if (info->control.hw_key && 111ee70108fSJanusz.Dziedzic@tieto.com (info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) 112ee70108fSJanusz.Dziedzic@tieto.com return newhdr + hdrlen; 113ee70108fSJanusz.Dziedzic@tieto.com 114*4325f6caSJohannes Berg skb_set_network_header(skb, skb_network_offset(skb) + 115*4325f6caSJohannes Berg IEEE80211_WEP_IV_LEN); 116c9cf0122SJohannes Berg ieee80211_wep_get_iv(local, keylen, keyidx, newhdr + hdrlen); 117f0706e82SJiri Benc return newhdr + hdrlen; 118f0706e82SJiri Benc } 119f0706e82SJiri Benc 120f0706e82SJiri Benc 1214f0d18e2SJohannes Berg static void ieee80211_wep_remove_iv(struct ieee80211_local *local, 122f0706e82SJiri Benc struct sk_buff *skb, 123f0706e82SJiri Benc struct ieee80211_key *key) 124f0706e82SJiri Benc { 125f0706e82SJiri Benc struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 12670217d7fSHarvey Harrison unsigned int hdrlen; 127f0706e82SJiri Benc 12870217d7fSHarvey Harrison hdrlen = ieee80211_hdrlen(hdr->frame_control); 129*4325f6caSJohannes Berg memmove(skb->data + IEEE80211_WEP_IV_LEN, skb->data, hdrlen); 130*4325f6caSJohannes Berg skb_pull(skb, IEEE80211_WEP_IV_LEN); 131f0706e82SJiri Benc } 132f0706e82SJiri Benc 133f0706e82SJiri Benc 134f0706e82SJiri Benc /* Perform WEP encryption using given key. data buffer must have tailroom 135f0706e82SJiri Benc * for 4-byte ICV. data_len must not include this ICV. Note: this function 136f0706e82SJiri Benc * does _not_ add IV. data = RC4(data | CRC32(data)) */ 1375f9f1812SFelix Fietkau int ieee80211_wep_encrypt_data(struct crypto_cipher *tfm, u8 *rc4key, 138f0706e82SJiri Benc size_t klen, u8 *data, size_t data_len) 139f0706e82SJiri Benc { 140860c6e6aSIvan Kuten __le32 icv; 1415f9f1812SFelix Fietkau int i; 142f0706e82SJiri Benc 1433473187dSJohn W. Linville if (IS_ERR(tfm)) 1443473187dSJohn W. Linville return -1; 1453473187dSJohn W. Linville 146860c6e6aSIvan Kuten icv = cpu_to_le32(~crc32_le(~0, data, data_len)); 147860c6e6aSIvan Kuten put_unaligned(icv, (__le32 *)(data + data_len)); 148f0706e82SJiri Benc 1495f9f1812SFelix Fietkau crypto_cipher_setkey(tfm, rc4key, klen); 150*4325f6caSJohannes Berg for (i = 0; i < data_len + IEEE80211_WEP_ICV_LEN; i++) 1515f9f1812SFelix Fietkau crypto_cipher_encrypt_one(tfm, data + i, data + i); 1523473187dSJohn W. Linville 1533473187dSJohn W. Linville return 0; 154f0706e82SJiri Benc } 155f0706e82SJiri Benc 156f0706e82SJiri Benc 157f0706e82SJiri Benc /* Perform WEP encryption on given skb. 4 bytes of extra space (IV) in the 158f0706e82SJiri Benc * beginning of the buffer 4 bytes of extra space (ICV) in the end of the 159f0706e82SJiri Benc * buffer will be added. Both IV and ICV will be transmitted, so the 160f0706e82SJiri Benc * payload length increases with 8 bytes. 161f0706e82SJiri Benc * 162f0706e82SJiri Benc * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data)) 163f0706e82SJiri Benc */ 164fffd0934SJohannes Berg int ieee80211_wep_encrypt(struct ieee80211_local *local, 165c9cf0122SJohannes Berg struct sk_buff *skb, 166c9cf0122SJohannes Berg const u8 *key, int keylen, int keyidx) 167f0706e82SJiri Benc { 168c9cf0122SJohannes Berg u8 *iv; 169f0706e82SJiri Benc size_t len; 170c9cf0122SJohannes Berg u8 rc4key[3 + WLAN_KEY_LEN_WEP104]; 171f0706e82SJiri Benc 172c9cf0122SJohannes Berg iv = ieee80211_wep_add_iv(local, skb, keylen, keyidx); 173c9cf0122SJohannes Berg if (!iv) 174f0706e82SJiri Benc return -1; 175f0706e82SJiri Benc 176*4325f6caSJohannes Berg len = skb->len - (iv + IEEE80211_WEP_IV_LEN - skb->data); 177f0706e82SJiri Benc 178f0706e82SJiri Benc /* Prepend 24-bit IV to RC4 key */ 179f0706e82SJiri Benc memcpy(rc4key, iv, 3); 180f0706e82SJiri Benc 181f0706e82SJiri Benc /* Copy rest of the WEP key (the secret part) */ 182c9cf0122SJohannes Berg memcpy(rc4key + 3, key, keylen); 183f0706e82SJiri Benc 184f0706e82SJiri Benc /* Add room for ICV */ 185*4325f6caSJohannes Berg skb_put(skb, IEEE80211_WEP_ICV_LEN); 186f0706e82SJiri Benc 1873473187dSJohn W. Linville return ieee80211_wep_encrypt_data(local->wep_tx_tfm, rc4key, keylen + 3, 188*4325f6caSJohannes Berg iv + IEEE80211_WEP_IV_LEN, len); 189f0706e82SJiri Benc } 190f0706e82SJiri Benc 191f0706e82SJiri Benc 192f0706e82SJiri Benc /* Perform WEP decryption using given key. data buffer includes encrypted 193f0706e82SJiri Benc * payload, including 4-byte ICV, but _not_ IV. data_len must not include ICV. 194f0706e82SJiri Benc * Return 0 on success and -1 on ICV mismatch. */ 1955f9f1812SFelix Fietkau int ieee80211_wep_decrypt_data(struct crypto_cipher *tfm, u8 *rc4key, 196f0706e82SJiri Benc size_t klen, u8 *data, size_t data_len) 197f0706e82SJiri Benc { 198f0706e82SJiri Benc __le32 crc; 1995f9f1812SFelix Fietkau int i; 200f0706e82SJiri Benc 2013473187dSJohn W. Linville if (IS_ERR(tfm)) 2023473187dSJohn W. Linville return -1; 2033473187dSJohn W. Linville 2045f9f1812SFelix Fietkau crypto_cipher_setkey(tfm, rc4key, klen); 205*4325f6caSJohannes Berg for (i = 0; i < data_len + IEEE80211_WEP_ICV_LEN; i++) 2065f9f1812SFelix Fietkau crypto_cipher_decrypt_one(tfm, data + i, data + i); 207f0706e82SJiri Benc 208f0706e82SJiri Benc crc = cpu_to_le32(~crc32_le(~0, data, data_len)); 209*4325f6caSJohannes Berg if (memcmp(&crc, data + data_len, IEEE80211_WEP_ICV_LEN) != 0) 210f0706e82SJiri Benc /* ICV mismatch */ 211f0706e82SJiri Benc return -1; 212f0706e82SJiri Benc 213f0706e82SJiri Benc return 0; 214f0706e82SJiri Benc } 215f0706e82SJiri Benc 216f0706e82SJiri Benc 217f0706e82SJiri Benc /* Perform WEP decryption on given skb. Buffer includes whole WEP part of 218f0706e82SJiri Benc * the frame: IV (4 bytes), encrypted payload (including SNAP header), 219f0706e82SJiri Benc * ICV (4 bytes). skb->len includes both IV and ICV. 220f0706e82SJiri Benc * 221f0706e82SJiri Benc * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on 222f0706e82SJiri Benc * failure. If frame is OK, IV and ICV will be removed, i.e., decrypted payload 223f0706e82SJiri Benc * is moved to the beginning of the skb and skb length will be reduced. 224f0706e82SJiri Benc */ 225c9cf0122SJohannes Berg static int ieee80211_wep_decrypt(struct ieee80211_local *local, 226c9cf0122SJohannes Berg struct sk_buff *skb, 227f0706e82SJiri Benc struct ieee80211_key *key) 228f0706e82SJiri Benc { 229f0706e82SJiri Benc u32 klen; 230730bd83bSJohannes Berg u8 rc4key[3 + WLAN_KEY_LEN_WEP104]; 231f0706e82SJiri Benc u8 keyidx; 232f0706e82SJiri Benc struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 23370217d7fSHarvey Harrison unsigned int hdrlen; 234f0706e82SJiri Benc size_t len; 235f0706e82SJiri Benc int ret = 0; 236f0706e82SJiri Benc 23770217d7fSHarvey Harrison if (!ieee80211_has_protected(hdr->frame_control)) 238f0706e82SJiri Benc return -1; 239f0706e82SJiri Benc 24070217d7fSHarvey Harrison hdrlen = ieee80211_hdrlen(hdr->frame_control); 241*4325f6caSJohannes Berg if (skb->len < hdrlen + IEEE80211_WEP_IV_LEN + IEEE80211_WEP_ICV_LEN) 242f0706e82SJiri Benc return -1; 243f0706e82SJiri Benc 244*4325f6caSJohannes Berg len = skb->len - hdrlen - IEEE80211_WEP_IV_LEN - IEEE80211_WEP_ICV_LEN; 245f0706e82SJiri Benc 246f0706e82SJiri Benc keyidx = skb->data[hdrlen + 3] >> 6; 247f0706e82SJiri Benc 24897359d12SJohannes Berg if (!key || keyidx != key->conf.keyidx) 249f0706e82SJiri Benc return -1; 250f0706e82SJiri Benc 2518f20fc24SJohannes Berg klen = 3 + key->conf.keylen; 252f0706e82SJiri Benc 253f0706e82SJiri Benc /* Prepend 24-bit IV to RC4 key */ 254f0706e82SJiri Benc memcpy(rc4key, skb->data + hdrlen, 3); 255f0706e82SJiri Benc 256f0706e82SJiri Benc /* Copy rest of the WEP key (the secret part) */ 2578f20fc24SJohannes Berg memcpy(rc4key + 3, key->conf.key, key->conf.keylen); 258f0706e82SJiri Benc 259f0706e82SJiri Benc if (ieee80211_wep_decrypt_data(local->wep_rx_tfm, rc4key, klen, 260*4325f6caSJohannes Berg skb->data + hdrlen + 261*4325f6caSJohannes Berg IEEE80211_WEP_IV_LEN, len)) 262f0706e82SJiri Benc ret = -1; 263f0706e82SJiri Benc 264f0706e82SJiri Benc /* Trim ICV */ 265*4325f6caSJohannes Berg skb_trim(skb, skb->len - IEEE80211_WEP_ICV_LEN); 266f0706e82SJiri Benc 267f0706e82SJiri Benc /* Remove IV */ 268*4325f6caSJohannes Berg memmove(skb->data + IEEE80211_WEP_IV_LEN, skb->data, hdrlen); 269*4325f6caSJohannes Berg skb_pull(skb, IEEE80211_WEP_IV_LEN); 270f0706e82SJiri Benc 271f0706e82SJiri Benc return ret; 272f0706e82SJiri Benc } 273f0706e82SJiri Benc 274f0706e82SJiri Benc 275617bbde8SJohannes Berg static bool ieee80211_wep_is_weak_iv(struct sk_buff *skb, 276617bbde8SJohannes Berg struct ieee80211_key *key) 277f0706e82SJiri Benc { 278f0706e82SJiri Benc struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 27970217d7fSHarvey Harrison unsigned int hdrlen; 280f0706e82SJiri Benc u8 *ivpos; 281f0706e82SJiri Benc u32 iv; 282f0706e82SJiri Benc 28370217d7fSHarvey Harrison hdrlen = ieee80211_hdrlen(hdr->frame_control); 284f0706e82SJiri Benc ivpos = skb->data + hdrlen; 285f0706e82SJiri Benc iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2]; 286f0706e82SJiri Benc 287c6a1fa12SJohannes Berg return ieee80211_wep_weak_iv(iv, key->conf.keylen); 288f0706e82SJiri Benc } 2894f0d18e2SJohannes Berg 2909ae54c84SJohannes Berg ieee80211_rx_result 2915cf121c3SJohannes Berg ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx) 2924f0d18e2SJohannes Berg { 293eb9fb5b8SJohannes Berg struct sk_buff *skb = rx->skb; 294eb9fb5b8SJohannes Berg struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); 295eb9fb5b8SJohannes Berg struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 296a8286911SJohannes Berg __le16 fc = hdr->frame_control; 297358c8d9dSHarvey Harrison 298a8286911SJohannes Berg if (!ieee80211_is_data(fc) && !ieee80211_is_auth(fc)) 2999ae54c84SJohannes Berg return RX_CONTINUE; 3004f0d18e2SJohannes Berg 301eb9fb5b8SJohannes Berg if (!(status->flag & RX_FLAG_DECRYPTED)) { 302a8286911SJohannes Berg if (skb_linearize(rx->skb)) 303a8286911SJohannes Berg return RX_DROP_UNUSABLE; 304617bbde8SJohannes Berg if (rx->sta && ieee80211_wep_is_weak_iv(rx->skb, rx->key)) 305617bbde8SJohannes Berg rx->sta->wep_weak_iv_count++; 306f4ea83ddSJohannes Berg if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) 307e4c26addSJohannes Berg return RX_DROP_UNUSABLE; 308eb9fb5b8SJohannes Berg } else if (!(status->flag & RX_FLAG_IV_STRIPPED)) { 309*4325f6caSJohannes Berg if (!pskb_may_pull(rx->skb, ieee80211_hdrlen(fc) + 310*4325f6caSJohannes Berg IEEE80211_WEP_IV_LEN)) 311a8286911SJohannes Berg return RX_DROP_UNUSABLE; 312617bbde8SJohannes Berg if (rx->sta && ieee80211_wep_is_weak_iv(rx->skb, rx->key)) 313617bbde8SJohannes Berg rx->sta->wep_weak_iv_count++; 3144f0d18e2SJohannes Berg ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key); 3154f0d18e2SJohannes Berg /* remove ICV */ 316*4325f6caSJohannes Berg if (pskb_trim(rx->skb, rx->skb->len - IEEE80211_WEP_ICV_LEN)) 317a8286911SJohannes Berg return RX_DROP_UNUSABLE; 3184f0d18e2SJohannes Berg } 3194f0d18e2SJohannes Berg 3209ae54c84SJohannes Berg return RX_CONTINUE; 3214f0d18e2SJohannes Berg } 3226a22a59dSJohannes Berg 3235cf121c3SJohannes Berg static int wep_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) 3246a22a59dSJohannes Berg { 325e039fa4aSJohannes Berg struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 326ee70108fSJanusz.Dziedzic@tieto.com struct ieee80211_key_conf *hw_key = info->control.hw_key; 327e039fa4aSJohannes Berg 328ee70108fSJanusz.Dziedzic@tieto.com if (!hw_key) { 329c9cf0122SJohannes Berg if (ieee80211_wep_encrypt(tx->local, skb, tx->key->conf.key, 330c9cf0122SJohannes Berg tx->key->conf.keylen, 331c9cf0122SJohannes Berg tx->key->conf.keyidx)) 3326a22a59dSJohannes Berg return -1; 333ee70108fSJanusz.Dziedzic@tieto.com } else if ((hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) || 334ee70108fSJanusz.Dziedzic@tieto.com (hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) { 335c9cf0122SJohannes Berg if (!ieee80211_wep_add_iv(tx->local, skb, 336c9cf0122SJohannes Berg tx->key->conf.keylen, 337c9cf0122SJohannes Berg tx->key->conf.keyidx)) 3386a22a59dSJohannes Berg return -1; 3396a22a59dSJohannes Berg } 340813d7669SJohannes Berg 3416a22a59dSJohannes Berg return 0; 3426a22a59dSJohannes Berg } 3436a22a59dSJohannes Berg 3449ae54c84SJohannes Berg ieee80211_tx_result 3455cf121c3SJohannes Berg ieee80211_crypto_wep_encrypt(struct ieee80211_tx_data *tx) 3466a22a59dSJohannes Berg { 3472de8e0d9SJohannes Berg struct sk_buff *skb; 348c6a1fa12SJohannes Berg 3495cf121c3SJohannes Berg ieee80211_tx_set_protected(tx); 3506a22a59dSJohannes Berg 351252b86c4SJohannes Berg skb_queue_walk(&tx->skbs, skb) { 3522de8e0d9SJohannes Berg if (wep_encrypt_skb(tx, skb) < 0) { 3536a22a59dSJohannes Berg I802_DEBUG_INC(tx->local->tx_handlers_drop_wep); 3549ae54c84SJohannes Berg return TX_DROP; 3556a22a59dSJohannes Berg } 356252b86c4SJohannes Berg } 3576a22a59dSJohannes Berg 3589ae54c84SJohannes Berg return TX_CONTINUE; 3596a22a59dSJohannes Berg } 360