[PATCH] crypto: caam - fix DKP detection logic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---

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




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux