diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-09-22 20:10:23 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-09-22 20:10:23 -0400 |
commit | 28eb177dfa5982d132edceed891cb3885df258bb (patch) | |
tree | 5f8fdc37ad1d8d0793e9c47da7d908b97c814ffb /net/ieee80211/ieee80211_crypt_wep.c | |
parent | fd8ae94eea9bb4269d6dff1b47b9dc741bd70d0b (diff) | |
parent | db392219c5f572610645696e3672f6ea38783a65 (diff) |
Merge branch 'master' into upstream
Conflicts:
net/ieee80211/ieee80211_crypt_tkip.c
net/ieee80211/ieee80211_crypt_wep.c
Diffstat (limited to 'net/ieee80211/ieee80211_crypt_wep.c')
-rw-r--r-- | net/ieee80211/ieee80211_crypt_wep.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/net/ieee80211/ieee80211_crypt_wep.c b/net/ieee80211/ieee80211_crypt_wep.c index b435b28857ed..9eeec13c28b0 100644 --- a/net/ieee80211/ieee80211_crypt_wep.c +++ b/net/ieee80211/ieee80211_crypt_wep.c | |||
@@ -9,6 +9,7 @@ | |||
9 | * more details. | 9 | * more details. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/err.h> | ||
12 | #include <linux/module.h> | 13 | #include <linux/module.h> |
13 | #include <linux/init.h> | 14 | #include <linux/init.h> |
14 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
@@ -32,8 +33,8 @@ struct prism2_wep_data { | |||
32 | u8 key[WEP_KEY_LEN + 1]; | 33 | u8 key[WEP_KEY_LEN + 1]; |
33 | u8 key_len; | 34 | u8 key_len; |
34 | u8 key_idx; | 35 | u8 key_idx; |
35 | struct crypto_tfm *tx_tfm; | 36 | struct crypto_blkcipher *tx_tfm; |
36 | struct crypto_tfm *rx_tfm; | 37 | struct crypto_blkcipher *rx_tfm; |
37 | }; | 38 | }; |
38 | 39 | ||
39 | static void *prism2_wep_init(int keyidx) | 40 | static void *prism2_wep_init(int keyidx) |
@@ -45,15 +46,16 @@ static void *prism2_wep_init(int keyidx) | |||
45 | goto fail; | 46 | goto fail; |
46 | priv->key_idx = keyidx; | 47 | priv->key_idx = keyidx; |
47 | 48 | ||
48 | priv->tx_tfm = crypto_alloc_tfm("arc4", 0); | 49 | priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); |
49 | if (priv->tx_tfm == NULL) { | 50 | if (IS_ERR(priv->tx_tfm)) { |
50 | printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " | 51 | printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " |
51 | "crypto API arc4\n"); | 52 | "crypto API arc4\n"); |
53 | priv->tfm = NULL; | ||
52 | goto fail; | 54 | goto fail; |
53 | } | 55 | } |
54 | 56 | ||
55 | priv->rx_tfm = crypto_alloc_tfm("arc4", 0); | 57 | priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); |
56 | if (priv->rx_tfm == NULL) { | 58 | if (IS_ERR(priv->rx_tfm)) { |
57 | printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " | 59 | printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " |
58 | "crypto API arc4\n"); | 60 | "crypto API arc4\n"); |
59 | goto fail; | 61 | goto fail; |
@@ -66,9 +68,9 @@ static void *prism2_wep_init(int keyidx) | |||
66 | fail: | 68 | fail: |
67 | if (priv) { | 69 | if (priv) { |
68 | if (priv->tx_tfm) | 70 | if (priv->tx_tfm) |
69 | crypto_free_tfm(priv->tx_tfm); | 71 | crypto_free_blkcipher(priv->tx_tfm); |
70 | if (priv->rx_tfm) | 72 | if (priv->rx_tfm) |
71 | crypto_free_tfm(priv->rx_tfm); | 73 | crypto_free_blkcipher(priv->rx_tfm); |
72 | kfree(priv); | 74 | kfree(priv); |
73 | } | 75 | } |
74 | return NULL; | 76 | return NULL; |
@@ -79,9 +81,9 @@ static void prism2_wep_deinit(void *priv) | |||
79 | struct prism2_wep_data *_priv = priv; | 81 | struct prism2_wep_data *_priv = priv; |
80 | if (_priv) { | 82 | if (_priv) { |
81 | if (_priv->tx_tfm) | 83 | if (_priv->tx_tfm) |
82 | crypto_free_tfm(_priv->tx_tfm); | 84 | crypto_free_blkcipher(_priv->tx_tfm); |
83 | if (_priv->rx_tfm) | 85 | if (_priv->rx_tfm) |
84 | crypto_free_tfm(_priv->rx_tfm); | 86 | crypto_free_blkcipher(_priv->rx_tfm); |
85 | } | 87 | } |
86 | kfree(priv); | 88 | kfree(priv); |
87 | } | 89 | } |
@@ -133,6 +135,7 @@ static int prism2_wep_build_iv(struct sk_buff *skb, int hdr_len, | |||
133 | static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) | 135 | static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) |
134 | { | 136 | { |
135 | struct prism2_wep_data *wep = priv; | 137 | struct prism2_wep_data *wep = priv; |
138 | struct blkcipher_desc desc = { .tfm = wep->tx_tfm }; | ||
136 | u32 crc, klen, len; | 139 | u32 crc, klen, len; |
137 | u8 *pos, *icv; | 140 | u8 *pos, *icv; |
138 | struct scatterlist sg; | 141 | struct scatterlist sg; |
@@ -164,13 +167,11 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
164 | icv[2] = crc >> 16; | 167 | icv[2] = crc >> 16; |
165 | icv[3] = crc >> 24; | 168 | icv[3] = crc >> 24; |
166 | 169 | ||
167 | crypto_cipher_setkey(wep->tx_tfm, key, klen); | 170 | crypto_blkcipher_setkey(wep->tx_tfm, key, klen); |
168 | sg.page = virt_to_page(pos); | 171 | sg.page = virt_to_page(pos); |
169 | sg.offset = offset_in_page(pos); | 172 | sg.offset = offset_in_page(pos); |
170 | sg.length = len + 4; | 173 | sg.length = len + 4; |
171 | crypto_cipher_encrypt(wep->tx_tfm, &sg, &sg, len + 4); | 174 | return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); |
172 | |||
173 | return 0; | ||
174 | } | 175 | } |
175 | 176 | ||
176 | /* Perform WEP decryption on given buffer. Buffer includes whole WEP part of | 177 | /* Perform WEP decryption on given buffer. Buffer includes whole WEP part of |
@@ -183,6 +184,7 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
183 | static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | 184 | static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) |
184 | { | 185 | { |
185 | struct prism2_wep_data *wep = priv; | 186 | struct prism2_wep_data *wep = priv; |
187 | struct blkcipher_desc desc = { .tfm = wep->rx_tfm }; | ||
186 | u32 crc, klen, plen; | 188 | u32 crc, klen, plen; |
187 | u8 key[WEP_KEY_LEN + 3]; | 189 | u8 key[WEP_KEY_LEN + 3]; |
188 | u8 keyidx, *pos, icv[4]; | 190 | u8 keyidx, *pos, icv[4]; |
@@ -207,11 +209,12 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
207 | /* Apply RC4 to data and compute CRC32 over decrypted data */ | 209 | /* Apply RC4 to data and compute CRC32 over decrypted data */ |
208 | plen = skb->len - hdr_len - 8; | 210 | plen = skb->len - hdr_len - 8; |
209 | 211 | ||
210 | crypto_cipher_setkey(wep->rx_tfm, key, klen); | 212 | crypto_blkcipher_setkey(wep->rx_tfm, key, klen); |
211 | sg.page = virt_to_page(pos); | 213 | sg.page = virt_to_page(pos); |
212 | sg.offset = offset_in_page(pos); | 214 | sg.offset = offset_in_page(pos); |
213 | sg.length = plen + 4; | 215 | sg.length = plen + 4; |
214 | crypto_cipher_decrypt(wep->rx_tfm, &sg, &sg, plen + 4); | 216 | if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) |
217 | return -7; | ||
215 | 218 | ||
216 | crc = ~crc32_le(~0, pos, plen); | 219 | crc = ~crc32_le(~0, pos, plen); |
217 | icv[0] = crc; | 220 | icv[0] = crc; |