crypto/openssl: add aes-xts support

Message ID 20230418230947.240459-1-michael.leung@bloombase.com (mailing list archive)
State Changes Requested, archived
Delegated to: akhil goyal
Headers
Series crypto/openssl: add aes-xts support |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional fail Functional Testing issues
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS

Commit Message

Michael Leung April 18, 2023, 11:09 p.m. UTC
  Add aes-128-xts and aes-256-xts support for crypto openssl pmd. As xts mode we got 2 key, the key length is multiplied by two, i.e. 32 and 64.

Signed-off-by: Michael Leung <michael.leung@bloombase.com>
---
 drivers/crypto/openssl/openssl_pmd_private.h |  2 +-
 drivers/crypto/openssl/rte_openssl_pmd.c     | 13 +++++++++++++
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 20 ++++++++++++++++++++
 3 files changed, 34 insertions(+), 1 deletion(-)
  

Comments

Akhil Goyal June 14, 2023, 6:50 p.m. UTC | #1
> Add aes-128-xts and aes-256-xts support for crypto openssl pmd. As xts mode
> we got 2 key, the key length is multiplied by two, i.e. 32 and 64.
> 
> Signed-off-by: Michael Leung <michael.leung@bloombase.com>
> ---
Fix checkpatch issues
Also update doc/guides/cryptodevs/features/openssl.ini
  
Akhil Goyal June 14, 2023, 6:51 p.m. UTC | #2
++Kai for review.

> -----Original Message-----
> From: Akhil Goyal
> Sent: Thursday, June 15, 2023 12:21 AM
> To: Michael Leung <michael.leung@bloombase.com>; dev@dpdk.org
> Subject: RE: [EXT] [PATCH] crypto/openssl: add aes-xts support
> 
> > Add aes-128-xts and aes-256-xts support for crypto openssl pmd. As xts mode
> > we got 2 key, the key length is multiplied by two, i.e. 32 and 64.
> >
> > Signed-off-by: Michael Leung <michael.leung@bloombase.com>
> > ---
> Fix checkpatch issues
> Also update doc/guides/cryptodevs/features/openssl.ini
  
Ji, Kai June 15, 2023, 4:45 p.m. UTC | #3
Please take time to address Akhill's comments.

Acked-by: Kai Ji <kai.ji@intel.com<mailto:kai.ji@intel.com>>
  

Patch

diff --git a/drivers/crypto/openssl/openssl_pmd_private.h b/drivers/crypto/openssl/openssl_pmd_private.h
index ed6841e460..85a8316edc 100644
--- a/drivers/crypto/openssl/openssl_pmd_private.h
+++ b/drivers/crypto/openssl/openssl_pmd_private.h
@@ -103,7 +103,7 @@  struct openssl_session {
 		/**< cipher algorithm */
 
 		struct {
-			uint8_t data[32];
+			uint8_t data[64];
 			/**< key data */
 			size_t length;
 			/**< key length in bytes */
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 384d262621..e9cbc60da7 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -240,6 +240,18 @@  get_cipher_algo(enum rte_crypto_cipher_algorithm sess_algo, size_t keylen,
 				res = -EINVAL;
 			}
 			break;
+		case RTE_CRYPTO_CIPHER_AES_XTS:
+			switch (keylen) {
+			case 32:
+				*algo = EVP_aes_128_xts();
+				break;
+			case 64:
+				*algo = EVP_aes_256_xts();
+				break;
+			default:
+				res = -EINVAL;
+			}
+			break;
 		default:
 			res = -EINVAL;
 			break;
@@ -483,6 +495,7 @@  openssl_set_session_cipher_parameters(struct openssl_session *sess,
 	case RTE_CRYPTO_CIPHER_3DES_CBC:
 	case RTE_CRYPTO_CIPHER_AES_CBC:
 	case RTE_CRYPTO_CIPHER_AES_CTR:
+	case RTE_CRYPTO_CIPHER_AES_XTS:
 		sess->cipher.mode = OPENSSL_CIPHER_LIB;
 		sess->cipher.algo = xform->cipher.algo;
 		sess->cipher.ctx = EVP_CIPHER_CTX_new();
diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index 29ad1b9505..c016b1926f 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -309,6 +309,26 @@  static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
 			}, }
 		}, }
 	},
+	{	/* AES XTS */
+		.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+		{.sym = {
+			.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
+			{.cipher = {
+				.algo = RTE_CRYPTO_CIPHER_AES_XTS,
+				.block_size = 16,
+				.key_size = {
+					.min = 32,
+					.max = 64,
+					.increment = 32	// only 32 & 64 (128/256-bit)
+				},
+				.iv_size = {
+					.min = 16,
+					.max = 16,
+					.increment = 0
+				}
+			}, }
+		}, }
+	},
 	{	/* AES GCM */
 		.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
 		{.sym = {