aboutsummaryrefslogtreecommitdiffstats
path: root/net/ieee80211/ieee80211_crypt_wep.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2006-08-22 06:36:13 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2006-09-20 21:46:15 -0400
commitf12cc2090d721647c23dfce20834f4306db3b77d (patch)
treefba6861bdb58153acaab1ba1e51ec4e48fe0fd99 /net/ieee80211/ieee80211_crypt_wep.c
parent378c6697a282c383d89428380a3405bf95189347 (diff)
[CRYPTO] users: Use block ciphers where applicable
This patch converts all remaining users to use the new block cipher type where applicable. It also changes all simple cipher operations to use the new encrypt_one/decrypt_one interface. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'net/ieee80211/ieee80211_crypt_wep.c')
-rw-r--r--net/ieee80211/ieee80211_crypt_wep.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/net/ieee80211/ieee80211_crypt_wep.c b/net/ieee80211/ieee80211_crypt_wep.c
index 0ebf235f6939..3d46d3efe1dd 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,7 +33,7 @@ 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 *tfm; 36 struct crypto_blkcipher *tfm;
36}; 37};
37 38
38static void *prism2_wep_init(int keyidx) 39static void *prism2_wep_init(int keyidx)
@@ -44,10 +45,11 @@ static void *prism2_wep_init(int keyidx)
44 goto fail; 45 goto fail;
45 priv->key_idx = keyidx; 46 priv->key_idx = keyidx;
46 47
47 priv->tfm = crypto_alloc_tfm("arc4", 0); 48 priv->tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
48 if (priv->tfm == NULL) { 49 if (IS_ERR(priv->tfm)) {
49 printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate " 50 printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
50 "crypto API arc4\n"); 51 "crypto API arc4\n");
52 priv->tfm = NULL;
51 goto fail; 53 goto fail;
52 } 54 }
53 55
@@ -59,7 +61,7 @@ static void *prism2_wep_init(int keyidx)
59 fail: 61 fail:
60 if (priv) { 62 if (priv) {
61 if (priv->tfm) 63 if (priv->tfm)
62 crypto_free_tfm(priv->tfm); 64 crypto_free_blkcipher(priv->tfm);
63 kfree(priv); 65 kfree(priv);
64 } 66 }
65 return NULL; 67 return NULL;
@@ -69,7 +71,7 @@ static void prism2_wep_deinit(void *priv)
69{ 71{
70 struct prism2_wep_data *_priv = priv; 72 struct prism2_wep_data *_priv = priv;
71 if (_priv && _priv->tfm) 73 if (_priv && _priv->tfm)
72 crypto_free_tfm(_priv->tfm); 74 crypto_free_blkcipher(_priv->tfm);
73 kfree(priv); 75 kfree(priv);
74} 76}
75 77
@@ -120,6 +122,7 @@ static int prism2_wep_build_iv(struct sk_buff *skb, int hdr_len,
120static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) 122static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
121{ 123{
122 struct prism2_wep_data *wep = priv; 124 struct prism2_wep_data *wep = priv;
125 struct blkcipher_desc desc = { .tfm = wep->tfm };
123 u32 crc, klen, len; 126 u32 crc, klen, len;
124 u8 *pos, *icv; 127 u8 *pos, *icv;
125 struct scatterlist sg; 128 struct scatterlist sg;
@@ -151,13 +154,11 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
151 icv[2] = crc >> 16; 154 icv[2] = crc >> 16;
152 icv[3] = crc >> 24; 155 icv[3] = crc >> 24;
153 156
154 crypto_cipher_setkey(wep->tfm, key, klen); 157 crypto_blkcipher_setkey(wep->tfm, key, klen);
155 sg.page = virt_to_page(pos); 158 sg.page = virt_to_page(pos);
156 sg.offset = offset_in_page(pos); 159 sg.offset = offset_in_page(pos);
157 sg.length = len + 4; 160 sg.length = len + 4;
158 crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4); 161 return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
159
160 return 0;
161} 162}
162 163
163/* Perform WEP decryption on given buffer. Buffer includes whole WEP part of 164/* Perform WEP decryption on given buffer. Buffer includes whole WEP part of
@@ -170,6 +171,7 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
170static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) 171static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
171{ 172{
172 struct prism2_wep_data *wep = priv; 173 struct prism2_wep_data *wep = priv;
174 struct blkcipher_desc desc = { .tfm = wep->tfm };
173 u32 crc, klen, plen; 175 u32 crc, klen, plen;
174 u8 key[WEP_KEY_LEN + 3]; 176 u8 key[WEP_KEY_LEN + 3];
175 u8 keyidx, *pos, icv[4]; 177 u8 keyidx, *pos, icv[4];
@@ -194,11 +196,12 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
194 /* Apply RC4 to data and compute CRC32 over decrypted data */ 196 /* Apply RC4 to data and compute CRC32 over decrypted data */
195 plen = skb->len - hdr_len - 8; 197 plen = skb->len - hdr_len - 8;
196 198
197 crypto_cipher_setkey(wep->tfm, key, klen); 199 crypto_blkcipher_setkey(wep->tfm, key, klen);
198 sg.page = virt_to_page(pos); 200 sg.page = virt_to_page(pos);
199 sg.offset = offset_in_page(pos); 201 sg.offset = offset_in_page(pos);
200 sg.length = plen + 4; 202 sg.length = plen + 4;
201 crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4); 203 if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4))
204 return -7;
202 205
203 crc = ~crc32_le(~0, pos, plen); 206 crc = ~crc32_le(~0, pos, plen);
204 icv[0] = crc; 207 icv[0] = crc;