12 #include <linux/module.h>
14 #include <linux/slab.h>
15 #include <linux/random.h>
17 #include <linux/string.h>
27 #define WEP_KEY_LEN 13
36 static void *prism2_wep_init(
int keyidx)
46 if (IS_ERR(priv->
tx_tfm)) {
53 if (IS_ERR(priv->
rx_tfm)) {
68 crypto_free_blkcipher(priv->
tx_tfm);
70 crypto_free_blkcipher(priv->
rx_tfm);
77 static void prism2_wep_deinit(
void *priv)
83 crypto_free_blkcipher(_priv->
tx_tfm);
85 crypto_free_blkcipher(_priv->
rx_tfm);
108 if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
111 " hdr_len=%d\n", skb_headroom(skb), skb_tailroom(skb),
117 memmove(pos, pos + 4, hdr_len);
127 if ((wep->
iv & 0xff00) == 0xff00) {
128 u8 B = (wep->
iv >> 16) & 0xff;
129 if (B >= 3 && B < klen)
134 *pos++ = key[0] = (wep->
iv >> 16) & 0xff;
135 *pos++ = key[1] = (wep->
iv >> 8) & 0xff;
136 *pos++ = key[2] = wep->
iv & 0xff;
153 crypto_blkcipher_setkey(wep->
tx_tfm, key, klen);
154 return crypto_blkcipher_encrypt(&desc, &
sg, &
sg, len + 4);
168 static int prism2_wep_decrypt(
struct sk_buff *skb,
int hdr_len,
void *priv)
180 if (skb->
len < hdr_len + 8)
187 keyidx = *pos++ >> 6;
197 plen = skb->
len - hdr_len - 8;
201 crypto_blkcipher_setkey(wep->
rx_tfm, key, klen);
202 if (crypto_blkcipher_decrypt(&desc, &
sg, &
sg, plen + 4))
209 if (
memcmp(icv, pos + plen, 4) != 0) {
223 static int prism2_wep_set_key(
void *key,
int len,
u8 *seq,
void *priv)
237 static int prism2_wep_get_key(
void *key,
int len,
u8 *seq,
void *priv)
250 static char *prism2_wep_print_stats(
char *
p,
void *priv)
253 p +=
sprintf(p,
"key[%d] alg=WEP len=%d\n",
260 .init = prism2_wep_init,
261 .deinit = prism2_wep_deinit,
262 .encrypt_mpdu = prism2_wep_encrypt,
263 .decrypt_mpdu = prism2_wep_decrypt,
264 .encrypt_msdu =
NULL,
265 .decrypt_msdu =
NULL,
266 .set_key = prism2_wep_set_key,
267 .get_key = prism2_wep_get_key,
268 .print_stats = prism2_wep_print_stats,
269 .extra_mpdu_prefix_len = 4,
270 .extra_mpdu_postfix_len = 4,