All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: caam - fix DKP detection logic
@ 2019-05-03 12:05 Horia Geantă
  2019-05-06  6:39 ` [v2 PATCH] " Herbert Xu
  0 siblings, 1 reply; 8+ messages in thread
From: Horia Geantă @ 2019-05-03 12:05 UTC (permalink / raw)
  To: Herbert Xu
  Cc: David S. Miller, Aymen Sghaier, linux-crypto, NXP Linux Team,
	Iuliana Prodan

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-06-03 12:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-03 12:05 [PATCH] crypto: caam - fix DKP detection logic Horia Geantă
2019-05-06  6:39 ` [v2 PATCH] " 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.