13 #include <linux/module.h>
15 #include <linux/slab.h>
16 #include <linux/random.h>
18 #include <asm/string.h>
32 #define WEP_KEY_LEN 13
41 static void * prism2_wep_init(
int keyidx)
51 if (IS_ERR(priv->
tx_tfm)) {
58 if (IS_ERR(priv->
rx_tfm)) {
73 crypto_free_blkcipher(priv->
tx_tfm);
75 crypto_free_blkcipher(priv->
rx_tfm);
83 static void prism2_wep_deinit(
void *priv)
89 crypto_free_blkcipher(_priv->
tx_tfm);
91 crypto_free_blkcipher(_priv->
rx_tfm);
113 if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
119 memmove(pos, pos + 4, hdr_len);
129 if ((wep->
iv & 0xff00) == 0xff00) {
130 u8 B = (wep->
iv >> 16) & 0xff;
131 if (B >= 3 && B < klen)
136 *pos++ = key[0] = (wep->
iv >> 16) & 0xff;
137 *pos++ = key[1] = (wep->
iv >> 8) & 0xff;
138 *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);
172 static int prism2_wep_decrypt(
struct sk_buff *skb,
int hdr_len,
void *priv)
183 if (skb->
len < hdr_len + 8)
190 keyidx = *pos++ >> 6;
200 plen = skb->
len - hdr_len - 8;
204 crypto_blkcipher_setkey(wep->
rx_tfm, key, klen);
207 if (crypto_blkcipher_decrypt(&desc, &
sg, &
sg, plen + 4))
215 if (
memcmp(icv, pos + plen, 4) != 0) {
229 static int prism2_wep_set_key(
void *key,
int len,
u8 *seq,
void *priv)
243 static int prism2_wep_get_key(
void *key,
int len,
u8 *seq,
void *priv)
256 static char * prism2_wep_print_stats(
char *
p,
void *priv)
259 p +=
sprintf(p,
"key[%d] alg=WEP len=%d\n",
267 .init = prism2_wep_init,
268 .deinit = prism2_wep_deinit,
269 .encrypt_mpdu = prism2_wep_encrypt,
270 .decrypt_mpdu = prism2_wep_decrypt,
271 .encrypt_msdu =
NULL,
272 .decrypt_msdu =
NULL,
273 .set_key = prism2_wep_set_key,
274 .get_key = prism2_wep_get_key,
275 .print_stats = prism2_wep_print_stats,
276 .extra_prefix_len = 4,
277 .extra_postfix_len = 4,