Linux cryptographic layer development
 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>,
	linux-crypto@vger.kernel.org, NXP Linux Team <linux-imx@nxp.com>,
	Iuliana Prodan <iuliana.prodan@nxp.com>
Subject: [PATCH] crypto: caam - fix DKP detection logic
Date: Fri,  3 May 2019 15:05:48 +0300	[thread overview]
Message-ID: <20190503120548.5576-1-horia.geanta@nxp.com> (raw)

The detection whether DKP (Derived Key Protocol) is used relies on
the setkey callback.
Since "aead_setkey" was replaced in some cases with "des3_aead_setkey"
(for 3DES weak key checking), the logic has to be updated - otherwise
the DMA mapping direction is incorrect (leading to faults in case caam
is behind an IOMMU).

Fixes: 1b52c40919e6 ("crypto: caam - Forbid 2-key 3DES in FIPS mode")
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---

This issue was noticed when testing with previously submitted IOMMU support:
https://patchwork.kernel.org/project/linux-crypto/list/?series=110277&state=*

 drivers/crypto/caam/caamalg.c     | 3 ++-
 drivers/crypto/caam/caamalg_qi.c  | 3 ++-
 drivers/crypto/caam/caamalg_qi2.c | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
index 0030cee3e75d..015fca99d867 100644
--- a/drivers/crypto/caam/caamalg.c
+++ b/drivers/crypto/caam/caamalg.c
@@ -3418,7 +3418,8 @@ static int caam_aead_init(struct crypto_aead *tfm)
 	struct caam_ctx *ctx = crypto_aead_ctx(tfm);
 
 	return caam_init_common(ctx, &caam_alg->caam,
-				alg->setkey == aead_setkey);
+				alg->setkey == aead_setkey ||
+				alg->setkey == des3_aead_setkey);
 }
 
 static void caam_exit_common(struct caam_ctx *ctx)
diff --git a/drivers/crypto/caam/caamalg_qi.c b/drivers/crypto/caam/caamalg_qi.c
index 70af211d2d01..4d98f5664d3e 100644
--- a/drivers/crypto/caam/caamalg_qi.c
+++ b/drivers/crypto/caam/caamalg_qi.c
@@ -2434,7 +2434,8 @@ static int caam_aead_init(struct crypto_aead *tfm)
 	struct caam_ctx *ctx = crypto_aead_ctx(tfm);
 
 	return caam_init_common(ctx, &caam_alg->caam,
-				alg->setkey == aead_setkey);
+				alg->setkey == aead_setkey ||
+				alg->setkey == des3_aead_setkey);
 }
 
 static void caam_exit_common(struct caam_ctx *ctx)
diff --git a/drivers/crypto/caam/caamalg_qi2.c b/drivers/crypto/caam/caamalg_qi2.c
index 33a4df6b81de..5977e615ff10 100644
--- a/drivers/crypto/caam/caamalg_qi2.c
+++ b/drivers/crypto/caam/caamalg_qi2.c
@@ -1480,7 +1480,8 @@ static int caam_cra_init_aead(struct crypto_aead *tfm)
 
 	crypto_aead_set_reqsize(tfm, sizeof(struct caam_request));
 	return caam_cra_init(crypto_aead_ctx(tfm), &caam_alg->caam,
-			     alg->setkey == aead_setkey);
+			     alg->setkey == aead_setkey ||
+			     alg->setkey == des3_aead_setkey);
 }
 
 static void caam_exit_common(struct caam_ctx *ctx)
-- 
2.17.1


             reply	other threads:[~2019-05-03 12:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-03 12:05 Horia Geantă [this message]
2019-05-06  6:39 ` [v2 PATCH] crypto: caam - fix DKP detection logic Herbert Xu
2019-05-06  8:06   ` Horia Geanta
2019-05-30 11:36     ` Horia Geanta
2019-06-03  7:52       ` Greg Kroah-Hartman
2019-06-03  8:10         ` Horia Geanta
2019-06-03  8:42           ` Greg Kroah-Hartman
2019-06-03 12:07             ` Horia Geanta

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=20190503120548.5576-1-horia.geanta@nxp.com \
    --to=horia.geanta@nxp.com \
    --cc=aymen.sghaier@nxp.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=iuliana.prodan@nxp.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-imx@nxp.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