linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Horia Geantă" <horia.geanta@nxp.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@davemloft.net>,
	Aymen Sghaier <aymen.sghaier@nxp.com>,
	Franck Lenormand <franck.lenormand@nxp.com>,
	Dan Douglass <dan.douglass@nxp.com>,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	NXP Linux Team <linux-imx@nxp.com>
Subject: [PATCH 3/7] crypto: caam/qi2 - create ahash shared descriptors only once
Date: Wed, 22 Jul 2020 15:14:54 +0300	[thread overview]
Message-ID: <20200722121458.8478-4-horia.geanta@nxp.com> (raw)
In-Reply-To: <20200722121458.8478-1-horia.geanta@nxp.com>

For keyed hash algorithms, shared descriptors are currently generated
twice:
-at tfm initialization time, in cra_init() callback
-in setkey() callback

Since it's mandatory to call setkey() for keyed algorithms, drop the
generation in cra_init().

This is similar to the change in caamhash (caam/jr top-level library)
commit 9a2537d0ebc9 ("crypto: caam - create ahash shared descriptors only once")

Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---
 drivers/crypto/caam/caamalg_qi2.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/caam/caamalg_qi2.c b/drivers/crypto/caam/caamalg_qi2.c
index 811d34eee4f2..1e901344db67 100644
--- a/drivers/crypto/caam/caamalg_qi2.c
+++ b/drivers/crypto/caam/caamalg_qi2.c
@@ -4500,7 +4500,11 @@ static int caam_hash_cra_init(struct crypto_tfm *tfm)
 	crypto_ahash_set_reqsize(__crypto_ahash_cast(tfm),
 				 sizeof(struct caam_hash_state));
 
-	return ahash_set_sh_desc(ahash);
+	/*
+	 * For keyed hash algorithms shared descriptors
+	 * will be created later in setkey() callback
+	 */
+	return alg->setkey ? 0 : ahash_set_sh_desc(ahash);
 }
 
 static void caam_hash_cra_exit(struct crypto_tfm *tfm)
-- 
2.17.1


  parent reply	other threads:[~2020-07-22 12:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-22 12:14 [PATCH 0/7] crypto: caam - updates for 5.9 Horia Geantă
2020-07-22 12:14 ` [PATCH 1/7] crypto: caam - remove deadcode on 32-bit platforms Horia Geantă
2020-07-22 12:14 ` [PATCH 2/7] crypto: caam/qi2 - fix error reporting for caam_hash_alloc Horia Geantă
2020-07-22 12:14 ` Horia Geantă [this message]
2020-07-22 12:14 ` [PATCH 4/7] crypto: caam - silence .setkey in case of bad key length Horia Geantă
2020-07-22 12:14 ` [PATCH 5/7] crypto: caam/jr - remove incorrect reference to caam_jr_register() Horia Geantă
2020-07-22 12:14 ` [PATCH 6/7] crypto: caam - add more RNG hw error codes Horia Geantă
2020-07-22 12:25   ` Horia Geantă
2020-07-22 12:14 ` [PATCH 7/7] crypto: caam/qi2 - add module alias Horia Geantă
2020-07-31 13:30 ` [PATCH 0/7] crypto: caam - updates for 5.9 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=20200722121458.8478-4-horia.geanta@nxp.com \
    --to=horia.geanta@nxp.com \
    --cc=aymen.sghaier@nxp.com \
    --cc=dan.douglass@nxp.com \
    --cc=davem@davemloft.net \
    --cc=franck.lenormand@nxp.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@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).