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 5/5] authenc: Add support for the pcrypt aead wrapper
Date: Wed, 13 May 2009 15:10:37 +0200 [thread overview]
Message-ID: <20090513131037.GI20366@secunet.com> (raw)
In-Reply-To: <20090513130618.GD20366@secunet.com>
This adds support for aead wrapper templates. An aead wrapper
can be coosen via a module parameter. For the moment only
pcrypt is supported.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
crypto/authenc.c | 33 +++++++++++++++++++++++++++++++--
1 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/crypto/authenc.c b/crypto/authenc.c
index 5793b64..aaa0fcc 100644
--- a/crypto/authenc.c
+++ b/crypto/authenc.c
@@ -13,6 +13,7 @@
#include <crypto/aead.h>
#include <crypto/internal/hash.h>
#include <crypto/internal/skcipher.h>
+#include <crypto/internal/aead.h>
#include <crypto/authenc.h>
#include <crypto/scatterwalk.h>
#include <linux/err.h>
@@ -23,6 +24,10 @@
#include <linux/slab.h>
#include <linux/spinlock.h>
+static char *wrapper = NULL;
+module_param(wrapper, charp, 0);
+MODULE_PARM_DESC(wrapper, "Wrapper template for AEAD algorithms");
+
struct authenc_instance_ctx {
struct crypto_spawn auth;
struct crypto_skcipher_spawn enc;
@@ -157,15 +162,16 @@ static int crypto_authenc_genicv(struct aead_request *req, u8 *iv,
dstp = sg_page(dst);
vdst = PageHighMem(dstp) ? NULL : page_address(dstp) + dst->offset;
+ cryptlen = req->cryptlen;
- if (ivsize) {
+ if (ivsize && !(aead_request_flags(req) & CRYPTO_TFM_REQ_SG_HAS_IV)) {
sg_init_table(cipher, 2);
sg_set_buf(cipher, iv, ivsize);
authenc_chain(cipher, dst, vdst == iv + ivsize);
dst = cipher;
+ cryptlen += ivsize;
}
- cryptlen = req->cryptlen + ivsize;
hash = crypto_authenc_hash(req, flags, dst, cryptlen);
if (IS_ERR(hash))
return PTR_ERR(hash);
@@ -369,6 +375,26 @@ static void crypto_authenc_exit_tfm(struct crypto_tfm *tfm)
crypto_free_ablkcipher(ctx->enc);
}
+static int crypto_authenc_set_wrapper(struct crypto_instance *inst)
+{
+ int err = 0;
+
+ if (!wrapper)
+ goto out;
+
+ if (!strcmp(wrapper, "pcrypt")) {
+ inst->alg.cra_type = &crypto_nivaead_type;
+ inst->alg.cra_aead.geniv = "eseqiv";
+ inst->alg.cra_aead.wrapper = "pcrypt";
+
+ goto out;
+ }
+
+ err = -EINVAL;
+out:
+ return err;
+}
+
static struct crypto_instance *crypto_authenc_alloc(struct rtattr **tb)
{
struct crypto_attr_type *algt;
@@ -452,6 +478,9 @@ static struct crypto_instance *crypto_authenc_alloc(struct rtattr **tb)
inst->alg.cra_aead.decrypt = crypto_authenc_decrypt;
inst->alg.cra_aead.givencrypt = crypto_authenc_givencrypt;
+ if (crypto_authenc_set_wrapper(inst))
+ goto err_drop_enc;
+
out:
crypto_mod_put(auth);
return inst;
--
1.5.4.2
prev parent reply other threads:[~2009-05-13 13:08 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-13 13:06 [RFC] [PATCH 0/5] Parallel IPsec v3 Steffen Klassert
2009-05-13 13:07 ` [RFC] [PATCH 1/5] padata: generic interface for parallel processing Steffen Klassert
2009-05-13 13:08 ` [RFC] [PATCH 2/5] aead: Add generic aead wrapper interface Steffen Klassert
2009-06-02 3:45 ` Herbert Xu
2009-06-02 3:50 ` Herbert Xu
2009-06-02 9:21 ` Steffen Klassert
2009-06-02 9:28 ` Herbert Xu
2009-06-03 9:32 ` Steffen Klassert
2009-06-03 9:40 ` Herbert Xu
2009-06-03 11:23 ` Steffen Klassert
2009-06-03 11:59 ` Herbert Xu
2009-06-03 12:14 ` Steffen Klassert
2009-06-03 12:14 ` Herbert Xu
2009-06-05 9:20 ` Steffen Klassert
2009-06-05 9:20 ` Herbert Xu
2009-06-05 9:34 ` Steffen Klassert
2009-06-08 5:28 ` Herbert Xu
2009-06-08 6:45 ` Steffen Klassert
2009-06-25 6:51 ` Herbert Xu
2009-06-29 11:04 ` Steffen Klassert
2009-06-29 11:59 ` Herbert Xu
2009-06-29 13:52 ` Steffen Klassert
2009-06-29 13:55 ` [PATCH 1/2] padata: generic interface for parallel processing Steffen Klassert
2009-06-29 13:57 ` [PATCH 2/2] pcrypt: Add pcrypt crypto parallelization wrapper Steffen Klassert
2009-08-19 7:15 ` [RFC] [PATCH 2/5] aead: Add generic aead wrapper interface Steffen Klassert
2009-08-31 5:58 ` Herbert Xu
2009-08-31 8:45 ` Steffen Klassert
2009-05-13 13:08 ` [RFC] [PATCH 3/5] pcrypt: Add pcrypt crypto parallelization wrapper Steffen Klassert
2009-05-13 13:09 ` [RFC] [PATCH 4/5] eseqiv: Add support for aead algorithms Steffen Klassert
2009-05-13 13:10 ` Steffen Klassert [this message]
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=20090513131037.GI20366@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).