From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 564D4A0032 for ; Fri, 24 Jun 2022 09:19:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 50C5D40A82; Fri, 24 Jun 2022 09:19:03 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 747C740A82 for ; Fri, 24 Jun 2022 09:19:02 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25O7BapE029071 for ; Fri, 24 Jun 2022 00:19:01 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=3NaPNxRvOH/W5ifoaCrobSu2CKqcTjlBriNUh9bJQ8o=; b=VL6gzewzXNlwGjKNAXhW3Ss5pmTbJN1YPa5nVoVgEnsOy1f9aylSlLqjqZJngwZ+fT+D 4uBFp9cZJvkZrOZjLgbjD6lBLnBI86gGRtVnzbNIKPmj98pIZOkQOczIpZa6w4f9T67K 3sdsa7G+CyHi6/ziizVUsOj6NR47tmv2hJ8JEqegAAXS7vOYHWJN2tknnIeh7Um60ALB JcYYF1gulJu0xRQkSkDiJEXcOGc30EYrW72KQA1t5AiQLqmURP9dwU4PpHso6Y/Ng6nL aY/kGKgSVip66J30RGKshiHmIsWP7nkIWX/2XaWKmhjS+Jo88xOEd4MbjiDg+QmcbRt5 rw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3guye839f2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 24 Jun 2022 00:19:01 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 24 Jun 2022 00:18:58 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 24 Jun 2022 00:18:58 -0700 Received: from hyd1349.t110.caveonetworks.com.com (unknown [10.29.45.13]) by maili.marvell.com (Postfix) with ESMTP id DCF493F7070; Fri, 24 Jun 2022 00:18:55 -0700 (PDT) From: Ankur Dwivedi To: CC: , , , , , Ankur Dwivedi Subject: [PATCH 21.11 2/2] crypto/cnxk: swap zuc-256 iv Date: Fri, 24 Jun 2022 12:48:09 +0530 Message-ID: <20220624071809.27393-3-adwivedi@marvell.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20220624071809.27393-1-adwivedi@marvell.com> References: <20220624071809.27393-1-adwivedi@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: o5wOOgHUEEo7nVAq6MH6GbNzfG_bsn_U X-Proofpoint-ORIG-GUID: o5wOOgHUEEo7nVAq6MH6GbNzfG_bsn_U X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-24_04,2022-06-23_01,2022-06-22_01 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ upstream commit 09ceaa636061c15e9c16a14aaa5caf7378e2c6fa ] 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. Fixes: 89b78a2e3df9 ("crypto/cnxk: fix IV length for ZUC-256") Signed-off-by: Ankur Dwivedi --- 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 99a2894fa6..af86ef18d8 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