[IPSEC]: Use HMAC template and hash interface
[deliverable/linux.git] / net / xfrm / xfrm_algo.c
index 6ed3302312fb56f0ebb2784b9990df6dca740865..87918f281bb436b1dcab4aa4a0a6f98b87a9958f 100644 (file)
@@ -9,7 +9,6 @@
  * any later version.
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/pfkeyv2.h>
@@ -31,7 +30,8 @@
  */
 static struct xfrm_algo_desc aalg_list[] = {
 {
-       .name = "digest_null",
+       .name = "hmac(digest_null)",
+       .compat = "digest_null",
        
        .uinfo = {
                .auth = {
@@ -48,7 +48,8 @@ static struct xfrm_algo_desc aalg_list[] = {
        }
 },
 {
-       .name = "md5",
+       .name = "hmac(md5)",
+       .compat = "md5",
 
        .uinfo = {
                .auth = {
@@ -65,7 +66,8 @@ static struct xfrm_algo_desc aalg_list[] = {
        }
 },
 {
-       .name = "sha1",
+       .name = "hmac(sha1)",
+       .compat = "sha1",
 
        .uinfo = {
                .auth = {
@@ -82,7 +84,8 @@ static struct xfrm_algo_desc aalg_list[] = {
        }
 },
 {
-       .name = "sha256",
+       .name = "hmac(sha256)",
+       .compat = "sha256",
 
        .uinfo = {
                .auth = {
@@ -99,7 +102,8 @@ static struct xfrm_algo_desc aalg_list[] = {
        }
 },
 {
-       .name = "ripemd160",
+       .name = "hmac(ripemd160)",
+       .compat = "ripemd160",
 
        .uinfo = {
                .auth = {
@@ -119,7 +123,8 @@ static struct xfrm_algo_desc aalg_list[] = {
 
 static struct xfrm_algo_desc ealg_list[] = {
 {
-       .name = "cipher_null",
+       .name = "ecb(cipher_null)",
+       .compat = "cipher_null",
        
        .uinfo = {
                .encr = {
@@ -136,7 +141,8 @@ static struct xfrm_algo_desc ealg_list[] = {
        }
 },
 {
-       .name = "des",
+       .name = "cbc(des)",
+       .compat = "des",
 
        .uinfo = {
                .encr = {
@@ -153,7 +159,8 @@ static struct xfrm_algo_desc ealg_list[] = {
        }
 },
 {
-       .name = "des3_ede",
+       .name = "cbc(des3_ede)",
+       .compat = "des3_ede",
 
        .uinfo = {
                .encr = {
@@ -170,7 +177,8 @@ static struct xfrm_algo_desc ealg_list[] = {
        }
 },
 {
-       .name = "cast128",
+       .name = "cbc(cast128)",
+       .compat = "cast128",
 
        .uinfo = {
                .encr = {
@@ -187,7 +195,8 @@ static struct xfrm_algo_desc ealg_list[] = {
        }
 },
 {
-       .name = "blowfish",
+       .name = "cbc(blowfish)",
+       .compat = "blowfish",
 
        .uinfo = {
                .encr = {
@@ -204,7 +213,8 @@ static struct xfrm_algo_desc ealg_list[] = {
        }
 },
 {
-       .name = "aes",
+       .name = "cbc(aes)",
+       .compat = "aes",
 
        .uinfo = {
                .encr = {
@@ -221,7 +231,8 @@ static struct xfrm_algo_desc ealg_list[] = {
        }
 },
 {
-        .name = "serpent",
+        .name = "cbc(serpent)",
+        .compat = "serpent",
 
         .uinfo = {
                 .encr = {
@@ -238,7 +249,8 @@ static struct xfrm_algo_desc ealg_list[] = {
         }
 },
 {
-        .name = "twofish",
+        .name = "cbc(twofish)",
+        .compat = "twofish",
                  
         .uinfo = {
                 .encr = {
@@ -360,7 +372,8 @@ static struct xfrm_algo_desc *xfrm_get_byname(struct xfrm_algo_desc *list,
                return NULL;
 
        for (i = 0; i < entries; i++) {
-               if (strcmp(name, list[i].name))
+               if (strcmp(name, list[i].name) &&
+                   (!list[i].compat || strcmp(name, list[i].compat)))
                        continue;
 
                if (list[i].available)
@@ -472,11 +485,12 @@ EXPORT_SYMBOL_GPL(xfrm_count_enc_supported);
 
 /* Move to common area: it is shared with AH. */
 
-void skb_icv_walk(const struct sk_buff *skb, struct crypto_tfm *tfm,
-                 int offset, int len, icv_update_fn_t icv_update)
+int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc,
+                int offset, int len, icv_update_fn_t icv_update)
 {
        int start = skb_headlen(skb);
        int i, copy = start - offset;
+       int err;
        struct scatterlist sg;
 
        /* Checksum header. */
@@ -488,10 +502,12 @@ void skb_icv_walk(const struct sk_buff *skb, struct crypto_tfm *tfm,
                sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE;
                sg.length = copy;
                
-               icv_update(tfm, &sg, 1);
+               err = icv_update(desc, &sg, copy);
+               if (unlikely(err))
+                       return err;
                
                if ((len -= copy) == 0)
-                       return;
+                       return 0;
                offset += copy;
        }
 
@@ -511,10 +527,12 @@ void skb_icv_walk(const struct sk_buff *skb, struct crypto_tfm *tfm,
                        sg.offset = frag->page_offset + offset-start;
                        sg.length = copy;
                        
-                       icv_update(tfm, &sg, 1);
+                       err = icv_update(desc, &sg, copy);
+                       if (unlikely(err))
+                               return err;
 
                        if (!(len -= copy))
-                               return;
+                               return 0;
                        offset += copy;
                }
                start = end;
@@ -532,15 +550,19 @@ void skb_icv_walk(const struct sk_buff *skb, struct crypto_tfm *tfm,
                        if ((copy = end - offset) > 0) {
                                if (copy > len)
                                        copy = len;
-                               skb_icv_walk(list, tfm, offset-start, copy, icv_update);
+                               err = skb_icv_walk(list, desc, offset-start,
+                                                  copy, icv_update);
+                               if (unlikely(err))
+                                       return err;
                                if ((len -= copy) == 0)
-                                       return;
+                                       return 0;
                                offset += copy;
                        }
                        start = end;
                }
        }
        BUG_ON(len);
+       return 0;
 }
 EXPORT_SYMBOL_GPL(skb_icv_walk);
 
This page took 0.032866 seconds and 5 git commands to generate.