Hi:

[IPSEC]: Use HMAC template

This patch converts IPsec to use the new HMAC template.  The names of
existing simple digest algorithms may still be used to refer to their
HMAC composites.

The same structure can be used by other MACs such as AES-XCBC-MAC.

Signed-off-by: Herbert Xu <[EMAIL PROTECTED]>

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[EMAIL PROTECTED]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff --git a/include/net/ah.h b/include/net/ah.h
--- a/include/net/ah.h
+++ b/include/net/ah.h
@@ -26,9 +26,10 @@ ah_hmac_digest(struct ah_data *ahp, stru
        struct crypto_tfm *tfm = ahp->tfm;
 
        memset(auth_data, 0, ahp->icv_trunc_len);
-       crypto_hmac_init(tfm, ahp->key, &ahp->key_len);
-       skb_icv_walk(skb, tfm, 0, skb->len, crypto_hmac_update);
-       crypto_hmac_final(tfm, ahp->key, &ahp->key_len, ahp->work_icv);
+       crypto_digest_setkey(tfm, ahp->key, ahp->key_len);
+       crypto_digest_init(tfm);
+       skb_icv_walk(skb, tfm, 0, skb->len, crypto_digest_update);
+       crypto_digest_final(tfm, ahp->work_icv);
        memcpy(auth_data, ahp->work_icv, ahp->icv_trunc_len);
 }
 
diff --git a/include/net/esp.h b/include/net/esp.h
--- a/include/net/esp.h
+++ b/include/net/esp.h
@@ -50,9 +50,10 @@ esp_hmac_digest(struct esp_data *esp, st
        char *icv = esp->auth.work_icv;
 
        memset(auth_data, 0, esp->auth.icv_trunc_len);
-       crypto_hmac_init(tfm, esp->auth.key, &esp->auth.key_len);
-       skb_icv_walk(skb, tfm, offset, len, crypto_hmac_update);
-       crypto_hmac_final(tfm, esp->auth.key, &esp->auth.key_len, icv);
+       crypto_digest_setkey(tfm, esp->auth.key, esp->auth.key_len);
+       crypto_digest_init(tfm);
+       skb_icv_walk(skb, tfm, offset, len, crypto_digest_update);
+       crypto_digest_final(tfm, icv);
        memcpy(auth_data, icv, esp->auth.icv_trunc_len);
 }
 
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -855,6 +855,7 @@ struct xfrm_algo_comp_info {
 
 struct xfrm_algo_desc {
        char *name;
+       char *compat;
        u8 available:1;
        union {
                struct xfrm_algo_auth_info auth;
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c
--- a/net/xfrm/xfrm_algo.c
+++ b/net/xfrm/xfrm_algo.c
@@ -31,7 +31,8 @@
  */
 static struct xfrm_algo_desc aalg_list[] = {
 {
-       .name = "digest_null",
+       .name = "hmac(digest_null)",
+       .compat = "digest_null",
        
        .uinfo = {
                .auth = {
@@ -48,7 +49,8 @@ static struct xfrm_algo_desc aalg_list[]
        }
 },
 {
-       .name = "md5",
+       .name = "hmac(md5)",
+       .compat = "md5",
 
        .uinfo = {
                .auth = {
@@ -65,7 +67,8 @@ static struct xfrm_algo_desc aalg_list[]
        }
 },
 {
-       .name = "sha1",
+       .name = "hmac(sha1)",
+       .compat = "sha1",
 
        .uinfo = {
                .auth = {
@@ -82,7 +85,8 @@ static struct xfrm_algo_desc aalg_list[]
        }
 },
 {
-       .name = "sha256",
+       .name = "hmac(sha256)",
+       .compat = "sha256",
 
        .uinfo = {
                .auth = {
@@ -99,7 +103,8 @@ static struct xfrm_algo_desc aalg_list[]
        }
 },
 {
-       .name = "ripemd160",
+       .name = "hmac(ripemd160)",
+       .compat = "ripemd160",
 
        .uinfo = {
                .auth = {
@@ -360,7 +365,8 @@ static struct xfrm_algo_desc *xfrm_get_b
                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)
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -212,6 +212,7 @@ static int attach_one_algo(struct xfrm_a
                return -ENOMEM;
 
        memcpy(p, ualg, len);
+       strcpy(p->alg_name, algo->name);
        *algpp = p;
        return 0;
 }
-
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to