diff options
Diffstat (limited to 'drivers/net/ppp_mppe.c')
-rw-r--r-- | drivers/net/ppp_mppe.c | 32 |
1 files changed, 19 insertions, 13 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 | */ |
97 | struct ppp_mppe_state { | 98 | struct 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 = { | |||
694 | static int __init ppp_mppe_init(void) | 700 | static 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 | ||