13 #include <linux/module.h>
15 #include <linux/slab.h>
16 #include <linux/random.h>
18 #include <asm/string.h>
34 #define WEP_KEY_LEN 13
43 static void * prism2_wep_init(
int keyidx)
52 if (IS_ERR(priv->
tx_tfm)) {
59 if (IS_ERR(priv->
rx_tfm)) {
74 crypto_free_blkcipher(priv->
tx_tfm);
76 crypto_free_blkcipher(priv->
rx_tfm);
84 static void prism2_wep_deinit(
void *priv)
90 crypto_free_blkcipher(_priv->
tx_tfm);
92 crypto_free_blkcipher(_priv->
rx_tfm);
116 if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
122 memmove(pos, pos + 4, hdr_len);
132 if ((wep->
iv & 0xff00) == 0xff00) {
133 u8 B = (wep->
iv >> 16) & 0xff;
134 if (B >= 3 && B < klen)
139 *pos++ = key[0] = (wep->
iv >> 16) & 0xff;
140 *pos++ = key[1] = (wep->
iv >> 8) & 0xff;
141 *pos++ = key[2] = wep->
iv & 0xff;
155 crypto_blkcipher_setkey(wep->
tx_tfm, key, klen);
158 return crypto_blkcipher_encrypt(&desc, &
sg, &
sg, len + 4);
169 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;
199 crypto_blkcipher_setkey(wep->
rx_tfm, key, klen);
202 if (crypto_blkcipher_decrypt(&desc, &
sg, &
sg, plen + 4))
211 if (
memcmp(icv, pos + plen, 4) != 0) {
224 static int prism2_wep_set_key(
void *key,
int len,
u8 *seq,
void *priv)
238 static int prism2_wep_get_key(
void *key,
int len,
u8 *seq,
void *priv)
251 static char * prism2_wep_print_stats(
char *
p,
void *priv)
254 p +=
sprintf(p,
"key[%d] alg=WEP len=%d\n",
262 .init = prism2_wep_init,
263 .deinit = prism2_wep_deinit,
264 .encrypt_mpdu = prism2_wep_encrypt,
265 .decrypt_mpdu = prism2_wep_decrypt,
266 .encrypt_msdu =
NULL,
267 .decrypt_msdu =
NULL,
268 .set_key = prism2_wep_set_key,
269 .get_key = prism2_wep_get_key,
270 .print_stats = prism2_wep_print_stats,
271 .extra_prefix_len = 4,
272 .extra_postfix_len = 4,