From: Steffen Klassert <steffen.klassert@secunet.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: David Miller <davem@davemloft.net>, linux-crypto@vger.kernel.org
Subject: [RFC] [PATCH v2 4/4] esp: Use pcrypt if it is selected as software crypto accelerator
Date: Fri, 24 Apr 2009 12:29:26 +0200 [thread overview]
Message-ID: <20090424102926.GF12680@secunet.com> (raw)
In-Reply-To: <20090424102451.GB12680@secunet.com>
This patch adds a function that sets up the format string for
authenc algorithms. If pcrypt is coosen as accelerator,
the format string is set up to use pcrypt. If no accelerator
is choosen, the default format string is set up.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/ipv4/esp4.c | 40 ++++++++++++++++++++++++++++++++++++----
net/ipv6/esp6.c | 40 ++++++++++++++++++++++++++++++++++++----
2 files changed, 72 insertions(+), 8 deletions(-)
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 18bb383..bff5609 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -467,6 +467,40 @@ error:
return err;
}
+static int esp_authenc_name(struct xfrm_state *x, char *authenc_name)
+{
+ struct xfrm_accl *accl = x->accl;
+ int err = 0;
+
+ if (!accl) {
+ if (snprintf(authenc_name, CRYPTO_MAX_ALG_NAME,
+ "authenc(%s,%s)",
+ x->aalg ? x->aalg->alg_name : "digest_null",
+ x->ealg->alg_name) >= CRYPTO_MAX_ALG_NAME)
+ err = -ENAMETOOLONG;
+
+ goto out;
+ }
+
+ /* Set aead as the default accl type if type is unspecified */
+ if (!accl->type)
+ accl->type |= XFRM_ACCL_AEAD;
+
+ if (!strcmp(accl->name, "pcrypt") && (accl->type & XFRM_ACCL_AEAD)) {
+ if (snprintf(authenc_name, CRYPTO_MAX_ALG_NAME,
+ "pcrypt(authenc(%s,eseqiv(%s)))",
+ x->aalg ? x->aalg->alg_name : "digest_null",
+ x->ealg->alg_name) >= CRYPTO_MAX_ALG_NAME)
+ err = -ENAMETOOLONG;
+
+ goto out;
+ }
+
+ err = -EINVAL;
+out:
+ return err;
+}
+
static int esp_init_authenc(struct xfrm_state *x)
{
struct esp_data *esp = x->data;
@@ -483,10 +517,8 @@ static int esp_init_authenc(struct xfrm_state *x)
if (x->ealg == NULL)
goto error;
- err = -ENAMETOOLONG;
- if (snprintf(authenc_name, CRYPTO_MAX_ALG_NAME, "authenc(%s,%s)",
- x->aalg ? x->aalg->alg_name : "digest_null",
- x->ealg->alg_name) >= CRYPTO_MAX_ALG_NAME)
+ err = esp_authenc_name(x, authenc_name);
+ if (err)
goto error;
aead = crypto_alloc_aead(authenc_name, 0, 0);
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index c2f2501..ac5ab90 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -410,6 +410,40 @@ error:
return err;
}
+static int esp_authenc_name(struct xfrm_state *x, char *authenc_name)
+{
+ struct xfrm_accl *accl = x->accl;
+ int err = 0;
+
+ if (!accl) {
+ if (snprintf(authenc_name, CRYPTO_MAX_ALG_NAME,
+ "authenc(%s,%s)",
+ x->aalg ? x->aalg->alg_name : "digest_null",
+ x->ealg->alg_name) >= CRYPTO_MAX_ALG_NAME)
+ err = -ENAMETOOLONG;
+
+ goto out;
+ }
+
+ /* Set aead as the default accl type if type is unspecified */
+ if (!accl->type)
+ accl->type |= XFRM_ACCL_AEAD;
+
+ if (!strcmp(accl->name, "pcrypt") && (accl->type & XFRM_ACCL_AEAD)) {
+ if (snprintf(authenc_name, CRYPTO_MAX_ALG_NAME,
+ "pcrypt(authenc(%s,eseqiv(%s)))",
+ x->aalg ? x->aalg->alg_name : "digest_null",
+ x->ealg->alg_name) >= CRYPTO_MAX_ALG_NAME)
+ err = -ENAMETOOLONG;
+
+ goto out;
+ }
+
+ err = -EINVAL;
+out:
+ return err;
+}
+
static int esp_init_authenc(struct xfrm_state *x)
{
struct esp_data *esp = x->data;
@@ -426,10 +460,8 @@ static int esp_init_authenc(struct xfrm_state *x)
if (x->ealg == NULL)
goto error;
- err = -ENAMETOOLONG;
- if (snprintf(authenc_name, CRYPTO_MAX_ALG_NAME, "authenc(%s,%s)",
- x->aalg ? x->aalg->alg_name : "digest_null",
- x->ealg->alg_name) >= CRYPTO_MAX_ALG_NAME)
+ err = esp_authenc_name(x, authenc_name);
+ if (err)
goto error;
aead = crypto_alloc_aead(authenc_name, 0, 0);
--
1.5.4.2
next prev parent reply other threads:[~2009-04-24 10:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-24 10:24 [RFC] [PATCH v2 0/4] Parallel IPsec Steffen Klassert
2009-04-24 10:26 ` [RFC] [PATCH v2 1/4] padata: generic interface for parallel processing Steffen Klassert
2009-04-27 8:56 ` Herbert Xu
2009-04-24 10:27 ` [RFC] [PATCH v2 2/4] pcrypt: Add pcrypt crypto parallelization engine Steffen Klassert
2009-04-27 8:56 ` Herbert Xu
2009-04-28 6:23 ` Steffen Klassert
2009-04-28 6:31 ` Herbert Xu
2009-04-28 6:41 ` Steffen Klassert
2009-04-24 10:28 ` [RFC] [PATCH v2 3/4] xfrm: Add a netlink attribute for software crypto accelerators Steffen Klassert
2009-04-27 8:53 ` Herbert Xu
2009-04-28 10:11 ` Steffen Klassert
2009-04-24 10:29 ` Steffen Klassert [this message]
2009-04-25 8:38 ` [RFC] [PATCH v2 0/4] Parallel IPsec Evgeniy Polyakov
2009-04-25 9:21 ` Herbert Xu
2009-04-25 10:10 ` Evgeniy Polyakov
2009-04-25 10:56 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090424102926.GF12680@secunet.com \
--to=steffen.klassert@secunet.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.