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 AD1CFA055C for ; Fri, 3 Jun 2022 13:18:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A784D40694; Fri, 3 Jun 2022 13:18:38 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 5670340694 for ; Fri, 3 Jun 2022 13:18:37 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2533q2NT004366 for ; Fri, 3 Jun 2022 04:18:36 -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=blf4VfWnEeN03vsbV1BIWOOMcIAOXl6fzntmOfp0/JQ=; b=FX4palE4GdJ6Wtj3STYesbbKIBa139guectZehDISwbdeKwEOOg3+R6lrgbyWKB/ahCm UbtRLQGXgBXWYcMhHay5SO2GrmYxb0p83hsLrGN193qmE+GkSKCPmhkF8139RdZT7voo kDGnPvhPyDITjkVqz516gUFvf4ADiWa85qpgD/hU47XEAJtm3U5/IL9paP1aHOrCZthu 2EejlvVRDqToEjrgHVmXbVZB5pkW5LRw3fpQgmPFZzat1F2ZyQ+t9FjrmNLkc0+JhaPk K77gI1MSd2gUaewEjacAxd3LWWrpIXpFUwu/oE3Ca6Z90RzyA57U3r0oq+Vh4L1yWBeo rQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3geupucx37-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 03 Jun 2022 04:18:36 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 3 Jun 2022 04:18:34 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Fri, 3 Jun 2022 04:18:34 -0700 Received: from hyd1349.t110.caveonetworks.com.com (unknown [10.29.45.13]) by maili.marvell.com (Postfix) with ESMTP id 7B6113F7097; Fri, 3 Jun 2022 04:18:32 -0700 (PDT) From: Ankur Dwivedi To: CC: , , , , Ankur Dwivedi Subject: [PATCH 1/2] common/cnxk: swap zuc-256 key Date: Fri, 3 Jun 2022 16:48:22 +0530 Message-ID: <20220603111823.311-2-adwivedi@marvell.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20220603111823.311-1-adwivedi@marvell.com> References: <20220603111823.311-1-adwivedi@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: ypRUPNa9kVtOK8-qDS5pMWqWA7CXHoNA X-Proofpoint-ORIG-GUID: ypRUPNa9kVtOK8-qDS5pMWqWA7CXHoNA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-03_03,2022-06-03_01,2022-02-23_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 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 Reviewed-by: Jerin Jacob Kollanukkaran --- 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