patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 0/2] add zuc-256 support
@ 2022-06-03 11:18 Ankur Dwivedi
  2022-06-03 11:18 ` [PATCH 1/2] common/cnxk: swap zuc-256 key Ankur Dwivedi
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ankur Dwivedi @ 2022-06-03 11:18 UTC (permalink / raw)
  To: stable; +Cc: anoobj, gakhil, ktejasree, jerinj, Ankur Dwivedi

Adds support for zuc-256 cipher in cnxk crypto PMD.

Ankur Dwivedi (2):
  common/cnxk: swap zuc-256 key
  crypto/cnxk: swap zuc-256 iv

 drivers/common/cnxk/roc_se.c  |  7 +++++--
 drivers/common/cnxk/roc_se.h  | 22 ++++++++++++++++++++++
 drivers/crypto/cnxk/cnxk_se.h | 24 +++++++++++++-----------
 3 files changed, 40 insertions(+), 13 deletions(-)

-- 
2.28.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] common/cnxk: swap zuc-256 key
  2022-06-03 11:18 [PATCH 0/2] add zuc-256 support Ankur Dwivedi
@ 2022-06-03 11:18 ` Ankur Dwivedi
  2022-06-03 11:18 ` [PATCH 2/2] crypto/cnxk: swap zuc-256 iv Ankur Dwivedi
  2022-06-23 14:25 ` [PATCH 0/2] add zuc-256 support Kevin Traynor
  2 siblings, 0 replies; 5+ messages in thread
From: Ankur Dwivedi @ 2022-06-03 11:18 UTC (permalink / raw)
  To: stable; +Cc: anoobj, gakhil, ktejasree, jerinj, Ankur Dwivedi

The microcode expects zuc-256 key to be in reverse of what is
provided by dpdk test app. This patch swaps the zuc-256 key.

Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
Reviewed-by: Jerin Jacob Kollanukkaran <jerinj@marvell.com>
---
 drivers/common/cnxk/roc_se.c |  7 +++++--
 drivers/common/cnxk/roc_se.h | 22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/common/cnxk/roc_se.c b/drivers/common/cnxk/roc_se.c
index ffe537af30..3f0821e400 100644
--- a/drivers/common/cnxk/roc_se.c
+++ b/drivers/common/cnxk/roc_se.c
@@ -283,6 +283,8 @@ roc_se_auth_key_set(struct roc_se_ctx *se_ctx, roc_se_auth_type type,
 				return ret;
 			se_ctx->pdcp_alg_type = ROC_SE_PDCP_ALG_TYPE_ZUC;
 			memcpy(ci_key, key, key_len);
+			if (key_len == 32)
+				roc_se_zuc_bytes_swap(ci_key, key_len);
 			cpt_pdcp_update_zuc_const(zuc_const, key_len, mac_len);
 			se_ctx->fc_type = ROC_SE_PDCP;
 			se_ctx->zsk_flags = 0x1;
@@ -459,9 +461,10 @@ roc_se_ciph_key_set(struct roc_se_ctx *se_ctx, roc_se_cipher_type type,
 		zs_ctx->zuc.otk_ctx.w0.s.alg_type = ROC_SE_PDCP_ALG_TYPE_ZUC;
 		se_ctx->pdcp_alg_type = ROC_SE_PDCP_ALG_TYPE_ZUC;
 		memcpy(ci_key, key, key_len);
-		if (key_len == 32)
+		if (key_len == 32) {
+			roc_se_zuc_bytes_swap(ci_key, key_len);
 			memcpy(zuc_const, zuc_key256, 16);
-		else
+		} else
 			memcpy(zuc_const, zuc_key128, 32);
 
 		se_ctx->zsk_flags = 0;
diff --git a/drivers/common/cnxk/roc_se.h b/drivers/common/cnxk/roc_se.h
index 5be832fa75..500f94ac11 100644
--- a/drivers/common/cnxk/roc_se.h
+++ b/drivers/common/cnxk/roc_se.h
@@ -297,6 +297,27 @@ struct roc_se_ctx {
 	uint8_t *auth_key;
 };
 
+static inline void
+roc_se_zuc_bytes_swap(uint8_t *arr, int len)
+{
+	int start, end;
+	uint8_t tmp;
+
+	if (len <= 0)
+		return;
+
+	start = 0;
+	end = len - 1;
+
+	while (start < end) {
+		tmp = arr[start];
+		arr[start] = arr[end];
+		arr[end] = tmp;
+		start++;
+		end--;
+	}
+}
+
 int __roc_api roc_se_auth_key_set(struct roc_se_ctx *se_ctx,
 				  roc_se_auth_type type, const uint8_t *key,
 				  uint16_t key_len, uint16_t mac_len);
@@ -306,4 +327,5 @@ int __roc_api roc_se_ciph_key_set(struct roc_se_ctx *se_ctx,
 				  uint16_t key_len, uint8_t *salt);
 
 void __roc_api roc_se_ctx_swap(struct roc_se_ctx *se_ctx);
+
 #endif /* __ROC_SE_H__ */
-- 
2.28.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] crypto/cnxk: swap zuc-256 iv
  2022-06-03 11:18 [PATCH 0/2] add zuc-256 support Ankur Dwivedi
  2022-06-03 11:18 ` [PATCH 1/2] common/cnxk: swap zuc-256 key Ankur Dwivedi
@ 2022-06-03 11:18 ` Ankur Dwivedi
  2022-06-23 14:25 ` [PATCH 0/2] add zuc-256 support Kevin Traynor
  2 siblings, 0 replies; 5+ messages in thread
From: Ankur Dwivedi @ 2022-06-03 11:18 UTC (permalink / raw)
  To: stable; +Cc: anoobj, gakhil, ktejasree, jerinj, Ankur Dwivedi

The microcode expects the iv to be in reverse of what is provided
by dpdk test app. Also the first 8 bytes of reversed iv is
compressed to 6 bytes.

Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
Reviewed-by: Jerin Jacob Kollanukkaran <jerinj@marvell.com>
---
 drivers/crypto/cnxk/cnxk_se.h | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h
index 37237de21a..f6f78a269e 100644
--- a/drivers/crypto/cnxk/cnxk_se.h
+++ b/drivers/crypto/cnxk/cnxk_se.h
@@ -39,17 +39,16 @@ struct cnxk_se_sess {
 static inline void
 cpt_pack_iv(uint8_t *iv_src, uint8_t *iv_dst)
 {
-	iv_dst[16] = iv_src[16];
-	/* pack the last 8 bytes of IV to 6 bytes.
+	/* pack the first 8 bytes of IV to 6 bytes.
 	 * discard the 2 MSB bits of each byte
 	 */
-	iv_dst[17] = (((iv_src[17] & 0x3f) << 2) | ((iv_src[18] >> 4) & 0x3));
-	iv_dst[18] = (((iv_src[18] & 0xf) << 4) | ((iv_src[19] >> 2) & 0xf));
-	iv_dst[19] = (((iv_src[19] & 0x3) << 6) | (iv_src[20] & 0x3f));
+	iv_dst[0] = (((iv_src[0] & 0x3f) << 2) | ((iv_src[1] >> 4) & 0x3));
+	iv_dst[1] = (((iv_src[1] & 0xf) << 4) | ((iv_src[2] >> 2) & 0xf));
+	iv_dst[2] = (((iv_src[2] & 0x3) << 6) | (iv_src[3] & 0x3f));
 
-	iv_dst[20] = (((iv_src[21] & 0x3f) << 2) | ((iv_src[22] >> 4) & 0x3));
-	iv_dst[21] = (((iv_src[22] & 0xf) << 4) | ((iv_src[23] >> 2) & 0xf));
-	iv_dst[22] = (((iv_src[23] & 0x3) << 6) | (iv_src[24] & 0x3f));
+	iv_dst[3] = (((iv_src[4] & 0x3f) << 2) | ((iv_src[5] >> 4) & 0x3));
+	iv_dst[4] = (((iv_src[5] & 0xf) << 4) | ((iv_src[6] >> 2) & 0xf));
+	iv_dst[5] = (((iv_src[6] & 0x3) << 6) | (iv_src[7] & 0x3f));
 }
 
 static inline void
@@ -71,10 +70,11 @@ pdcp_iv_copy(uint8_t *iv_d, uint8_t *iv_s, const uint8_t pdcp_alg_type,
 			iv_temp[j] = iv_s_temp[3 - j];
 		memcpy(iv_d, iv_temp, 16);
 	} else {
-		/* ZUC doesn't need a swap */
-		memcpy(iv_d, iv_s, 16);
-		if (pack_iv)
+		if (pack_iv) {
 			cpt_pack_iv(iv_s, iv_d);
+			memcpy(iv_d + 6, iv_s + 8, 17);
+		} else
+			memcpy(iv_d, iv_s, 16);
 	}
 }
 
@@ -1020,6 +1020,7 @@ cpt_zuc_snow3g_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens,
 		iv_len = params->auth_iv_len;
 
 		if (iv_len == 25) {
+			roc_se_zuc_bytes_swap(iv_s, iv_len);
 			iv_len -= 2;
 			pack_iv = 1;
 		}
@@ -1049,6 +1050,7 @@ cpt_zuc_snow3g_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens,
 		iv_len = params->cipher_iv_len;
 
 		if (iv_len == 25) {
+			roc_se_zuc_bytes_swap(iv_s, iv_len);
 			iv_len -= 2;
 			pack_iv = 1;
 		}
-- 
2.28.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] add zuc-256 support
  2022-06-03 11:18 [PATCH 0/2] add zuc-256 support Ankur Dwivedi
  2022-06-03 11:18 ` [PATCH 1/2] common/cnxk: swap zuc-256 key Ankur Dwivedi
  2022-06-03 11:18 ` [PATCH 2/2] crypto/cnxk: swap zuc-256 iv Ankur Dwivedi
@ 2022-06-23 14:25 ` Kevin Traynor
  2022-06-23 14:42   ` [EXT] " Ankur Dwivedi
  2 siblings, 1 reply; 5+ messages in thread
From: Kevin Traynor @ 2022-06-23 14:25 UTC (permalink / raw)
  To: Ankur Dwivedi, stable; +Cc: anoobj, gakhil, ktejasree, jerinj, Luca Boccassi

On 03/06/2022 12:18, Ankur Dwivedi wrote:
> Adds support for zuc-256 cipher in cnxk crypto PMD.
> 
> Ankur Dwivedi (2):
>    common/cnxk: swap zuc-256 key
>    crypto/cnxk: swap zuc-256 iv
> 
>   drivers/common/cnxk/roc_se.c  |  7 +++++--
>   drivers/common/cnxk/roc_se.h  | 22 ++++++++++++++++++++++
>   drivers/crypto/cnxk/cnxk_se.h | 24 +++++++++++++-----------
>   3 files changed, 40 insertions(+), 13 deletions(-)
> 

Hi Ankur,

These patches were missed because they didn't have the branch(es) they 
are requested for in the subject e.g. [PATCH 21.11]. See [0] below.

They are also missing DPDK main branch commit references and Fixes: 
tags. It is not clear from the commit messages if they are fixing 
something that was incorrectly implemented or they are adding a new 
feature. Please check [1] for info on what is backported to stable branches.

[0] 
http://doc.dpdk.org/guides/contributing/patches.html#backporting-patches-for-stable-releases

[1] 
http://doc.dpdk.org/guides/contributing/stable.html#what-changes-should-be-backported

thanks,
Kevin.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [EXT] Re: [PATCH 0/2] add zuc-256 support
  2022-06-23 14:25 ` [PATCH 0/2] add zuc-256 support Kevin Traynor
@ 2022-06-23 14:42   ` Ankur Dwivedi
  0 siblings, 0 replies; 5+ messages in thread
From: Ankur Dwivedi @ 2022-06-23 14:42 UTC (permalink / raw)
  To: Kevin Traynor, stable
  Cc: Anoob Joseph, Akhil Goyal, Tejasree Kondoj,
	Jerin Jacob Kollanukkaran, Luca Boccassi

Hi Kevin,

>-----Original Message-----
>From: Kevin Traynor <ktraynor@redhat.com>
>Sent: Thursday, June 23, 2022 7:55 PM
>To: Ankur Dwivedi <adwivedi@marvell.com>; stable@dpdk.org
>Cc: Anoob Joseph <anoobj@marvell.com>; Akhil Goyal
><gakhil@marvell.com>; Tejasree Kondoj <ktejasree@marvell.com>; Jerin
>Jacob Kollanukkaran <jerinj@marvell.com>; Luca Boccassi
><bluca@debian.org>
>Subject: [EXT] Re: [PATCH 0/2] add zuc-256 support
>
>External Email
>
>----------------------------------------------------------------------
>On 03/06/2022 12:18, Ankur Dwivedi wrote:
>> Adds support for zuc-256 cipher in cnxk crypto PMD.
>>
>> Ankur Dwivedi (2):
>>    common/cnxk: swap zuc-256 key
>>    crypto/cnxk: swap zuc-256 iv
>>
>>   drivers/common/cnxk/roc_se.c  |  7 +++++--
>>   drivers/common/cnxk/roc_se.h  | 22 ++++++++++++++++++++++
>>   drivers/crypto/cnxk/cnxk_se.h | 24 +++++++++++++-----------
>>   3 files changed, 40 insertions(+), 13 deletions(-)
>>
>
>Hi Ankur,
>
>These patches were missed because they didn't have the branch(es) they are
>requested for in the subject e.g. [PATCH 21.11]. See [0] below.
>
>They are also missing DPDK main branch commit references and Fixes:
>tags. It is not clear from the commit messages if they are fixing something that
>was incorrectly implemented or they are adding a new feature. Please check
>[1] for info on what is backported to stable branches.
>
>[0]
>https://urldefense.proofpoint.com/v2/url?u=http-
>3A__doc.dpdk.org_guides_contributing_patches.html-23backporting-
>2Dpatches-2Dfor-2Dstable-
>2Dreleases&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=ILjiNF3GF25y6QdHZ
>UxMl6JrStU0MIuCtO5dMzn3Ybk&m=jYpt8ha5W3GgR12vMbMLMDLbuko1AlkS
>H0VLgfs0qqmHaJb_lTs9XxWBcW9xLvUc&s=W65zD6TlBKec7YgOGOd-
>pKZdjX7M6AHmvFD3akwPmmo&e=
>
>[1]
>https://urldefense.proofpoint.com/v2/url?u=http-
>3A__doc.dpdk.org_guides_contributing_stable.html-23what-2Dchanges-
>2Dshould-2Dbe-
>2Dbackported&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=ILjiNF3GF25y6Qd
>HZUxMl6JrStU0MIuCtO5dMzn3Ybk&m=jYpt8ha5W3GgR12vMbMLMDLbuko1A
>lkSH0VLgfs0qqmHaJb_lTs9XxWBcW9xLvUc&s=ReOmg81NtozJLRB5DJcMStKUB
>Qyk9IVx_EniqYzjEck&e=
Thanks for the information. I will resend after adding the missing parts.
>
>thanks,
>Kevin.
Regards,
Ankur


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-23 14:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-03 11:18 [PATCH 0/2] add zuc-256 support Ankur Dwivedi
2022-06-03 11:18 ` [PATCH 1/2] common/cnxk: swap zuc-256 key Ankur Dwivedi
2022-06-03 11:18 ` [PATCH 2/2] crypto/cnxk: swap zuc-256 iv Ankur Dwivedi
2022-06-23 14:25 ` [PATCH 0/2] add zuc-256 support Kevin Traynor
2022-06-23 14:42   ` [EXT] " Ankur Dwivedi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).