linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Stephan Müller" <smueller@chronox.de>
To: herbert@gondor.apana.org.au
Cc: linux-crypto@vger.kernel.org
Subject: [PATCH 12/13] crypto: nx - copy AAD during encryption
Date: Tue, 10 Jan 2017 02:40:32 +0100	[thread overview]
Message-ID: <6034656.8T7AjXVcWL@positron.chronox.de> (raw)
In-Reply-To: <10526995.lyZ7Je1KMx@positron.chronox.de>

Invoke the crypto_aead_copy_ad function during the encryption code path
to copy the AAD from the source to the destination buffer.

Signed-off-by: Stephan Mueller <smueller@chronox.de>
---
 drivers/crypto/nx/nx-aes-ccm.c |  4 ++++
 drivers/crypto/nx/nx-aes-gcm.c | 10 ++++++++++
 2 files changed, 14 insertions(+)

diff --git a/drivers/crypto/nx/nx-aes-ccm.c b/drivers/crypto/nx/nx-aes-ccm.c
index 7038f36..ee570bf 100644
--- a/drivers/crypto/nx/nx-aes-ccm.c
+++ b/drivers/crypto/nx/nx-aes-ccm.c
@@ -428,6 +428,10 @@ static int ccm_nx_encrypt(struct aead_request   *req,
 	unsigned int processed = 0, to_process;
 	int rc = -1;
 
+	rc = crypto_aead_copy_ad(req);
+	if (rc)
+		return rc;
+
 	spin_lock_irqsave(&nx_ctx->lock, irq_flags);
 
 	rc = generate_pat(desc->info, req, nx_ctx, authsize, nbytes, assoclen,
diff --git a/drivers/crypto/nx/nx-aes-gcm.c b/drivers/crypto/nx/nx-aes-gcm.c
index abd465f..0cc0533 100644
--- a/drivers/crypto/nx/nx-aes-gcm.c
+++ b/drivers/crypto/nx/nx-aes-gcm.c
@@ -432,9 +432,14 @@ static int gcm_aes_nx_encrypt(struct aead_request *req)
 {
 	struct nx_gcm_rctx *rctx = aead_request_ctx(req);
 	char *iv = rctx->iv;
+	int err;
 
 	memcpy(iv, req->iv, 12);
 
+	err = crypto_aead_copy_ad(req);
+	if (err)
+		return err;
+
 	return gcm_aes_nx_crypt(req, 1, req->assoclen);
 }
 
@@ -455,6 +460,7 @@ static int gcm4106_aes_nx_encrypt(struct aead_request *req)
 	struct nx_gcm_rctx *rctx = aead_request_ctx(req);
 	char *iv = rctx->iv;
 	char *nonce = nx_ctx->priv.gcm.nonce;
+	int err;
 
 	memcpy(iv, nonce, NX_GCM4106_NONCE_LEN);
 	memcpy(iv + NX_GCM4106_NONCE_LEN, req->iv, 8);
@@ -462,6 +468,10 @@ static int gcm4106_aes_nx_encrypt(struct aead_request *req)
 	if (req->assoclen < 8)
 		return -EINVAL;
 
+	err = crypto_aead_copy_ad(req);
+	if (err)
+		return err;
+
 	return gcm_aes_nx_crypt(req, 1, req->assoclen - 8);
 }
 
-- 
2.9.3

  parent reply	other threads:[~2017-01-10  1:42 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-10  1:36 [PATCH 00/13] crypto: copy AAD during encrypt for AEAD ciphers Stephan Müller
2017-01-10  1:36 ` [PATCH 01/13] crypto: service function to copy AAD from src to dst Stephan Müller
2017-01-10  1:37 ` [PATCH 02/13] crypto: gcm_generic - copy AAD during encryption Stephan Müller
2017-01-10  1:37 ` [PATCH 03/13] crypto: ccm_generic " Stephan Müller
2017-01-10  1:37 ` [PATCH 04/13] crypto: rfc4106-gcm-aesni " Stephan Müller
2017-01-10  1:38 ` [PATCH 05/13] crypto: ccm-aes-ce " Stephan Müller
2017-01-10  1:38 ` [PATCH 06/13] crypto: talitos " Stephan Müller
2017-01-10  1:38 ` [PATCH 07/13] crypto: picoxcell " Stephan Müller
2017-01-10  1:39 ` [PATCH 08/13] crypto: ixp4xx " Stephan Müller
2017-01-10  1:39 ` [PATCH 09/13] crypto: atmel " Stephan Müller
2017-01-10  1:39 ` [PATCH 10/13] crypto: caam " Stephan Müller
2017-01-10  1:40 ` [PATCH 11/13] crypto: chelsio " Stephan Müller
2017-01-10  1:40 ` Stephan Müller [this message]
2017-01-10  1:41 ` [PATCH 13/13] crypto: qat " Stephan Müller
2017-01-12  6:19 ` [PATCH 00/13] crypto: copy AAD during encrypt for AEAD ciphers Herbert Xu
2017-01-12 11:22   ` Stephan Müller
2017-01-12 14:57     ` Herbert Xu
2017-01-12 15:23       ` Stephan Müller
2017-01-12 15:27         ` Herbert Xu
2017-01-12 15:34           ` Stephan Müller
2017-01-12 15:39             ` Herbert Xu
2017-01-12 15:50               ` Stephan Müller
2017-01-12 15:53                 ` Herbert Xu
2017-01-12 16:01                   ` Stephan Müller
2017-01-12 16:06                     ` Herbert Xu
2017-01-12 16:37                       ` Stephan Müller
2017-01-13 10:23                         ` Herbert Xu
2017-01-13 10:58                           ` Stephan Müller
2017-01-13 11:04                             ` Herbert Xu
2017-01-13 11:12                               ` Stephan Müller
2017-01-13 11:14                                 ` Herbert Xu
2017-01-13 11:19                                   ` Stephan Müller
2017-01-13 11:26                                     ` Herbert Xu
2017-01-13 11:30                                       ` Stephan Müller
2017-01-13 11:33                                         ` Herbert Xu
2017-01-13 11:36                                           ` Stephan Müller
2017-01-13 11:39                                             ` Herbert Xu
2017-01-20 17:07                                               ` Cyrille Pitchen
2017-01-20 20:28                                                 ` Stephan Müller
2017-01-23 13:10                                                 ` Herbert Xu
2017-01-12 12:43   ` Stephan Müller
2017-01-18 14:57 ` Cyrille Pitchen

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=6034656.8T7AjXVcWL@positron.chronox.de \
    --to=smueller@chronox.de \
    --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).