From patchwork Wed Sep 28 13:18:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arkadiusz Kusztal X-Patchwork-Id: 117064 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BA741A00C4; Wed, 28 Sep 2022 16:27:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 59767427F1; Wed, 28 Sep 2022 16:27:19 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 6CCE041140 for ; Wed, 28 Sep 2022 16:27:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664375236; x=1695911236; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=GuJlP9j+mAeDjv1natHHb4L+wuR914xXdFLTbxBuNmg=; b=NvnoWQuPv99XTSk6q1yrTAkBtDDLTs4F9Je6L+7jiKQ1XoZeP6/ku6C3 JKdSTObcsKQtr01YoksToU5+043/Bcvkt98fe3esNfDrL6XPdiarEMrKT 2h0MMFkcN4MDtGZGpED/TLep7NfNB+fcTU5EzrsR7EpWu7vcMn7sLDJGp b9dabB/UVfnP5Xk2mHUGyfuHD6ENx/ME3i8IVmxqo5lS3QHjGGzP0Qaem 7SFarQvFgRAdjdueOUXS0l6CEVKfHMXAuQP+UpQxnOK1wNwbxK5AwqkCx QQ+0itOxyA38FZlPBMtccZgkrQVGlfv5RYN7dhpldIWzTvlenLQX+ThnD A==; X-IronPort-AV: E=McAfee;i="6500,9779,10484"; a="281331396" X-IronPort-AV: E=Sophos;i="5.93,352,1654585200"; d="scan'208";a="281331396" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2022 07:27:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10484"; a="684425694" X-IronPort-AV: E=Sophos;i="5.93,352,1654585200"; d="scan'208";a="684425694" Received: from silpixa00399302.ir.intel.com ([10.237.214.136]) by fmsmga008.fm.intel.com with ESMTP; 28 Sep 2022 07:27:08 -0700 From: Arek Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, kai.ji@intel.com, Arek Kusztal Subject: [PATCH v2 1/2] cryptodev: add sm4 encryption algorithm Date: Wed, 28 Sep 2022 14:18:00 +0100 Message-Id: <20220928131801.64467-2-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20220928131801.64467-1-arkadiuszx.kusztal@intel.com> References: <20220928131801.64467-1-arkadiuszx.kusztal@intel.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org ShangMi 4 (SM4) is a block cipher used in the Chinese National Standard for Wireless LAN WAPI and also used with Transport Layer Security. - Added SM4 encryption algorithm. Supported modes are ECB, CBC and CTR. Signed-off-by: Arek Kusztal Acked-by: Kai Ji --- doc/guides/cryptodevs/features/default.ini | 3 +++ doc/guides/rel_notes/release_22_11.rst | 4 ++++ lib/cryptodev/rte_crypto_sym.h | 9 ++++++++- lib/cryptodev/rte_cryptodev.c | 5 ++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/doc/guides/cryptodevs/features/default.ini b/doc/guides/cryptodevs/features/default.ini index 7371ca6644..1608426b12 100644 --- a/doc/guides/cryptodevs/features/default.ini +++ b/doc/guides/cryptodevs/features/default.ini @@ -61,6 +61,9 @@ DES DOCSIS BPI = SNOW3G UEA2 = KASUMI F8 = ZUC EEA3 = +SM4 ECB = +SM4 CBC = +SM4 CTR = ; ; Supported authentication algorithms of a default crypto driver. diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst index 510485017d..e8113ee056 100644 --- a/doc/guides/rel_notes/release_22_11.rst +++ b/doc/guides/rel_notes/release_22_11.rst @@ -80,6 +80,10 @@ New Features * Added ``rte_event_eth_tx_adapter_instance_get`` to get Tx adapter instance ID for specified ethernet device ID and Tx queue index. +* **Added ShangMi 4 (SM4) encryption algorithm in ECB, CBC and CTR mode to the cryptodev.** + + Added ``RTE_CRYPTO_CIPHER_SM4_ECB``, ``RTE_CRYPTO_CIPHER_SM4_CBC``, + ``RTE_CRYPTO_CIPHER_SM4_CTR`` to the cipher algorithm list in the cryptodev. Removed Items ------------- diff --git a/lib/cryptodev/rte_crypto_sym.h b/lib/cryptodev/rte_crypto_sym.h index daa090b978..613950993a 100644 --- a/lib/cryptodev/rte_crypto_sym.h +++ b/lib/cryptodev/rte_crypto_sym.h @@ -160,12 +160,19 @@ enum rte_crypto_cipher_algorithm { * for m_src and m_dst in the rte_crypto_sym_op must be NULL. */ - RTE_CRYPTO_CIPHER_DES_DOCSISBPI + RTE_CRYPTO_CIPHER_DES_DOCSISBPI, /**< DES algorithm using modes required by * DOCSIS Baseline Privacy Plus Spec. * Chained mbufs are not supported in this mode, i.e. rte_mbuf.next * for m_src and m_dst in the rte_crypto_sym_op must be NULL. */ + + RTE_CRYPTO_CIPHER_SM4_ECB, + /**< ShangMi 4 (SM4) algorithm in ECB mode */ + RTE_CRYPTO_CIPHER_SM4_CBC, + /**< ShangMi 4 (SM4) algorithm in CBC mode */ + RTE_CRYPTO_CIPHER_SM4_CTR + /**< ShangMi 4 (SM4) algorithm in CTR mode */ }; /** Cipher algorithm name strings */ diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 5e25e607fa..5622c5a735 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -89,7 +89,10 @@ rte_crypto_cipher_algorithm_strings[] = { [RTE_CRYPTO_CIPHER_KASUMI_F8] = "kasumi-f8", [RTE_CRYPTO_CIPHER_SNOW3G_UEA2] = "snow3g-uea2", - [RTE_CRYPTO_CIPHER_ZUC_EEA3] = "zuc-eea3" + [RTE_CRYPTO_CIPHER_ZUC_EEA3] = "zuc-eea3", + [RTE_CRYPTO_CIPHER_SM4_ECB] = "sm4-ecb", + [RTE_CRYPTO_CIPHER_SM4_CBC] = "sm4-cbc", + [RTE_CRYPTO_CIPHER_SM4_CTR] = "sm4-ctr" }; /**