^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * lib80211 crypt: host-based WEP encryption implementation for lib80211
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2002-2004, Jouni Malinen <j@w1.fi>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (c) 2008, John W. Linville <linville@tuxdriver.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/fips.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/random.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/scatterlist.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <asm/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <net/lib80211.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <crypto/arc4.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/crc32.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) MODULE_AUTHOR("Jouni Malinen");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) MODULE_DESCRIPTION("lib80211 crypt: WEP");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct lib80211_wep_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) u32 iv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define WEP_KEY_LEN 13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) u8 key[WEP_KEY_LEN + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) u8 key_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) u8 key_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct arc4_ctx tx_ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct arc4_ctx rx_ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static void *lib80211_wep_init(int keyidx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct lib80211_wep_data *priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) if (fips_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) if (priv == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) priv->key_idx = keyidx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /* start WEP IV from a random value */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) get_random_bytes(&priv->iv, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) return priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static void lib80211_wep_deinit(void *priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) kfree_sensitive(priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /* Add WEP IV/key info to a frame that has at least 4 bytes of headroom */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) static int lib80211_wep_build_iv(struct sk_buff *skb, int hdr_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) u8 *key, int keylen, void *priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct lib80211_wep_data *wep = priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) u32 klen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) u8 *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) if (skb_headroom(skb) < 4 || skb->len < hdr_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) pos = skb_push(skb, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) memmove(pos, pos + 4, hdr_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) pos += hdr_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) klen = 3 + wep->key_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) wep->iv++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /* Fluhrer, Mantin, and Shamir have reported weaknesses in the key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * scheduling algorithm of RC4. At least IVs (KeyByte + 3, 0xff, N)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * can be used to speedup attacks, so avoid using them. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) if ((wep->iv & 0xff00) == 0xff00) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) u8 B = (wep->iv >> 16) & 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) if (B >= 3 && B < klen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) wep->iv += 0x0100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) /* Prepend 24-bit IV to RC4 key and TX frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) *pos++ = (wep->iv >> 16) & 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) *pos++ = (wep->iv >> 8) & 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) *pos++ = wep->iv & 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) *pos++ = wep->key_idx << 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) /* Perform WEP encryption on given skb that has at least 4 bytes of headroom
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * for IV and 4 bytes of tailroom for ICV. Both IV and ICV will be transmitted,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * so the payload length increases with 8 bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static int lib80211_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) struct lib80211_wep_data *wep = priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) u32 crc, klen, len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) u8 *pos, *icv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) u8 key[WEP_KEY_LEN + 3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /* other checks are in lib80211_wep_build_iv */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) if (skb_tailroom(skb) < 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) /* add the IV to the frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) if (lib80211_wep_build_iv(skb, hdr_len, NULL, 0, priv))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /* Copy the IV into the first 3 bytes of the key */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) skb_copy_from_linear_data_offset(skb, hdr_len, key, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /* Copy rest of the WEP key (the secret part) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) memcpy(key + 3, wep->key, wep->key_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) len = skb->len - hdr_len - 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) pos = skb->data + hdr_len + 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) klen = 3 + wep->key_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /* Append little-endian CRC32 over only the data and encrypt it to produce ICV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) crc = ~crc32_le(~0, pos, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) icv = skb_put(skb, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) icv[0] = crc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) icv[1] = crc >> 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) icv[2] = crc >> 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) icv[3] = crc >> 24;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) arc4_setkey(&wep->tx_ctx, key, klen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) arc4_crypt(&wep->tx_ctx, pos, pos, len + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /* Perform WEP decryption on given buffer. Buffer includes whole WEP part of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * the frame: IV (4 bytes), encrypted payload (including SNAP header),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * ICV (4 bytes). len includes both IV and ICV.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * failure. If frame is OK, IV and ICV will be removed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) static int lib80211_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) struct lib80211_wep_data *wep = priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) u32 crc, klen, plen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) u8 key[WEP_KEY_LEN + 3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) u8 keyidx, *pos, icv[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) if (skb->len < hdr_len + 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) pos = skb->data + hdr_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) key[0] = *pos++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) key[1] = *pos++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) key[2] = *pos++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) keyidx = *pos++ >> 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) if (keyidx != wep->key_idx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) klen = 3 + wep->key_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) /* Copy rest of the WEP key (the secret part) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) memcpy(key + 3, wep->key, wep->key_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* Apply RC4 to data and compute CRC32 over decrypted data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) plen = skb->len - hdr_len - 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) arc4_setkey(&wep->rx_ctx, key, klen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) arc4_crypt(&wep->rx_ctx, pos, pos, plen + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) crc = ~crc32_le(~0, pos, plen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) icv[0] = crc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) icv[1] = crc >> 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) icv[2] = crc >> 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) icv[3] = crc >> 24;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) if (memcmp(icv, pos + plen, 4) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) /* ICV mismatch - drop frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) return -2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) /* Remove IV and ICV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) memmove(skb->data + 4, skb->data, hdr_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) skb_pull(skb, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) skb_trim(skb, skb->len - 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) static int lib80211_wep_set_key(void *key, int len, u8 * seq, void *priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) struct lib80211_wep_data *wep = priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) if (len < 0 || len > WEP_KEY_LEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) memcpy(wep->key, key, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) wep->key_len = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) static int lib80211_wep_get_key(void *key, int len, u8 * seq, void *priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) struct lib80211_wep_data *wep = priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if (len < wep->key_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) memcpy(key, wep->key, wep->key_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) return wep->key_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) static void lib80211_wep_print_stats(struct seq_file *m, void *priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) struct lib80211_wep_data *wep = priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) seq_printf(m, "key[%d] alg=WEP len=%d\n", wep->key_idx, wep->key_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) static struct lib80211_crypto_ops lib80211_crypt_wep = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) .name = "WEP",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) .init = lib80211_wep_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) .deinit = lib80211_wep_deinit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) .encrypt_mpdu = lib80211_wep_encrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) .decrypt_mpdu = lib80211_wep_decrypt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) .encrypt_msdu = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) .decrypt_msdu = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) .set_key = lib80211_wep_set_key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) .get_key = lib80211_wep_get_key,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) .print_stats = lib80211_wep_print_stats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) .extra_mpdu_prefix_len = 4, /* IV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) .extra_mpdu_postfix_len = 4, /* ICV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static int __init lib80211_crypto_wep_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) return lib80211_register_crypto_ops(&lib80211_crypt_wep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) static void __exit lib80211_crypto_wep_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) lib80211_unregister_crypto_ops(&lib80211_crypt_wep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) module_init(lib80211_crypto_wep_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) module_exit(lib80211_crypto_wep_exit);