Skip to contentSkip to conversation

crypto/ccp: sha3 support enabling in ccp

PATCH Applied [email protected] 6 participants 10 messages Jan 22, 2020 – Feb 6, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 crypto/ccp: sha3 support enabling in ccp

From: Sardar Shamsher Singh <[email protected]>

sha3 support enabled in AMD-CCP crypto controller

---
 lib/librte_cryptodev/rte_cryptodev.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
lib/librte_cryptodev/rte_cryptodev.c +10 -1
index 5c6359b5c..6ee4f1086 100644
@@ -140,7 +140,16 @@ rte_crypto_auth_algorithm_strings[] = {
 
 	[RTE_CRYPTO_AUTH_KASUMI_F9]	= "kasumi-f9",
 	[RTE_CRYPTO_AUTH_SNOW3G_UIA2]	= "snow3g-uia2",
-	[RTE_CRYPTO_AUTH_ZUC_EIA3]	= "zuc-eia3"
+	[RTE_CRYPTO_AUTH_ZUC_EIA3]	= "zuc-eia3",
+
+	[RTE_CRYPTO_AUTH_SHA3_224]	= "sha3-224",
+	[RTE_CRYPTO_AUTH_SHA3_224_HMAC]	= "sha3-224-hmac",
+	[RTE_CRYPTO_AUTH_SHA3_256]	= "sha3-256",
+	[RTE_CRYPTO_AUTH_SHA3_256_HMAC]	= "sha3-256-hmac",
+	[RTE_CRYPTO_AUTH_SHA3_384]	= "sha3-384",
+	[RTE_CRYPTO_AUTH_SHA3_384_HMAC]	= "sha3-384-hmac",
+	[RTE_CRYPTO_AUTH_SHA3_512]	= "sha3-512",
+	[RTE_CRYPTO_AUTH_SHA3_512_HMAC]	= "sha3-512-hmac"
 };
 
 /**
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 2/2 examples/crypto: crypto test application

From: Sardar Shamsher Singh <[email protected]>

test application to test Cipher/Authentication/AEAD in AMD CCP a crypto controller. This test application can be used as reference to develop/test crypto algo.

---
 doc/guides/sample_app_ug/ccp_crypto.rst | 114 +++
 examples/crypto/Makefile                |  63 ++
 examples/crypto/main.c                  | 899 ++++++++++++++++++++++++
 3 files changed, 1076 insertions(+)
 create mode 100644 doc/guides/sample_app_ug/ccp_crypto.rst
 create mode 100644 examples/crypto/Makefile
 create mode 100644 examples/crypto/main.c
doc/guides/sample_app_ug/ccp_crypto.rst new file +114 -0
new file mode 100644
index 000000000..0f56b444b
@@ -0,0 +1,114 @@
+.. SPDX-License-Identifier: BSD-3-Clause
+   Copyright(c) 2018 Advanced Micro Devices, Inc. All rights reserved.
+
+
+.. _crypto_app:
+
+Crypto Sample Application
+============================================
+
+The Crypto sample application is a simple example to test Crypto algorithm using
+CCP, the Data Plane Development Kit (DPDK), in conjunction with the Cryptodev library.
+
+Overview
+--------
+
+The Crypto sample application performs a Crypto operation (Cipher/Auth) specified by the user
+from command line, with a Crypto device (like CCP) capable of doing that operation.
+
+Compiling the Application
+-------------------------
+
+To compile the sample application see :doc:`compiling`.
+
+The application is located in the `examples/crypto` sub-directory.
+
+Running the Application
+-----------------------
+
+The application requires a number of command line options:
+
+.. code-block:: console
+
+	./build/crypto [EAL options] -- [-l core list] [-n number of channels] /
+	[--vdev "crypto_ccp"] [--cdev_type HW/SW/ANY] [--cipher_op ENCRYPT / DECRYPT] /
+	[--cipher_algo ALGO] [--plain_text ] [--cipher_key KEY] [--cipher_iv IV] /
+	[--auth_op GENERATE / VERIFY] [ --auth_algo ALGO] [--auth_key KEY] /
+	[--aead_algo ALGO] [--aead_op ENCRYPT / DECRYPT] [--aead_key KEY] [--aead_iv IV] /
+	[--aad AAD] [ --digest]
+
+
+where,
+
+* l <core list>  	: List of cores to run on
+
+* n NUM      		: Number of memory channels
+
+* vdev             : Add a virtual device
+
+* cdev_type: select preferred crypto device type: HW, SW or anything (ANY)
+
+* cipher_op: select the ciphering operation to perform: ENCRYPT or DECRYPT
+
+* cipher_algo: select the ciphering algorithm (EX: aes-cbc/aes-ecb/aes-ctr/)
+
+* cipher_key: set the ciphering key to be used. Bytes has to be separated with ":"
+
+* cipher_iv: set the cipher IV to be used. Bytes has to be separated with ":"
+
+* plain_text: set the plain text to be operated. Bytes has to be separated with ":"
+
+* auth_op: select the authentication operation to perform: GENERATE or VERIFY
+
+* auth_algo: select the authentication algorithm
+
+* auth_key: set the authentication key to be used. Bytes has to be separated with ":"
+
+* aead_algo: select the AEAD algorithm
+
+* aead_op: select the AEAD operation to perform: ENCRYPT or DECRYPT
+
+* aead_key: set the AEAD key to be used. Bytes has to be separated with ":"
+
+* aead_iv: set the AEAD IV to be used. Bytes has to be separated with ":"
+
+* aad: set the AAD to be used. Bytes has to be separated with ":"
+
+* digest : set the DIGEST values to be used. Bytes has to be separated with ":"
+
+
+The application requires that crypto devices capable of performing
+the specified crypto operation are available on application initialization.
+This means that HW crypto device/s must be bound to a DPDK driver or
+a SW crypto device/s (virtual crypto PMD) must be created (using --vdev).
+
+Below are few example to run the application in linux environment with 2 lcores,
+	4 Memory channel and 1 crypto device, issue the command:
+
+.. code-block:: console
+
+    Example 1:
+	$sudo ./build/crypto -l1,2 -n 4 --vdev "crypto_ccp" -- --cipher_op ENCRYPT \
+	--cipher_algo aes-cbc --plain_text f3:44:81:ec:3c:c6:27:ba:cd:5d:c3:fb:08:f2:73:e6 \
+	--cipher_key 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 \
+	--cipher_iv 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
+
+    Example 2:
+	$sudo ./build/crypto -l1,2 -n 4 --vdev "crypto_ccp" -- --auth_op GENERATE \
+	--auth_algo sha3-224 --plain_text 01
+
+    Example 3:
+	$sudo ./build/crypto -l1,2 -n 4 --vdev "crypto_ccp" \
+	-- --aead_op ENCRYPT --aead_algo aes-gcm \
+	--plain_text c3:b3:c4:1f:11:3a:31:b7:3d:9a:5c:d4:32:10:30:69 \
+	--aead_key c9:39:cc:13:39:7c:1d:37:de:6a:e0:e1:cb:7c:42:3c \
+	--aead_iv 01:00:00:00:e2:67:0f:9e:b3:89:bb:7c:01:cc:d8:b3 \
+	--aad 24:82:56:02:bd:12:a9:84:e0:09:2d:3e:44:8e:da:5f \
+	--digest 00:00:00:00:00:00:00:80:00:00:00:00:00:00:00:80
+
+Refer to the *DPDK Getting Started Guide* for general information on running applications
+and the Environment Abstraction Layer (EAL) options.
+
+.. Note::
+
+    * All crypto devices shall use the same session.
examples/crypto/Makefile new file +63 -0

63 lines not on this page · raw message

examples/crypto/main.c new file +899 -0

899 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] examples/crypto: crypto test application

Hi,

Quoted 9 lines

From: Sardar Shamsher Singh <[email protected]>

test application to test Cipher/Authentication/AEAD in AMD CCP a crypto controller. This test application can be used as reference to develop/test crypto algo.

---

Why do you need a separate example application to test an algo. Is it not possible to test it with app/test/test_cryptodev.c and Examples/l2fwd-crypto?

-Akhil

#3 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] examples/crypto: crypto test application

Hi Akhil,
Our app has been developed to do standalone test.
The L2fwd test need the network ports.
Therefore, this test app has been developed for quick development in standalone mode. Is there anyway to do standalone test?

Thanks & regards
S. Shamsher Singh

-----Original Message-----
From: Akhil Goyal <[email protected]>
Sent: Tuesday, January 28, 2020 12:05 PM
To: Sardar, Shamsher singh <[email protected]>; [email protected]
Cc: Kumar, Ravi1 <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 2/2] examples/crypto: crypto test application

[CAUTION: External Email]

Hi,

Quoted 9 lines

From: Sardar Shamsher Singh <[email protected]>

test application to test Cipher/Authentication/AEAD in AMD CCP a crypto controller. This test application can be used as reference to develop/test crypto algo.

---

Why do you need a separate example application to test an algo.
Is it not possible to test it with app/test/test_cryptodev.c and Examples/l2fwd-crypto?

-Akhil

#4 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] examples/crypto: crypto test application

Hi Shamsher,

Quoted 8 lines

Hi Akhil,
Our app has been developed to do standalone test.
The L2fwd test need the network ports.
Therefore, this test app has been developed for quick development in standalone mode.
Is there anyway to do standalone test?

As I mentioned below, you can use app/test/test_cryptodev.c to add your PMD in the unit test framework of DPDK and it is without network interface. This test app is for functional testing for all the supported algos. If you need to get performance data, you can add in app/test-crypto-perf

Both these are standalone applications without ethernet.

Regards,
Akhil

Quoted 15 lines

Hi,

Quoted 9 lines

From: Sardar Shamsher Singh <[email protected]>

test application to test Cipher/Authentication/AEAD in AMD CCP a crypto controller. This test application can be used as reference to develop/test crypto algo.

---

Why do you need a separate example application to test an algo.
Is it not possible to test it with app/test/test_cryptodev.c and Examples/l2fwd- crypto?

-Akhil

#5 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] examples/crypto: crypto test application

Hi Akhil,
Thanks. I was not aware of this app so developed new one. Will explore more on this.

Thanks & regards
S Shamsher Singh

-----Original Message-----
From: Akhil Goyal <[email protected]>
Sent: Thursday, January 30, 2020 2:22 PM
To: Sardar, Shamsher singh <[email protected]>; [email protected]
Cc: Kumar, Ravi1 <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 2/2] examples/crypto: crypto test application

[CAUTION: External Email]

Hi Shamsher,

Quoted 8 lines

Hi Akhil,
Our app has been developed to do standalone test.
The L2fwd test need the network ports.
Therefore, this test app has been developed for quick development in standalone mode.
Is there anyway to do standalone test?

As I mentioned below, you can use app/test/test_cryptodev.c to add your PMD in the unit test framework of DPDK and it is without network interface. This test app is for functional testing for all the supported algos.
If you need to get performance data, you can add in app/test-crypto-perf

Both these are standalone applications without ethernet.

Regards,
Akhil

Quoted 15 lines

Hi,

Quoted 9 lines

From: Sardar Shamsher Singh <[email protected]>

test application to test Cipher/Authentication/AEAD in AMD CCP a crypto controller. This test application can be used as reference to develop/test crypto algo.

---

Why do you need a separate example application to test an algo. Is it not possible to test it with app/test/test_cryptodev.c and Examples/l2fwd- crypto?

-Akhil

Acked-by on v2 1/2
#6 lore raw
In reply to [email protected]

[AMD Official Use Only - Internal Distribution Only]

For series,

Regards,
Ravi

Quoted 41 lines

-----Original Message-----
From: Sardar, Shamsher singh <[email protected]>
Sent: Wednesday, January 22, 2020 4:22 PM
To: [email protected]
Cc: Kumar, Ravi1 <[email protected]>
Subject: [PATCH v2 1/2] crypto/ccp: sha3 support enabling in ccp

From: Sardar Shamsher Singh <[email protected]>

sha3 support enabled in AMD-CCP crypto controller

---
lib/librte_cryptodev/rte_cryptodev.c | 11 ++++++++++-

1 file changed, 10 insertions(+), 1 deletion(-)
lib/librte_cryptodev/rte_cryptodev.c +10 -1
index 5c6359b5c..6ee4f1086 100644
@@ -140,7 +140,16 @@ rte_crypto_auth_algorithm_strings[] = {
 
 	[RTE_CRYPTO_AUTH_KASUMI_F9]	= "kasumi-f9",
 	[RTE_CRYPTO_AUTH_SNOW3G_UIA2]	= "snow3g-uia2",
-	[RTE_CRYPTO_AUTH_ZUC_EIA3]	= "zuc-eia3"
+	[RTE_CRYPTO_AUTH_ZUC_EIA3]	= "zuc-eia3",
+
+	[RTE_CRYPTO_AUTH_SHA3_224]	= "sha3-224",
+	[RTE_CRYPTO_AUTH_SHA3_224_HMAC]	= "sha3-224-hmac",
+	[RTE_CRYPTO_AUTH_SHA3_256]	= "sha3-256",
+	[RTE_CRYPTO_AUTH_SHA3_256_HMAC]	= "sha3-256-hmac",
+	[RTE_CRYPTO_AUTH_SHA3_384]	= "sha3-384",
+	[RTE_CRYPTO_AUTH_SHA3_384_HMAC]	= "sha3-384-hmac",
+	[RTE_CRYPTO_AUTH_SHA3_512]	= "sha3-512",
+	[RTE_CRYPTO_AUTH_SHA3_512_HMAC]	= "sha3-512-hmac"
 };
 
 /**
Signature · 1 line
2.17.1
Acked-by Ravi Kumar Acked-by Applied
#7 lore raw
Quoted 10 lines

For series,

Quoted 7 lines

From: Sardar Shamsher Singh <[email protected]>

sha3 support enabled in AMD-CCP crypto controller

---

Change patch title and description as below
cryptodev: fix missing SHA3 algo strings

SHA3 support was added earlier but algo strings were missing. This patch add the missing strings.

Fixes 1df800f89518 ("crypto/ccp: support SHA3 family")

Applied to dpdk-next-crypto

Thanks.

#8 lore raw

05/02/2020 13:24, Akhil Goyal:

Quoted 16 lines
Quoted 10 lines

For series,

Quoted 7 lines

From: Sardar Shamsher Singh <[email protected]>

sha3 support enabled in AMD-CCP crypto controller

---

Change patch title and description as below
cryptodev: fix missing SHA3 algo strings

SHA3 support was added earlier but algo strings were missing. This patch add the missing strings.

Quoted 8 lines
Fixes 1df800f89518 ("crypto/ccp: support SHA3 family")

Applied to dpdk-next-crypto

Sorry I must drop this patch because it triggers an ABI warning:
[C]'const char* rte_crypto_auth_algorithm_strings[]' was changed at rte_crypto_sym.h:320:1:
size of symbol changed from 168 to 232

I don't understand how the size of this array can impact the application, but I prefer to stay on the safe side for now.

Please let's discuss this patch in 20.02-rc3 timeframe.

#9 lore raw
Quoted 24 lines · Thomas Monjalon

05/02/2020 13:24, Akhil Goyal:

Quoted 23 lines
Quoted 10 lines

For series,

Quoted 7 lines

From: Sardar Shamsher Singh <[email protected]>

sha3 support enabled in AMD-CCP crypto controller

---

Change patch title and description as below
cryptodev: fix missing SHA3 algo strings

SHA3 support was added earlier but algo strings were missing. This patch add the missing strings.

Fixes 1df800f89518 ("crypto/ccp: support SHA3 family")
Quoted 5 lines
Quoted 1 line

Applied to dpdk-next-crypto

Sorry I must drop this patch because it triggers an ABI warning:
[C]'const char* rte_crypto_auth_algorithm_strings[]' was changed at rte_crypto_sym.h:320:1:
size of symbol changed from 168 to 232

This is still not clear to me, but here is how I understand the issue.

An exposed array (and its size) ends up in both the shared library and the final binary data section.

[dmarchan@wsfd-netdev66 dpdk]$ readelf -sW ~/builds/build-gcc-shared/app/dpdk-test-crypto-perf |grep rte_crypto_auth_algorithm_strings

    86: 00000000004141a0   168 OBJECT  GLOBAL DEFAULT   24

rte_crypto_auth_algorithm_strings@DPDK_20.0 (4)
308: 00000000004141a0 168 OBJECT GLOBAL DEFAULT 24
rte_crypto_auth_algorithm_strings@@DPDK_20.0 [dmarchan@wsfd-netdev66 dpdk]$ readelf -sW ~/builds/build-gcc-shared/lib/librte_cryptodev.so |grep rte_crypto_auth_algorithm_strings

    57: 000000000000b220   168 OBJECT  GLOBAL DEFAULT   23

rte_crypto_auth_algorithm_strings@@DPDK_20.0
158: 000000000000b220 168 OBJECT GLOBAL DEFAULT 23
rte_crypto_auth_algorithm_strings

At runtime, the linker chooses to rewire all access to the final binary data section, not the shared library local representation.

Now, if we update the array size, the shared library code is built with the assumption of the increased size.
But at runtime with an "old" binary, the shared library code runs with a shorter array, with potential out of bound access.

Interesting article:
https://developers.redhat.com/blog/2019/05/06/how-c-array-sizes-become-part-of-the-binary-interface-of-a-library/

Signature · 1 line
David Marchand