aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/ppp_mppe.c32
-rw-r--r--drivers/net/wireless/airo.c22
-rw-r--r--net/ieee80211/ieee80211_crypt_ccmp.c32
-rw-r--r--net/ieee80211/ieee80211_crypt_tkip.c34
-rw-r--r--net/ieee80211/ieee80211_crypt_wep.c25
5 files changed, 79 insertions, 66 deletions
diff --git a/drivers/net/ppp_mppe.c b/drivers/net/ppp_mppe.c
index 51ff9a9d1bb5..495d8667419a 100644
--- a/drivers/net/ppp_mppe.c
+++ b/drivers/net/ppp_mppe.c
@@ -43,6 +43,7 @@
43 * deprecated in 2.6 43 * deprecated in 2.6
44 */ 44 */
45 45
46#include <linux/err.h>
46#include <linux/module.h> 47#include <linux/module.h>
47#include <linux/kernel.h> 48#include <linux/kernel.h>
48#include <linux/version.h> 49#include <linux/version.h>
@@ -95,7 +96,7 @@ static inline void sha_pad_init(struct sha_pad *shapad)
95 * State for an MPPE (de)compressor. 96 * State for an MPPE (de)compressor.
96 */ 97 */
97struct ppp_mppe_state { 98struct ppp_mppe_state {
98 struct crypto_tfm *arc4; 99 struct crypto_blkcipher *arc4;
99 struct crypto_tfm *sha1; 100 struct crypto_tfm *sha1;
100 unsigned char *sha1_digest; 101 unsigned char *sha1_digest;
101 unsigned char master_key[MPPE_MAX_KEY_LEN]; 102 unsigned char master_key[MPPE_MAX_KEY_LEN];
@@ -156,14 +157,15 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key)
156{ 157{
157 unsigned char InterimKey[MPPE_MAX_KEY_LEN]; 158 unsigned char InterimKey[MPPE_MAX_KEY_LEN];
158 struct scatterlist sg_in[1], sg_out[1]; 159 struct scatterlist sg_in[1], sg_out[1];
160 struct blkcipher_desc desc = { .tfm = state->arc4 };
159 161
160 get_new_key_from_sha(state, InterimKey); 162 get_new_key_from_sha(state, InterimKey);
161 if (!initial_key) { 163 if (!initial_key) {
162 crypto_cipher_setkey(state->arc4, InterimKey, state->keylen); 164 crypto_blkcipher_setkey(state->arc4, InterimKey, state->keylen);
163 setup_sg(sg_in, InterimKey, state->keylen); 165 setup_sg(sg_in, InterimKey, state->keylen);
164 setup_sg(sg_out, state->session_key, state->keylen); 166 setup_sg(sg_out, state->session_key, state->keylen);
165 if (crypto_cipher_encrypt(state->arc4, sg_out, sg_in, 167 if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in,
166 state->keylen) != 0) { 168 state->keylen) != 0) {
167 printk(KERN_WARNING "mppe_rekey: cipher_encrypt failed\n"); 169 printk(KERN_WARNING "mppe_rekey: cipher_encrypt failed\n");
168 } 170 }
169 } else { 171 } else {
@@ -175,7 +177,7 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key)
175 state->session_key[1] = 0x26; 177 state->session_key[1] = 0x26;
176 state->session_key[2] = 0x9e; 178 state->session_key[2] = 0x9e;
177 } 179 }
178 crypto_cipher_setkey(state->arc4, state->session_key, state->keylen); 180 crypto_blkcipher_setkey(state->arc4, state->session_key, state->keylen);
179} 181}
180 182
181/* 183/*
@@ -196,9 +198,11 @@ static void *mppe_alloc(unsigned char *options, int optlen)
196 198
197 memset(state, 0, sizeof(*state)); 199 memset(state, 0, sizeof(*state));
198 200
199 state->arc4 = crypto_alloc_tfm("arc4", 0); 201 state->arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
200 if (!state->arc4) 202 if (IS_ERR(state->arc4)) {
203 state->arc4 = NULL;
201 goto out_free; 204 goto out_free;
205 }
202 206
203 state->sha1 = crypto_alloc_tfm("sha1", 0); 207 state->sha1 = crypto_alloc_tfm("sha1", 0);
204 if (!state->sha1) 208 if (!state->sha1)
@@ -231,7 +235,7 @@ static void *mppe_alloc(unsigned char *options, int optlen)
231 if (state->sha1) 235 if (state->sha1)
232 crypto_free_tfm(state->sha1); 236 crypto_free_tfm(state->sha1);
233 if (state->arc4) 237 if (state->arc4)
234 crypto_free_tfm(state->arc4); 238 crypto_free_blkcipher(state->arc4);
235 kfree(state); 239 kfree(state);
236 out: 240 out:
237 return NULL; 241 return NULL;
@@ -249,7 +253,7 @@ static void mppe_free(void *arg)
249 if (state->sha1) 253 if (state->sha1)
250 crypto_free_tfm(state->sha1); 254 crypto_free_tfm(state->sha1);
251 if (state->arc4) 255 if (state->arc4)
252 crypto_free_tfm(state->arc4); 256 crypto_free_blkcipher(state->arc4);
253 kfree(state); 257 kfree(state);
254 } 258 }
255} 259}
@@ -356,6 +360,7 @@ mppe_compress(void *arg, unsigned char *ibuf, unsigned char *obuf,
356 int isize, int osize) 360 int isize, int osize)
357{ 361{
358 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; 362 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg;
363 struct blkcipher_desc desc = { .tfm = state->arc4 };
359 int proto; 364 int proto;
360 struct scatterlist sg_in[1], sg_out[1]; 365 struct scatterlist sg_in[1], sg_out[1];
361 366
@@ -413,7 +418,7 @@ mppe_compress(void *arg, unsigned char *ibuf, unsigned char *obuf,
413 /* Encrypt packet */ 418 /* Encrypt packet */
414 setup_sg(sg_in, ibuf, isize); 419 setup_sg(sg_in, ibuf, isize);
415 setup_sg(sg_out, obuf, osize); 420 setup_sg(sg_out, obuf, osize);
416 if (crypto_cipher_encrypt(state->arc4, sg_out, sg_in, isize) != 0) { 421 if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in, isize) != 0) {
417 printk(KERN_DEBUG "crypto_cypher_encrypt failed\n"); 422 printk(KERN_DEBUG "crypto_cypher_encrypt failed\n");
418 return -1; 423 return -1;
419 } 424 }
@@ -462,6 +467,7 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf,
462 int osize) 467 int osize)
463{ 468{
464 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; 469 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg;
470 struct blkcipher_desc desc = { .tfm = state->arc4 };
465 unsigned ccount; 471 unsigned ccount;
466 int flushed = MPPE_BITS(ibuf) & MPPE_BIT_FLUSHED; 472 int flushed = MPPE_BITS(ibuf) & MPPE_BIT_FLUSHED;
467 int sanity = 0; 473 int sanity = 0;
@@ -599,7 +605,7 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf,
599 */ 605 */
600 setup_sg(sg_in, ibuf, 1); 606 setup_sg(sg_in, ibuf, 1);
601 setup_sg(sg_out, obuf, 1); 607 setup_sg(sg_out, obuf, 1);
602 if (crypto_cipher_decrypt(state->arc4, sg_out, sg_in, 1) != 0) { 608 if (crypto_blkcipher_decrypt(&desc, sg_out, sg_in, 1) != 0) {
603 printk(KERN_DEBUG "crypto_cypher_decrypt failed\n"); 609 printk(KERN_DEBUG "crypto_cypher_decrypt failed\n");
604 return DECOMP_ERROR; 610 return DECOMP_ERROR;
605 } 611 }
@@ -619,7 +625,7 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf,
619 /* And finally, decrypt the rest of the packet. */ 625 /* And finally, decrypt the rest of the packet. */
620 setup_sg(sg_in, ibuf + 1, isize - 1); 626 setup_sg(sg_in, ibuf + 1, isize - 1);
621 setup_sg(sg_out, obuf + 1, osize - 1); 627 setup_sg(sg_out, obuf + 1, osize - 1);
622 if (crypto_cipher_decrypt(state->arc4, sg_out, sg_in, isize - 1) != 0) { 628 if (crypto_blkcipher_decrypt(&desc, sg_out, sg_in, isize - 1)) {
623 printk(KERN_DEBUG "crypto_cypher_decrypt failed\n"); 629 printk(KERN_DEBUG "crypto_cypher_decrypt failed\n");
624 return DECOMP_ERROR; 630 return DECOMP_ERROR;
625 } 631 }
@@ -694,7 +700,7 @@ static struct compressor ppp_mppe = {
694static int __init ppp_mppe_init(void) 700static int __init ppp_mppe_init(void)
695{ 701{
696 int answer; 702 int answer;
697 if (!(crypto_alg_available("arc4", 0) && 703 if (!(crypto_alg_available("ecb(arc4)", 0) &&
698 crypto_alg_available("sha1", 0))) 704 crypto_alg_available("sha1", 0)))
699 return -ENODEV; 705 return -ENODEV;
700 706
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index a4dd13942714..170c500169da 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -19,6 +19,7 @@
19 19
20======================================================================*/ 20======================================================================*/
21 21
22#include <linux/err.h>
22#include <linux/init.h> 23#include <linux/init.h>
23 24
24#include <linux/kernel.h> 25#include <linux/kernel.h>
@@ -1203,7 +1204,7 @@ struct airo_info {
1203 struct iw_spy_data spy_data; 1204 struct iw_spy_data spy_data;
1204 struct iw_public_data wireless_data; 1205 struct iw_public_data wireless_data;
1205 /* MIC stuff */ 1206 /* MIC stuff */
1206 struct crypto_tfm *tfm; 1207 struct crypto_cipher *tfm;
1207 mic_module mod[2]; 1208 mic_module mod[2];
1208 mic_statistics micstats; 1209 mic_statistics micstats;
1209 HostRxDesc rxfids[MPI_MAX_FIDS]; // rx/tx/config MPI350 descriptors 1210 HostRxDesc rxfids[MPI_MAX_FIDS]; // rx/tx/config MPI350 descriptors
@@ -1271,7 +1272,8 @@ static int flashrestart(struct airo_info *ai,struct net_device *dev);
1271 1272
1272static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq); 1273static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq);
1273static void MoveWindow(miccntx *context, u32 micSeq); 1274static void MoveWindow(miccntx *context, u32 micSeq);
1274static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto_tfm *); 1275static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen,
1276 struct crypto_cipher *tfm);
1275static void emmh32_init(emmh32_context *context); 1277static void emmh32_init(emmh32_context *context);
1276static void emmh32_update(emmh32_context *context, u8 *pOctets, int len); 1278static void emmh32_update(emmh32_context *context, u8 *pOctets, int len);
1277static void emmh32_final(emmh32_context *context, u8 digest[4]); 1279static void emmh32_final(emmh32_context *context, u8 digest[4]);
@@ -1339,10 +1341,11 @@ static int micsetup(struct airo_info *ai) {
1339 int i; 1341 int i;
1340 1342
1341 if (ai->tfm == NULL) 1343 if (ai->tfm == NULL)
1342 ai->tfm = crypto_alloc_tfm("aes", CRYPTO_TFM_REQ_MAY_SLEEP); 1344 ai->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
1343 1345
1344 if (ai->tfm == NULL) { 1346 if (IS_ERR(ai->tfm)) {
1345 airo_print_err(ai->dev->name, "failed to load transform for AES"); 1347 airo_print_err(ai->dev->name, "failed to load transform for AES");
1348 ai->tfm = NULL;
1346 return ERROR; 1349 return ERROR;
1347 } 1350 }
1348 1351
@@ -1608,7 +1611,8 @@ static void MoveWindow(miccntx *context, u32 micSeq)
1608static unsigned char aes_counter[16]; 1611static unsigned char aes_counter[16];
1609 1612
1610/* expand the key to fill the MMH coefficient array */ 1613/* expand the key to fill the MMH coefficient array */
1611static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto_tfm *tfm) 1614static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen,
1615 struct crypto_cipher *tfm)
1612{ 1616{
1613 /* take the keying material, expand if necessary, truncate at 16-bytes */ 1617 /* take the keying material, expand if necessary, truncate at 16-bytes */
1614 /* run through AES counter mode to generate context->coeff[] */ 1618 /* run through AES counter mode to generate context->coeff[] */
@@ -1616,7 +1620,6 @@ static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct
1616 int i,j; 1620 int i,j;
1617 u32 counter; 1621 u32 counter;
1618 u8 *cipher, plain[16]; 1622 u8 *cipher, plain[16];
1619 struct scatterlist sg[1];
1620 1623
1621 crypto_cipher_setkey(tfm, pkey, 16); 1624 crypto_cipher_setkey(tfm, pkey, 16);
1622 counter = 0; 1625 counter = 0;
@@ -1627,9 +1630,8 @@ static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct
1627 aes_counter[12] = (u8)(counter >> 24); 1630 aes_counter[12] = (u8)(counter >> 24);
1628 counter++; 1631 counter++;
1629 memcpy (plain, aes_counter, 16); 1632 memcpy (plain, aes_counter, 16);
1630 sg_set_buf(sg, plain, 16); 1633 crypto_cipher_encrypt_one(tfm, plain, plain);
1631 crypto_cipher_encrypt(tfm, sg, sg, 16); 1634 cipher = plain;
1632 cipher = kmap(sg->page) + sg->offset;
1633 for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) { 1635 for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) {
1634 context->coeff[i++] = ntohl(*(u32 *)&cipher[j]); 1636 context->coeff[i++] = ntohl(*(u32 *)&cipher[j]);
1635 j += 4; 1637 j += 4;
@@ -2432,7 +2434,7 @@ void stop_airo_card( struct net_device *dev, int freeres )
2432 ai->shared, ai->shared_dma); 2434 ai->shared, ai->shared_dma);
2433 } 2435 }
2434 } 2436 }
2435 crypto_free_tfm(ai->tfm); 2437 crypto_free_cipher(ai->tfm);
2436 del_airo_dev( dev ); 2438 del_airo_dev( dev );
2437 free_netdev( dev ); 2439 free_netdev( dev );
2438} 2440}
diff --git a/net/ieee80211/ieee80211_crypt_ccmp.c b/net/ieee80211/ieee80211_crypt_ccmp.c
index ed90a8af1444..fdfe7704a469 100644
--- a/net/ieee80211/ieee80211_crypt_ccmp.c
+++ b/net/ieee80211/ieee80211_crypt_ccmp.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>
@@ -48,7 +49,7 @@ struct ieee80211_ccmp_data {
48 49
49 int key_idx; 50 int key_idx;
50 51
51 struct crypto_tfm *tfm; 52 struct crypto_cipher *tfm;
52 53
53 /* scratch buffers for virt_to_page() (crypto API) */ 54 /* scratch buffers for virt_to_page() (crypto API) */
54 u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN], 55 u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN],
@@ -56,20 +57,10 @@ struct ieee80211_ccmp_data {
56 u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; 57 u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN];
57}; 58};
58 59
59static void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, 60static inline void ieee80211_ccmp_aes_encrypt(struct crypto_cipher *tfm,
60 const u8 pt[16], u8 ct[16]) 61 const u8 pt[16], u8 ct[16])
61{ 62{
62 struct scatterlist src, dst; 63 crypto_cipher_encrypt_one(tfm, ct, pt);
63
64 src.page = virt_to_page(pt);
65 src.offset = offset_in_page(pt);
66 src.length = AES_BLOCK_LEN;
67
68 dst.page = virt_to_page(ct);
69 dst.offset = offset_in_page(ct);
70 dst.length = AES_BLOCK_LEN;
71
72 crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN);
73} 64}
74 65
75static void *ieee80211_ccmp_init(int key_idx) 66static void *ieee80211_ccmp_init(int key_idx)
@@ -81,10 +72,11 @@ static void *ieee80211_ccmp_init(int key_idx)
81 goto fail; 72 goto fail;
82 priv->key_idx = key_idx; 73 priv->key_idx = key_idx;
83 74
84 priv->tfm = crypto_alloc_tfm("aes", 0); 75 priv->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
85 if (priv->tfm == NULL) { 76 if (IS_ERR(priv->tfm)) {
86 printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " 77 printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
87 "crypto API aes\n"); 78 "crypto API aes\n");
79 priv->tfm = NULL;
88 goto fail; 80 goto fail;
89 } 81 }
90 82
@@ -93,7 +85,7 @@ static void *ieee80211_ccmp_init(int key_idx)
93 fail: 85 fail:
94 if (priv) { 86 if (priv) {
95 if (priv->tfm) 87 if (priv->tfm)
96 crypto_free_tfm(priv->tfm); 88 crypto_free_cipher(priv->tfm);
97 kfree(priv); 89 kfree(priv);
98 } 90 }
99 91
@@ -104,7 +96,7 @@ static void ieee80211_ccmp_deinit(void *priv)
104{ 96{
105 struct ieee80211_ccmp_data *_priv = priv; 97 struct ieee80211_ccmp_data *_priv = priv;
106 if (_priv && _priv->tfm) 98 if (_priv && _priv->tfm)
107 crypto_free_tfm(_priv->tfm); 99 crypto_free_cipher(_priv->tfm);
108 kfree(priv); 100 kfree(priv);
109} 101}
110 102
@@ -115,7 +107,7 @@ static inline void xor_block(u8 * b, u8 * a, size_t len)
115 b[i] ^= a[i]; 107 b[i] ^= a[i];
116} 108}
117 109
118static void ccmp_init_blocks(struct crypto_tfm *tfm, 110static void ccmp_init_blocks(struct crypto_cipher *tfm,
119 struct ieee80211_hdr_4addr *hdr, 111 struct ieee80211_hdr_4addr *hdr,
120 u8 * pn, size_t dlen, u8 * b0, u8 * auth, u8 * s0) 112 u8 * pn, size_t dlen, u8 * b0, u8 * auth, u8 * s0)
121{ 113{
@@ -377,7 +369,7 @@ static int ieee80211_ccmp_set_key(void *key, int len, u8 * seq, void *priv)
377{ 369{
378 struct ieee80211_ccmp_data *data = priv; 370 struct ieee80211_ccmp_data *data = priv;
379 int keyidx; 371 int keyidx;
380 struct crypto_tfm *tfm = data->tfm; 372 struct crypto_cipher *tfm = data->tfm;
381 373
382 keyidx = data->key_idx; 374 keyidx = data->key_idx;
383 memset(data, 0, sizeof(*data)); 375 memset(data, 0, sizeof(*data));
diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c
index 34dba0ba545d..d60ce9b49b4f 100644
--- a/net/ieee80211/ieee80211_crypt_tkip.c
+++ b/net/ieee80211/ieee80211_crypt_tkip.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>
@@ -52,7 +53,7 @@ struct ieee80211_tkip_data {
52 53
53 int key_idx; 54 int key_idx;
54 55
55 struct crypto_tfm *tfm_arc4; 56 struct crypto_blkcipher *tfm_arc4;
56 struct crypto_tfm *tfm_michael; 57 struct crypto_tfm *tfm_michael;
57 58
58 /* scratch buffers for virt_to_page() (crypto API) */ 59 /* scratch buffers for virt_to_page() (crypto API) */
@@ -85,10 +86,12 @@ static void *ieee80211_tkip_init(int key_idx)
85 86
86 priv->key_idx = key_idx; 87 priv->key_idx = key_idx;
87 88
88 priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0); 89 priv->tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
89 if (priv->tfm_arc4 == NULL) { 90 CRYPTO_ALG_ASYNC);
91 if (IS_ERR(priv->tfm_arc4)) {
90 printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " 92 printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
91 "crypto API arc4\n"); 93 "crypto API arc4\n");
94 priv->tfm_arc4 = NULL;
92 goto fail; 95 goto fail;
93 } 96 }
94 97
@@ -106,7 +109,7 @@ static void *ieee80211_tkip_init(int key_idx)
106 if (priv->tfm_michael) 109 if (priv->tfm_michael)
107 crypto_free_tfm(priv->tfm_michael); 110 crypto_free_tfm(priv->tfm_michael);
108 if (priv->tfm_arc4) 111 if (priv->tfm_arc4)
109 crypto_free_tfm(priv->tfm_arc4); 112 crypto_free_blkcipher(priv->tfm_arc4);
110 kfree(priv); 113 kfree(priv);
111 } 114 }
112 115
@@ -119,7 +122,7 @@ static void ieee80211_tkip_deinit(void *priv)
119 if (_priv && _priv->tfm_michael) 122 if (_priv && _priv->tfm_michael)
120 crypto_free_tfm(_priv->tfm_michael); 123 crypto_free_tfm(_priv->tfm_michael);
121 if (_priv && _priv->tfm_arc4) 124 if (_priv && _priv->tfm_arc4)
122 crypto_free_tfm(_priv->tfm_arc4); 125 crypto_free_blkcipher(_priv->tfm_arc4);
123 kfree(priv); 126 kfree(priv);
124} 127}
125 128
@@ -318,6 +321,7 @@ static int ieee80211_tkip_hdr(struct sk_buff *skb, int hdr_len,
318static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) 321static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
319{ 322{
320 struct ieee80211_tkip_data *tkey = priv; 323 struct ieee80211_tkip_data *tkey = priv;
324 struct blkcipher_desc desc = { .tfm = tkey->tfm_arc4 };
321 int len; 325 int len;
322 u8 rc4key[16], *pos, *icv; 326 u8 rc4key[16], *pos, *icv;
323 u32 crc; 327 u32 crc;
@@ -351,18 +355,17 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
351 icv[2] = crc >> 16; 355 icv[2] = crc >> 16;
352 icv[3] = crc >> 24; 356 icv[3] = crc >> 24;
353 357
354 crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); 358 crypto_blkcipher_setkey(tkey->tfm_arc4, rc4key, 16);
355 sg.page = virt_to_page(pos); 359 sg.page = virt_to_page(pos);
356 sg.offset = offset_in_page(pos); 360 sg.offset = offset_in_page(pos);
357 sg.length = len + 4; 361 sg.length = len + 4;
358 crypto_cipher_encrypt(tkey->tfm_arc4, &sg, &sg, len + 4); 362 return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
359
360 return 0;
361} 363}
362 364
363static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) 365static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
364{ 366{
365 struct ieee80211_tkip_data *tkey = priv; 367 struct ieee80211_tkip_data *tkey = priv;
368 struct blkcipher_desc desc = { .tfm = tkey->tfm_arc4 };
366 u8 rc4key[16]; 369 u8 rc4key[16];
367 u8 keyidx, *pos; 370 u8 keyidx, *pos;
368 u32 iv32; 371 u32 iv32;
@@ -434,11 +437,18 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
434 437
435 plen = skb->len - hdr_len - 12; 438 plen = skb->len - hdr_len - 12;
436 439
437 crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); 440 crypto_blkcipher_setkey(tkey->tfm_arc4, rc4key, 16);
438 sg.page = virt_to_page(pos); 441 sg.page = virt_to_page(pos);
439 sg.offset = offset_in_page(pos); 442 sg.offset = offset_in_page(pos);
440 sg.length = plen + 4; 443 sg.length = plen + 4;
441 crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4); 444 if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
445 if (net_ratelimit()) {
446 printk(KERN_DEBUG ": TKIP: failed to decrypt "
447 "received packet from " MAC_FMT "\n",
448 MAC_ARG(hdr->addr2));
449 }
450 return -7;
451 }
442 452
443 crc = ~crc32_le(~0, pos, plen); 453 crc = ~crc32_le(~0, pos, plen);
444 icv[0] = crc; 454 icv[0] = crc;
@@ -619,7 +629,7 @@ static int ieee80211_tkip_set_key(void *key, int len, u8 * seq, void *priv)
619 struct ieee80211_tkip_data *tkey = priv; 629 struct ieee80211_tkip_data *tkey = priv;
620 int keyidx; 630 int keyidx;
621 struct crypto_tfm *tfm = tkey->tfm_michael; 631 struct crypto_tfm *tfm = tkey->tfm_michael;
622 struct crypto_tfm *tfm2 = tkey->tfm_arc4; 632 struct crypto_blkcipher *tfm2 = tkey->tfm_arc4;
623 633
624 keyidx = tkey->key_idx; 634 keyidx = tkey->key_idx;
625 memset(tkey, 0, sizeof(*tkey)); 635 memset(tkey, 0, sizeof(*tkey));
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;