diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2006-09-23 08:34:10 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2006-09-23 08:34:10 -0400 |
commit | 919251758195919ae3568021bc221e4f8c4b20eb (patch) | |
tree | 81137a037ff8e6c91cc8de72d568275605c653c5 /net/xfrm | |
parent | c394f1eafef61c6666f5876afde6110a276c4c9f (diff) | |
parent | 3eeab61aa3ddd3c0bedb7449ada1599de22fdb5a (diff) |
Merge branch 'mainline' into upstream-linus
Diffstat (limited to 'net/xfrm')
-rw-r--r-- | net/xfrm/xfrm_algo.c | 94 | ||||
-rw-r--r-- | net/xfrm/xfrm_user.c | 2 |
2 files changed, 65 insertions, 31 deletions
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c index 04e1aea58bc9..5a0dbeb6bbe8 100644 --- a/net/xfrm/xfrm_algo.c +++ b/net/xfrm/xfrm_algo.c | |||
@@ -30,7 +30,8 @@ | |||
30 | */ | 30 | */ |
31 | static struct xfrm_algo_desc aalg_list[] = { | 31 | static struct xfrm_algo_desc aalg_list[] = { |
32 | { | 32 | { |
33 | .name = "digest_null", | 33 | .name = "hmac(digest_null)", |
34 | .compat = "digest_null", | ||
34 | 35 | ||
35 | .uinfo = { | 36 | .uinfo = { |
36 | .auth = { | 37 | .auth = { |
@@ -47,7 +48,8 @@ static struct xfrm_algo_desc aalg_list[] = { | |||
47 | } | 48 | } |
48 | }, | 49 | }, |
49 | { | 50 | { |
50 | .name = "md5", | 51 | .name = "hmac(md5)", |
52 | .compat = "md5", | ||
51 | 53 | ||
52 | .uinfo = { | 54 | .uinfo = { |
53 | .auth = { | 55 | .auth = { |
@@ -64,7 +66,8 @@ static struct xfrm_algo_desc aalg_list[] = { | |||
64 | } | 66 | } |
65 | }, | 67 | }, |
66 | { | 68 | { |
67 | .name = "sha1", | 69 | .name = "hmac(sha1)", |
70 | .compat = "sha1", | ||
68 | 71 | ||
69 | .uinfo = { | 72 | .uinfo = { |
70 | .auth = { | 73 | .auth = { |
@@ -81,7 +84,8 @@ static struct xfrm_algo_desc aalg_list[] = { | |||
81 | } | 84 | } |
82 | }, | 85 | }, |
83 | { | 86 | { |
84 | .name = "sha256", | 87 | .name = "hmac(sha256)", |
88 | .compat = "sha256", | ||
85 | 89 | ||
86 | .uinfo = { | 90 | .uinfo = { |
87 | .auth = { | 91 | .auth = { |
@@ -98,7 +102,8 @@ static struct xfrm_algo_desc aalg_list[] = { | |||
98 | } | 102 | } |
99 | }, | 103 | }, |
100 | { | 104 | { |
101 | .name = "ripemd160", | 105 | .name = "hmac(ripemd160)", |
106 | .compat = "ripemd160", | ||
102 | 107 | ||
103 | .uinfo = { | 108 | .uinfo = { |
104 | .auth = { | 109 | .auth = { |
@@ -118,7 +123,8 @@ static struct xfrm_algo_desc aalg_list[] = { | |||
118 | 123 | ||
119 | static struct xfrm_algo_desc ealg_list[] = { | 124 | static struct xfrm_algo_desc ealg_list[] = { |
120 | { | 125 | { |
121 | .name = "cipher_null", | 126 | .name = "ecb(cipher_null)", |
127 | .compat = "cipher_null", | ||
122 | 128 | ||
123 | .uinfo = { | 129 | .uinfo = { |
124 | .encr = { | 130 | .encr = { |
@@ -135,7 +141,8 @@ static struct xfrm_algo_desc ealg_list[] = { | |||
135 | } | 141 | } |
136 | }, | 142 | }, |
137 | { | 143 | { |
138 | .name = "des", | 144 | .name = "cbc(des)", |
145 | .compat = "des", | ||
139 | 146 | ||
140 | .uinfo = { | 147 | .uinfo = { |
141 | .encr = { | 148 | .encr = { |
@@ -152,7 +159,8 @@ static struct xfrm_algo_desc ealg_list[] = { | |||
152 | } | 159 | } |
153 | }, | 160 | }, |
154 | { | 161 | { |
155 | .name = "des3_ede", | 162 | .name = "cbc(des3_ede)", |
163 | .compat = "des3_ede", | ||
156 | 164 | ||
157 | .uinfo = { | 165 | .uinfo = { |
158 | .encr = { | 166 | .encr = { |
@@ -169,7 +177,8 @@ static struct xfrm_algo_desc ealg_list[] = { | |||
169 | } | 177 | } |
170 | }, | 178 | }, |
171 | { | 179 | { |
172 | .name = "cast128", | 180 | .name = "cbc(cast128)", |
181 | .compat = "cast128", | ||
173 | 182 | ||
174 | .uinfo = { | 183 | .uinfo = { |
175 | .encr = { | 184 | .encr = { |
@@ -186,7 +195,8 @@ static struct xfrm_algo_desc ealg_list[] = { | |||
186 | } | 195 | } |
187 | }, | 196 | }, |
188 | { | 197 | { |
189 | .name = "blowfish", | 198 | .name = "cbc(blowfish)", |
199 | .compat = "blowfish", | ||
190 | 200 | ||
191 | .uinfo = { | 201 | .uinfo = { |
192 | .encr = { | 202 | .encr = { |
@@ -203,7 +213,8 @@ static struct xfrm_algo_desc ealg_list[] = { | |||
203 | } | 213 | } |
204 | }, | 214 | }, |
205 | { | 215 | { |
206 | .name = "aes", | 216 | .name = "cbc(aes)", |
217 | .compat = "aes", | ||
207 | 218 | ||
208 | .uinfo = { | 219 | .uinfo = { |
209 | .encr = { | 220 | .encr = { |
@@ -220,7 +231,8 @@ static struct xfrm_algo_desc ealg_list[] = { | |||
220 | } | 231 | } |
221 | }, | 232 | }, |
222 | { | 233 | { |
223 | .name = "serpent", | 234 | .name = "cbc(serpent)", |
235 | .compat = "serpent", | ||
224 | 236 | ||
225 | .uinfo = { | 237 | .uinfo = { |
226 | .encr = { | 238 | .encr = { |
@@ -237,7 +249,8 @@ static struct xfrm_algo_desc ealg_list[] = { | |||
237 | } | 249 | } |
238 | }, | 250 | }, |
239 | { | 251 | { |
240 | .name = "twofish", | 252 | .name = "cbc(twofish)", |
253 | .compat = "twofish", | ||
241 | 254 | ||
242 | .uinfo = { | 255 | .uinfo = { |
243 | .encr = { | 256 | .encr = { |
@@ -350,8 +363,8 @@ struct xfrm_algo_desc *xfrm_calg_get_byid(int alg_id) | |||
350 | EXPORT_SYMBOL_GPL(xfrm_calg_get_byid); | 363 | EXPORT_SYMBOL_GPL(xfrm_calg_get_byid); |
351 | 364 | ||
352 | static struct xfrm_algo_desc *xfrm_get_byname(struct xfrm_algo_desc *list, | 365 | static struct xfrm_algo_desc *xfrm_get_byname(struct xfrm_algo_desc *list, |
353 | int entries, char *name, | 366 | int entries, u32 type, u32 mask, |
354 | int probe) | 367 | char *name, int probe) |
355 | { | 368 | { |
356 | int i, status; | 369 | int i, status; |
357 | 370 | ||
@@ -359,7 +372,8 @@ static struct xfrm_algo_desc *xfrm_get_byname(struct xfrm_algo_desc *list, | |||
359 | return NULL; | 372 | return NULL; |
360 | 373 | ||
361 | for (i = 0; i < entries; i++) { | 374 | for (i = 0; i < entries; i++) { |
362 | if (strcmp(name, list[i].name)) | 375 | if (strcmp(name, list[i].name) && |
376 | (!list[i].compat || strcmp(name, list[i].compat))) | ||
363 | continue; | 377 | continue; |
364 | 378 | ||
365 | if (list[i].available) | 379 | if (list[i].available) |
@@ -368,7 +382,7 @@ static struct xfrm_algo_desc *xfrm_get_byname(struct xfrm_algo_desc *list, | |||
368 | if (!probe) | 382 | if (!probe) |
369 | break; | 383 | break; |
370 | 384 | ||
371 | status = crypto_alg_available(name, 0); | 385 | status = crypto_has_alg(name, type, mask | CRYPTO_ALG_ASYNC); |
372 | if (!status) | 386 | if (!status) |
373 | break; | 387 | break; |
374 | 388 | ||
@@ -380,19 +394,25 @@ static struct xfrm_algo_desc *xfrm_get_byname(struct xfrm_algo_desc *list, | |||
380 | 394 | ||
381 | struct xfrm_algo_desc *xfrm_aalg_get_byname(char *name, int probe) | 395 | struct xfrm_algo_desc *xfrm_aalg_get_byname(char *name, int probe) |
382 | { | 396 | { |
383 | return xfrm_get_byname(aalg_list, aalg_entries(), name, probe); | 397 | return xfrm_get_byname(aalg_list, aalg_entries(), |
398 | CRYPTO_ALG_TYPE_HASH, CRYPTO_ALG_TYPE_HASH_MASK, | ||
399 | name, probe); | ||
384 | } | 400 | } |
385 | EXPORT_SYMBOL_GPL(xfrm_aalg_get_byname); | 401 | EXPORT_SYMBOL_GPL(xfrm_aalg_get_byname); |
386 | 402 | ||
387 | struct xfrm_algo_desc *xfrm_ealg_get_byname(char *name, int probe) | 403 | struct xfrm_algo_desc *xfrm_ealg_get_byname(char *name, int probe) |
388 | { | 404 | { |
389 | return xfrm_get_byname(ealg_list, ealg_entries(), name, probe); | 405 | return xfrm_get_byname(ealg_list, ealg_entries(), |
406 | CRYPTO_ALG_TYPE_BLKCIPHER, CRYPTO_ALG_TYPE_MASK, | ||
407 | name, probe); | ||
390 | } | 408 | } |
391 | EXPORT_SYMBOL_GPL(xfrm_ealg_get_byname); | 409 | EXPORT_SYMBOL_GPL(xfrm_ealg_get_byname); |
392 | 410 | ||
393 | struct xfrm_algo_desc *xfrm_calg_get_byname(char *name, int probe) | 411 | struct xfrm_algo_desc *xfrm_calg_get_byname(char *name, int probe) |
394 | { | 412 | { |
395 | return xfrm_get_byname(calg_list, calg_entries(), name, probe); | 413 | return xfrm_get_byname(calg_list, calg_entries(), |
414 | CRYPTO_ALG_TYPE_COMPRESS, CRYPTO_ALG_TYPE_MASK, | ||
415 | name, probe); | ||
396 | } | 416 | } |
397 | EXPORT_SYMBOL_GPL(xfrm_calg_get_byname); | 417 | EXPORT_SYMBOL_GPL(xfrm_calg_get_byname); |
398 | 418 | ||
@@ -427,19 +447,22 @@ void xfrm_probe_algs(void) | |||
427 | BUG_ON(in_softirq()); | 447 | BUG_ON(in_softirq()); |
428 | 448 | ||
429 | for (i = 0; i < aalg_entries(); i++) { | 449 | for (i = 0; i < aalg_entries(); i++) { |
430 | status = crypto_alg_available(aalg_list[i].name, 0); | 450 | status = crypto_has_hash(aalg_list[i].name, 0, |
451 | CRYPTO_ALG_ASYNC); | ||
431 | if (aalg_list[i].available != status) | 452 | if (aalg_list[i].available != status) |
432 | aalg_list[i].available = status; | 453 | aalg_list[i].available = status; |
433 | } | 454 | } |
434 | 455 | ||
435 | for (i = 0; i < ealg_entries(); i++) { | 456 | for (i = 0; i < ealg_entries(); i++) { |
436 | status = crypto_alg_available(ealg_list[i].name, 0); | 457 | status = crypto_has_blkcipher(ealg_list[i].name, 0, |
458 | CRYPTO_ALG_ASYNC); | ||
437 | if (ealg_list[i].available != status) | 459 | if (ealg_list[i].available != status) |
438 | ealg_list[i].available = status; | 460 | ealg_list[i].available = status; |
439 | } | 461 | } |
440 | 462 | ||
441 | for (i = 0; i < calg_entries(); i++) { | 463 | for (i = 0; i < calg_entries(); i++) { |
442 | status = crypto_alg_available(calg_list[i].name, 0); | 464 | status = crypto_has_comp(calg_list[i].name, 0, |
465 | CRYPTO_ALG_ASYNC); | ||
443 | if (calg_list[i].available != status) | 466 | if (calg_list[i].available != status) |
444 | calg_list[i].available = status; | 467 | calg_list[i].available = status; |
445 | } | 468 | } |
@@ -471,11 +494,12 @@ EXPORT_SYMBOL_GPL(xfrm_count_enc_supported); | |||
471 | 494 | ||
472 | /* Move to common area: it is shared with AH. */ | 495 | /* Move to common area: it is shared with AH. */ |
473 | 496 | ||
474 | void skb_icv_walk(const struct sk_buff *skb, struct crypto_tfm *tfm, | 497 | int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc, |
475 | int offset, int len, icv_update_fn_t icv_update) | 498 | int offset, int len, icv_update_fn_t icv_update) |
476 | { | 499 | { |
477 | int start = skb_headlen(skb); | 500 | int start = skb_headlen(skb); |
478 | int i, copy = start - offset; | 501 | int i, copy = start - offset; |
502 | int err; | ||
479 | struct scatterlist sg; | 503 | struct scatterlist sg; |
480 | 504 | ||
481 | /* Checksum header. */ | 505 | /* Checksum header. */ |
@@ -487,10 +511,12 @@ void skb_icv_walk(const struct sk_buff *skb, struct crypto_tfm *tfm, | |||
487 | sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE; | 511 | sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE; |
488 | sg.length = copy; | 512 | sg.length = copy; |
489 | 513 | ||
490 | icv_update(tfm, &sg, 1); | 514 | err = icv_update(desc, &sg, copy); |
515 | if (unlikely(err)) | ||
516 | return err; | ||
491 | 517 | ||
492 | if ((len -= copy) == 0) | 518 | if ((len -= copy) == 0) |
493 | return; | 519 | return 0; |
494 | offset += copy; | 520 | offset += copy; |
495 | } | 521 | } |
496 | 522 | ||
@@ -510,10 +536,12 @@ void skb_icv_walk(const struct sk_buff *skb, struct crypto_tfm *tfm, | |||
510 | sg.offset = frag->page_offset + offset-start; | 536 | sg.offset = frag->page_offset + offset-start; |
511 | sg.length = copy; | 537 | sg.length = copy; |
512 | 538 | ||
513 | icv_update(tfm, &sg, 1); | 539 | err = icv_update(desc, &sg, copy); |
540 | if (unlikely(err)) | ||
541 | return err; | ||
514 | 542 | ||
515 | if (!(len -= copy)) | 543 | if (!(len -= copy)) |
516 | return; | 544 | return 0; |
517 | offset += copy; | 545 | offset += copy; |
518 | } | 546 | } |
519 | start = end; | 547 | start = end; |
@@ -531,15 +559,19 @@ void skb_icv_walk(const struct sk_buff *skb, struct crypto_tfm *tfm, | |||
531 | if ((copy = end - offset) > 0) { | 559 | if ((copy = end - offset) > 0) { |
532 | if (copy > len) | 560 | if (copy > len) |
533 | copy = len; | 561 | copy = len; |
534 | skb_icv_walk(list, tfm, offset-start, copy, icv_update); | 562 | err = skb_icv_walk(list, desc, offset-start, |
563 | copy, icv_update); | ||
564 | if (unlikely(err)) | ||
565 | return err; | ||
535 | if ((len -= copy) == 0) | 566 | if ((len -= copy) == 0) |
536 | return; | 567 | return 0; |
537 | offset += copy; | 568 | offset += copy; |
538 | } | 569 | } |
539 | start = end; | 570 | start = end; |
540 | } | 571 | } |
541 | } | 572 | } |
542 | BUG_ON(len); | 573 | BUG_ON(len); |
574 | return 0; | ||
543 | } | 575 | } |
544 | EXPORT_SYMBOL_GPL(skb_icv_walk); | 576 | EXPORT_SYMBOL_GPL(skb_icv_walk); |
545 | 577 | ||
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 3e6a722d072e..fa79ddc4239e 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c | |||
@@ -10,6 +10,7 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/crypto.h> | ||
13 | #include <linux/module.h> | 14 | #include <linux/module.h> |
14 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
15 | #include <linux/types.h> | 16 | #include <linux/types.h> |
@@ -212,6 +213,7 @@ static int attach_one_algo(struct xfrm_algo **algpp, u8 *props, | |||
212 | return -ENOMEM; | 213 | return -ENOMEM; |
213 | 214 | ||
214 | memcpy(p, ualg, len); | 215 | memcpy(p, ualg, len); |
216 | strcpy(p->alg_name, algo->name); | ||
215 | *algpp = p; | 217 | *algpp = p; |
216 | return 0; | 218 | return 0; |
217 | } | 219 | } |