diff options
Diffstat (limited to 'net/xfrm/xfrm_algo.c')
-rw-r--r-- | net/xfrm/xfrm_algo.c | 113 |
1 files changed, 35 insertions, 78 deletions
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c index faf54c6bf96b..743c0134a6a9 100644 --- a/net/xfrm/xfrm_algo.c +++ b/net/xfrm/xfrm_algo.c | |||
@@ -200,6 +200,40 @@ static struct xfrm_algo_desc aalg_list[] = { | |||
200 | } | 200 | } |
201 | }, | 201 | }, |
202 | { | 202 | { |
203 | .name = "hmac(sha384)", | ||
204 | |||
205 | .uinfo = { | ||
206 | .auth = { | ||
207 | .icv_truncbits = 192, | ||
208 | .icv_fullbits = 384, | ||
209 | } | ||
210 | }, | ||
211 | |||
212 | .desc = { | ||
213 | .sadb_alg_id = SADB_X_AALG_SHA2_384HMAC, | ||
214 | .sadb_alg_ivlen = 0, | ||
215 | .sadb_alg_minbits = 384, | ||
216 | .sadb_alg_maxbits = 384 | ||
217 | } | ||
218 | }, | ||
219 | { | ||
220 | .name = "hmac(sha512)", | ||
221 | |||
222 | .uinfo = { | ||
223 | .auth = { | ||
224 | .icv_truncbits = 256, | ||
225 | .icv_fullbits = 512, | ||
226 | } | ||
227 | }, | ||
228 | |||
229 | .desc = { | ||
230 | .sadb_alg_id = SADB_X_AALG_SHA2_512HMAC, | ||
231 | .sadb_alg_ivlen = 0, | ||
232 | .sadb_alg_minbits = 512, | ||
233 | .sadb_alg_maxbits = 512 | ||
234 | } | ||
235 | }, | ||
236 | { | ||
203 | .name = "hmac(rmd160)", | 237 | .name = "hmac(rmd160)", |
204 | .compat = "rmd160", | 238 | .compat = "rmd160", |
205 | 239 | ||
@@ -365,6 +399,7 @@ static struct xfrm_algo_desc ealg_list[] = { | |||
365 | }, | 399 | }, |
366 | { | 400 | { |
367 | .name = "cbc(camellia)", | 401 | .name = "cbc(camellia)", |
402 | .compat = "camellia", | ||
368 | 403 | ||
369 | .uinfo = { | 404 | .uinfo = { |
370 | .encr = { | 405 | .encr = { |
@@ -689,84 +724,6 @@ int xfrm_count_enc_supported(void) | |||
689 | } | 724 | } |
690 | EXPORT_SYMBOL_GPL(xfrm_count_enc_supported); | 725 | EXPORT_SYMBOL_GPL(xfrm_count_enc_supported); |
691 | 726 | ||
692 | /* Move to common area: it is shared with AH. */ | ||
693 | |||
694 | int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc, | ||
695 | int offset, int len, icv_update_fn_t icv_update) | ||
696 | { | ||
697 | int start = skb_headlen(skb); | ||
698 | int i, copy = start - offset; | ||
699 | struct sk_buff *frag_iter; | ||
700 | struct scatterlist sg; | ||
701 | int err; | ||
702 | |||
703 | /* Checksum header. */ | ||
704 | if (copy > 0) { | ||
705 | if (copy > len) | ||
706 | copy = len; | ||
707 | |||
708 | sg_init_one(&sg, skb->data + offset, copy); | ||
709 | |||
710 | err = icv_update(desc, &sg, copy); | ||
711 | if (unlikely(err)) | ||
712 | return err; | ||
713 | |||
714 | if ((len -= copy) == 0) | ||
715 | return 0; | ||
716 | offset += copy; | ||
717 | } | ||
718 | |||
719 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | ||
720 | int end; | ||
721 | |||
722 | WARN_ON(start > offset + len); | ||
723 | |||
724 | end = start + skb_shinfo(skb)->frags[i].size; | ||
725 | if ((copy = end - offset) > 0) { | ||
726 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | ||
727 | |||
728 | if (copy > len) | ||
729 | copy = len; | ||
730 | |||
731 | sg_init_table(&sg, 1); | ||
732 | sg_set_page(&sg, frag->page, copy, | ||
733 | frag->page_offset + offset-start); | ||
734 | |||
735 | err = icv_update(desc, &sg, copy); | ||
736 | if (unlikely(err)) | ||
737 | return err; | ||
738 | |||
739 | if (!(len -= copy)) | ||
740 | return 0; | ||
741 | offset += copy; | ||
742 | } | ||
743 | start = end; | ||
744 | } | ||
745 | |||
746 | skb_walk_frags(skb, frag_iter) { | ||
747 | int end; | ||
748 | |||
749 | WARN_ON(start > offset + len); | ||
750 | |||
751 | end = start + frag_iter->len; | ||
752 | if ((copy = end - offset) > 0) { | ||
753 | if (copy > len) | ||
754 | copy = len; | ||
755 | err = skb_icv_walk(frag_iter, desc, offset-start, | ||
756 | copy, icv_update); | ||
757 | if (unlikely(err)) | ||
758 | return err; | ||
759 | if ((len -= copy) == 0) | ||
760 | return 0; | ||
761 | offset += copy; | ||
762 | } | ||
763 | start = end; | ||
764 | } | ||
765 | BUG_ON(len); | ||
766 | return 0; | ||
767 | } | ||
768 | EXPORT_SYMBOL_GPL(skb_icv_walk); | ||
769 | |||
770 | #if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE) | 727 | #if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE) |
771 | 728 | ||
772 | void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len) | 729 | void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len) |