Skip to contentSkip to conversation

crypto: marvell: cesa: ECB does not IV

PATCH In review Corentin Labbe 2 participants 4 messages Apr 13, 2022 – Apr 21, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 crypto: marvell: cesa: ECB does not IV

The DES3 ECB has an IV size set but ECB does not need one.

Fixes 4ada483978237 ("crypto: marvell/cesa - add Triple-DES support")
---
 drivers/crypto/marvell/cesa/cipher.c | 1 -
 1 file changed, 1 deletion(-)
drivers/crypto/marvell/cesa/cipher.c +0 -1
index b739d3b873dc..c6f2fa753b7c 100644
@@ -624,7 +624,6 @@ struct skcipher_alg mv_cesa_ecb_des3_ede_alg = {
 	.decrypt = mv_cesa_ecb_des3_ede_decrypt,
 	.min_keysize = DES3_EDE_KEY_SIZE,
 	.max_keysize = DES3_EDE_KEY_SIZE,
-	.ivsize = DES3_EDE_BLOCK_SIZE,
 	.base = {
 		.cra_name = "ecb(des3_ede)",
 		.cra_driver_name = "mv-ecb-des3-ede",
Signature · 1 line
2.35.1
#1 lore raw

PATCH 2/2 crypto: marvell: cesa: Add fallback for handling empty length case

The driver does not handle case where cryptlen is zero and fail crypto selftests. So let's add a fallback for this case.

Fixes f63601fd616ab ("crypto: marvell/cesa - add a new driver for Marvell's CESA")
---
 drivers/crypto/marvell/Kconfig       |  4 ++
 drivers/crypto/marvell/cesa/cesa.h   | 12 +++--
 drivers/crypto/marvell/cesa/cipher.c | 69 ++++++++++++++++++++++++----
 3 files changed, 72 insertions(+), 13 deletions(-)
drivers/crypto/marvell/Kconfig +4 -0
index a48591af12d0..6d8a625e2208 100644
@@ -13,6 +13,10 @@ config CRYPTO_DEV_MARVELL_CESA
 	select CRYPTO_SKCIPHER
 	select CRYPTO_HASH
 	select SRAM
+	select CRYPTO_ECB
+	select CRYPTO_CBC
+	select CRYPTO_DES
+	select CRYPTO_AES
 	select CRYPTO_DEV_MARVELL
 	help
 	  This driver allows you to utilize the Cryptographic Engines and
drivers/crypto/marvell/cesa/cesa.h +8 -4
index d215a6bed6bc..93736eed19f1 100644
@@ -487,12 +487,14 @@ struct mv_cesa_req_ops {
 
 /**
  * struct mv_cesa_ctx - CESA operation context
- * @ops:	crypto operations
+ * @ops:		crypto operations
+ * @fallback_tfm:	pointer to the fallback TFM
  *
  * Base context structure inherited by operation specific ones.
  */
 struct mv_cesa_ctx {
 	const struct mv_cesa_req_ops *ops;
+	struct crypto_skcipher *fallback_tfm;
 };
 
 /**
@@ -563,15 +565,17 @@ struct mv_cesa_skcipher_std_req {
 
 /**
  * struct mv_cesa_skcipher_req - cipher request
- * @req:	type specific request information
- * @src_nents:	number of entries in the src sg list
- * @dst_nents:	number of entries in the dest sg list
+ * @req:		type specific request information
+ * @src_nents:		number of entries in the src sg list
+ * @dst_nents:		number of entries in the dest sg list
+ * @fallback_req:	request struct for invoking the fallback skcipher TFM
  */
 struct mv_cesa_skcipher_req {
 	struct mv_cesa_req base;
 	struct mv_cesa_skcipher_std_req std;
 	int src_nents;
 	int dst_nents;
+	struct skcipher_request fallback_req;   // keep at the end
 };
 
 /**
drivers/crypto/marvell/cesa/cipher.c +60 -9

143 lines not on this page · raw message

Signature · 1 line
2.35.1
maintainer
#2 lore raw

Re: [PATCH 2/2] crypto: marvell: cesa: Add fallback for handling empty length case

Quoted 2 lines · Corentin Labbe

The driver does not handle case where cryptlen is zero and fail crypto selftests. So let's add a fallback for this case.

Wouldn't it be easier to just handle this in the software? After all, a zero encryption/decryption is just a no-op, right?

Thanks,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer
#3 lore raw
In reply to Corentin Labbe
Quoted 7 lines · Corentin Labbe

The DES3 ECB has an IV size set but ECB does not need one.

Fixes 4ada483978237 ("crypto: marvell/cesa - add Triple-DES support")
---
 drivers/crypto/marvell/cesa/cipher.c | 1 -
 1 file changed, 1 deletion(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt