From: Lokesh Vutla <lokeshvutla@ti.com>
To: <herbert@gondor.apana.org.au>, <linux-crypto@vger.kernel.org>,
<davem@davemloft.net>
Cc: <linux-omap@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<t-kristo@ti.com>, <nsekhar@ti.com>, <lokeshvutla@ti.com>
Subject: [PATCH 06/10] crypto: omap-aes: gcm: Handle inputs properly
Date: Thu, 2 Jul 2015 10:48:36 +0530 [thread overview]
Message-ID: <1435814320-30347-7-git-send-email-lokeshvutla@ti.com> (raw)
In-Reply-To: <1435814320-30347-1-git-send-email-lokeshvutla@ti.com>
Its not necessary that assoc data and plain text is passed always.
Add these checks before processing the input.
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
drivers/crypto/omap-aes-gcm.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/drivers/crypto/omap-aes-gcm.c b/drivers/crypto/omap-aes-gcm.c
index 1be9d91..72815af 100644
--- a/drivers/crypto/omap-aes-gcm.c
+++ b/drivers/crypto/omap-aes-gcm.c
@@ -87,7 +87,7 @@ static int omap_aes_gcm_copy_buffers(struct omap_aes_dev *dd,
struct aead_request *req)
{
void *buf_in;
- int alen, clen;
+ int alen, clen, nsg;
struct crypto_aead *aead = crypto_aead_reqtfm(req);
unsigned int authlen = crypto_aead_authsize(aead);
u32 dec = !(dd->flags & FLAGS_ENCRYPT);
@@ -97,12 +97,18 @@ static int omap_aes_gcm_copy_buffers(struct omap_aes_dev *dd,
dd->sgs_copied = 0;
- sg_init_table(dd->in_sgl, 2);
- buf_in = sg_virt(req->assoc);
- sg_set_buf(dd->in_sgl, buf_in, alen);
+ nsg = 1 + !!(req->assoclen && req->cryptlen);
- buf_in = sg_virt(req->src);
- sg_set_buf(&dd->in_sgl[1], buf_in, clen);
+ sg_init_table(dd->in_sgl, nsg);
+ if (req->assoclen) {
+ buf_in = sg_virt(req->assoc);
+ sg_set_buf(dd->in_sgl, buf_in, alen);
+ }
+
+ if (req->cryptlen) {
+ buf_in = sg_virt(req->src);
+ sg_set_buf(&dd->in_sgl[nsg - 1], buf_in, clen);
+ }
dd->in_sg = dd->in_sgl;
dd->total = clen;
@@ -258,6 +264,8 @@ static int omap_aes_gcm_crypt(struct aead_request *req, unsigned long mode)
{
struct omap_aes_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req));
struct omap_aes_reqctx *rctx = aead_request_ctx(req);
+ struct crypto_aead *aead = crypto_aead_reqtfm(req);
+ unsigned int authlen = crypto_aead_authsize(aead);
struct omap_aes_dev *dd;
__be32 counter = cpu_to_be32(1);
int err;
@@ -270,6 +278,12 @@ static int omap_aes_gcm_crypt(struct aead_request *req, unsigned long mode)
if (err)
return err;
+ if (req->assoclen + req->cryptlen == 0) {
+ scatterwalk_map_and_copy(ctx->auth_tag, req->dst, 0, authlen,
+ 1);
+ return 0;
+ }
+
dd = omap_aes_find_dev(ctx);
if (!dd)
return -ENODEV;
--
1.7.9.5
next prev parent reply other threads:[~2015-07-02 5:22 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-02 5:18 [PATCH 00/10] crypto: omap-aes: Add support for GCM mode Lokesh Vutla
2015-07-02 5:18 ` [PATCH 01/10] crypto: omap-aes: Add support for lengths not aligned with AES_BLOCK_SIZE Lokesh Vutla
2015-07-02 7:53 ` Felipe Balbi
2015-07-02 9:26 ` Lokesh Vutla
2015-07-06 7:38 ` Herbert Xu
2015-07-02 5:18 ` [PATCH 02/10] crypto: omap-aes: Fix configuring of AES mode Lokesh Vutla
2015-07-02 7:57 ` Felipe Balbi
2015-07-02 9:43 ` Lokesh Vutla
2015-07-02 5:18 ` [PATCH 03/10] crypto: aead: Add aead_request_cast() api Lokesh Vutla
2015-07-02 7:58 ` Felipe Balbi
2015-07-02 9:46 ` Lokesh Vutla
2015-07-06 7:41 ` Herbert Xu
2015-07-02 5:18 ` [PATCH 04/10] crypto: omap-aes: Use BIT() macro Lokesh Vutla
2015-07-02 7:59 ` Felipe Balbi
2015-07-06 7:42 ` Herbert Xu
2015-07-02 5:18 ` [PATCH 05/10] crypto: omap-aes: Add support for GCM mode Lokesh Vutla
2015-07-02 8:04 ` Felipe Balbi
2015-07-02 10:10 ` Lokesh Vutla
2015-07-02 5:18 ` Lokesh Vutla [this message]
2015-07-02 8:04 ` [PATCH 06/10] crypto: omap-aes: gcm: Handle inputs properly Felipe Balbi
2015-07-02 10:13 ` Lokesh Vutla
2015-07-02 5:18 ` [PATCH 07/10] crypto: omap-aes: gcm: Add support for unaligned lengths Lokesh Vutla
2015-07-02 8:05 ` Felipe Balbi
2015-07-02 5:18 ` [PATCH 08/10] crypto: omap-aes: gmc: Add algo info Lokesh Vutla
2015-07-02 8:00 ` Stephan Mueller
2015-07-02 9:54 ` Lokesh Vutla
2015-07-02 9:56 ` Stephan Mueller
2015-07-06 7:35 ` Herbert Xu
2015-07-06 8:15 ` Lokesh Vutla
2015-07-02 5:18 ` [PATCH 09/10] crypto: omap-aes: gcm: Add support for PIO mode Lokesh Vutla
2015-07-02 8:06 ` Felipe Balbi
2015-07-02 10:17 ` Lokesh Vutla
2015-07-02 5:18 ` [PATCH 10/10] crypto: tcrypt: Added speed tests for Async AEAD crypto alogrithms Lokesh Vutla
2015-07-06 7:44 ` Herbert Xu
2015-07-06 8:45 ` Lokesh Vutla
2015-07-06 8:49 ` 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=1435814320-30347-7-git-send-email-lokeshvutla@ti.com \
--to=lokeshvutla@ti.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=nsekhar@ti.com \
--cc=t-kristo@ti.com \
/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
all inboxes | Powered by JetHome®