From patchwork Mon Jan 30 14:28:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary R Hook X-Patchwork-Id: 9545489 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4DAC4604A8 for ; Mon, 30 Jan 2017 14:29:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 401F52022B for ; Mon, 30 Jan 2017 14:29:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 349DC2811D; Mon, 30 Jan 2017 14:29:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 163ED2022B for ; Mon, 30 Jan 2017 14:29:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932152AbdA3O3P (ORCPT ); Mon, 30 Jan 2017 09:29:15 -0500 Received: from mail-sn1nam01on0085.outbound.protection.outlook.com ([104.47.32.85]:10597 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752959AbdA3O3O (ORCPT ); Mon, 30 Jan 2017 09:29:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=D6S6B/6KCQP5kVzjfXYeoZ86QZw6BHnFIvHu8eRNqVc=; b=NdmkF6orqdVEsCaVDcDWonAQCWSigwH/LO7iAvLTB9odT/hL1ZrmvBjnkHnvAVSTYvjC96DPWSatHTkDBrvauC5/XCpOdGr0+3yHUw5KT26OMhiSyHaeoBNvfe4JZ/442jskV5HgtqIX2nyyZALsEIFe1Up9l2hw1Fw1j6/QEx0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Gary.Hook@amd.com; Received: from [10.236.19.42] (165.204.77.1) by MWHPR12MB1405.namprd12.prod.outlook.com (10.169.206.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.860.13; Mon, 30 Jan 2017 14:29:05 +0000 Subject: [PATCH 4/4] crypto: ccp - Simplify some buffer management routines From: Gary R Hook To: CC: , , Date: Mon, 30 Jan 2017 08:28:51 -0600 Message-ID: <20170130142851.8459.77653.stgit@taos> In-Reply-To: <20170130142414.8459.71539.stgit@taos> References: <20170130142414.8459.71539.stgit@taos> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR19CA0005.namprd19.prod.outlook.com (10.175.226.143) To MWHPR12MB1405.namprd12.prod.outlook.com (10.169.206.16) X-MS-Office365-Filtering-Correlation-Id: 1ce57c51-d275-4de4-4bac-08d4491c5858 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401076); SRVR:MWHPR12MB1405; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1405; 3:SLNvIkoZ+zci7RVcQWfdH+42y0uZ459cWy4EaO4zUNoPhDUXSGhBNop7EZzkapjd/wvlr4NGDUEotZMmIqZ/D2xISCx1jV/kylFMMMoqYCOhb+laMwzU7NjL2oCYkdlVGuyJHElvzzkK12b4UaFAiYjTY3c1ia1HB7PGvbVhTpy1ORUAgL6JgjeTF4gMRCJ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QRyyqkYsTYBloGn5fDhB90Ribqx2AZLSEfRj64+imYu2ceHnnFMNLVXfD3NZ8cmlBF0nylxFxF00ju6+aQ==; 20:DbUWN/dUyhCmyWkHj4fwnpwILTm0tBgiCPqZ3T/VV6S7mmFCpu+/k9YBcT32+J6gQEXbAU1c7rAaHVOrr+v8+B95untB55UnsoO1hft+DJ3DohFXolna9kV8OEdTrCUt0JLmAIu37Yx9BFZgKgtAdYpQfJ2bBMA68OeXNIFi5ULhbkJx2mVaFnVWZk+FbEEBSKrefovWMyTqVN6UpD/6IngzKDGpnuDt//R7eNgsFiG086KS7mEOoCkbGXjiGdVfvSFkn5QyPM0GIdOiikJoG/JEAZ4vaUUadW3pPWDZekV7daKPsKZKJwfFJzRE5e8faR6nvVnUW9xbjLTeG/xF/f634eefPL063ku9a/g4zAdp20m5SZl0Kna7CIpyEMFQ9B/GJzpme5RDcGXSnyWx/rFyTSk6u/AUjuaOd0m5uJBCWIh4b7yLUK4IO1elz27GxVy0UUUJIuBbLtC9Kr3HVKUfD9zbv1A0zv/HWDfMTEyKbhq9Qy7bR7gCsZAZ3oJo X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123564025)(20161123562025)(20161123555025)(6072148); SRVR:MWHPR12MB1405; BCL:0; PCL:0; RULEID:; SRVR:MWHPR12MB1405; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1405; 4:2a7+KNphebQO/PcGLw2nMOt0IhxJbaFpCrlCXpk7e1VxwjfsQOmEWbCfoioNrt5rt90Qn++x50cwKG+ybzwoBEjhhWFVbpTRNb8NGGI80ynFHnBYHrc1AACQKx4xmYC16P7w/viC3JinSl9cZsw6eXgQxp6tk2riogwBz1XtexBSuQNnn4RnQ8xCfqmsC9CZmftLqkuWy9tyYhzyEVFLbUOX6JyYgnCrbDrI1vOW9UedKGEz7oXV5R4QGKFULyf4FYNdLPFoU9+Kd1dgWRkvBNpfWXhZNrFAi+9wcvWTiFOZ+tCx7F/Vw4DZPQ17t0uRmsaEAu7khSCFx7RsXepImwyDKNSC6PHuyPB9pBaxnxulGLyya+LsUzZLxqeOTnbadkEgsmgsQpJabujn3KyYgi7OSetoA6hyKOnv/cRc1plEd7soEAcaeuaer8MO2JyqTwE3r9r6ko6/ymiNQu6wTBS59aX0AAytADytJ5qxHnGr4kskUodZSbcdpAxcwBmheF4nOl0gbEUA1oE+quddlBELFylhQ1GKxDXw/sCd5hnajBvns3mRW/sd7nPgBb6jQjfbnP7a+Zr0mTzEulFl+PAqq/LfWuL4UFD2+jGIOevC/TkGfsWya34SUmM6jej/ X-Forefront-PRVS: 0203C93D51 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(39410400002)(39840400002)(39850400002)(39860400002)(39450400003)(189002)(199003)(106356001)(23676002)(97746001)(105586002)(8676002)(1076002)(68736007)(4001350100001)(2351001)(97736004)(25786008)(50986999)(101416001)(53936002)(110136003)(81166006)(81156014)(90366009)(6116002)(3846002)(230700001)(189998001)(54356999)(42186005)(6666003)(2950100002)(6916009)(76176999)(38730400001)(83506001)(33716001)(92566002)(2906002)(4326007)(54906002)(47776003)(66066001)(103116003)(86362001)(9686003)(7736002)(305945005)(6486002)(77096006)(5660300001)(33646002)(50466002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1405; H:[10.236.19.42]; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxNDA1OzIzOjhEMDU3TGpqTkhqT0RZRFFQTmhWUm0wRVVM?= =?utf-8?B?V3FqN0ZuWVZvWHJNdU0wcVBEWEQ1aTJnb1QwYThvL1llcDl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VOAMVl/vbzmBO+JjwuVBW4zdEoBtM9uN?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1405; 6:mQGm3xvCIH8GegJcmGk5c0t1AlKYJZgUOXoT0quesZUEw7vt/FMEKb/Mo/QnxmYfjrSJc3nGlQzMOTwLF0+R5ly73njazst51BxI6T+0vbf82s/ngsHOyxt9WFl5OjeXjxMnOOB0NWKwCgFuk1IGlNol8Owex5W2g1bbsusQUZhl1KTdqjJAlLKw7Ri1IkBJkPwmsN0sygCL8xF3l32z295HZzA9FVsL/ZhhBa+PEMN049yziL+F4/GFh9ClcgqYi8QCtVrcZIehGBbifcdewMlc48Dv3gGaZUzRQL24GUUwa7N4wBecKwrztK0mLNQyADd0ANUyi7Am/ra+3FK32yuPBFWWWRkjR/TB8WZy4JH+PY7egNwM03TgNibcWuXKxgLrzFUFMNzRcxXtiXoHvdEoN4GKp8wrilRG1TwbgVuK1Kd/8h1i6AXiwx5pBI+a; 5:WCMZ+O/gHpn6bK5xib5guPjuu48kO3PQb+ynLeRHq1bkor18ZjfX/x0RowkkjMXnXeC6AUvm/Adc71cMRThBLnf6Zg4QyeQCth6VWJ/phknSlJMHclXziJnDPGbeD0AKVIDAVoqedgeDAo2faqGDsA==; 24:CVm+6Gi3I7J1+3XXjEoNwpUAmHrN5LzPbdV+1ZukoWKTiDPa2kWy3ThYZLiXSZY6ApFU+6jlNs3bbGAN1HziNjesUkgK6lQrabXR3qzXe0I= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1405; 7:4ReJWvSSPtRy3F7xtafx8C0FQ6dum73zpdn0Q7U7PZDDkgtQUcrob/X6dt7uKAmYEFTjdD4xswr/B7OO5kgBXRhPjls3K0E8wELFnWgXtneUx8qmJzmxW0GtcjmMVFvWEV31FulkbxnpywtWNrZuGDEv+qLVQa9gzpJPLhWmm2qM9mfKk6ItZ2DRcD5IVy41kzkygn9QE9M0mr6g3Yam7GZhKbJd1GTXZzUWBYCjh4Z801cFPBBHVJ7HRt9HmriVDAmbQxDRCLmYoATNiL50qI14IELYfjikgJz26cM+sJ5h0HqMALJ5Q74o1KhcU18+mT943j7cE7Xn66oZsQeTealVYT86Rh3CyxrX8w1fZ7MsNm/WbsNlNrnX+31KXEUTsoGU+S69IaqjkPKhzT9tuZ+qGbORidd6KoqXFJ4lyXyjZUBvgtpfRWLz0SRea3D/+eUxs4vUsFf/Vni+Gp/m3A==; 20:FG7sT+KV4unuoPA+v1tBMfYQU5o9e3Rw1s5TVcGxpGbpGfqdtlmtbWcCDrXm2zVGYFzgpvnFvLUhZfRKSRpEmLXPfnYrD7esfdDMTH36l9sb9bAk8+lurP7utPCYn2hts0kzsIvIZXQbR2KV7GaKPf5XC6w3fQC4AancWO/RaYKZr/saWgnzIfRhCpHNphIrRHvD2jjtsx7KQnBd8zWWeTSjbgbj1pMdTWTAJniAeTNgnDN53DiQrMyHGEb17nxG X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2017 14:29:05.2733 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1405 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The reverse-get/set functions can be simplified by eliminating unused code. Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-ops.c | 142 +++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 86 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c index 1a27af3..f426ba5 100644 --- a/drivers/crypto/ccp/ccp-ops.c +++ b/drivers/crypto/ccp/ccp-ops.c @@ -184,62 +184,46 @@ static void ccp_get_dm_area(struct ccp_dm_workarea *wa, unsigned int wa_offset, } static int ccp_reverse_set_dm_area(struct ccp_dm_workarea *wa, + unsigned int wa_offset, struct scatterlist *sg, - unsigned int len, unsigned int se_len, - bool sign_extend) + unsigned int sg_offset, + unsigned int len) { - unsigned int nbytes, sg_offset, dm_offset, sb_len, i; - u8 buffer[CCP_REVERSE_BUF_SIZE]; - - if (WARN_ON(se_len > sizeof(buffer))) - return -EINVAL; - - sg_offset = len; - dm_offset = 0; - nbytes = len; - while (nbytes) { - sb_len = min_t(unsigned int, nbytes, se_len); - sg_offset -= sb_len; - - scatterwalk_map_and_copy(buffer, sg, sg_offset, sb_len, 0); - for (i = 0; i < sb_len; i++) - wa->address[dm_offset + i] = buffer[sb_len - i - 1]; - - dm_offset += sb_len; - nbytes -= sb_len; - - if ((sb_len != se_len) && sign_extend) { - /* Must sign-extend to nearest sign-extend length */ - if (wa->address[dm_offset - 1] & 0x80) - memset(wa->address + dm_offset, 0xff, - se_len - sb_len); - } + u8 *p, *q; + + ccp_set_dm_area(wa, wa_offset, sg, sg_offset, len); + + p = wa->address + wa_offset; + q = p + len - 1; + while (p < q) { + *p = *p ^ *q; + *q = *p ^ *q; + *p = *p ^ *q; + p++; + q--; } - return 0; } static void ccp_reverse_get_dm_area(struct ccp_dm_workarea *wa, + unsigned int wa_offset, struct scatterlist *sg, + unsigned int sg_offset, unsigned int len) { - unsigned int nbytes, sg_offset, dm_offset, sb_len, i; - u8 buffer[CCP_REVERSE_BUF_SIZE]; - - sg_offset = 0; - dm_offset = len; - nbytes = len; - while (nbytes) { - sb_len = min_t(unsigned int, nbytes, sizeof(buffer)); - dm_offset -= sb_len; - - for (i = 0; i < sb_len; i++) - buffer[sb_len - i - 1] = wa->address[dm_offset + i]; - scatterwalk_map_and_copy(buffer, sg, sg_offset, sb_len, 1); - - sg_offset += sb_len; - nbytes -= sb_len; + u8 *p, *q; + + p = wa->address + wa_offset; + q = p + len - 1; + while (p < q) { + *p = *p ^ *q; + *q = *p ^ *q; + *p = *p ^ *q; + p++; + q--; } + + ccp_get_dm_area(wa, wa_offset, sg, sg_offset, len); } static void ccp_free_data(struct ccp_data *data, struct ccp_cmd_queue *cmd_q) @@ -1262,8 +1246,7 @@ static int ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) if (ret) goto e_sb; - ret = ccp_reverse_set_dm_area(&exp, rsa->exp, rsa->exp_len, - CCP_SB_BYTES, false); + ret = ccp_reverse_set_dm_area(&exp, 0, rsa->exp, 0, rsa->exp_len); if (ret) goto e_exp; ret = ccp_copy_to_sb(cmd_q, &exp, op.jobid, op.sb_key, @@ -1281,16 +1264,12 @@ static int ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) if (ret) goto e_exp; - ret = ccp_reverse_set_dm_area(&src, rsa->mod, rsa->mod_len, - CCP_SB_BYTES, false); + ret = ccp_reverse_set_dm_area(&src, 0, rsa->mod, 0, rsa->mod_len); if (ret) goto e_src; - src.address += o_len; /* Adjust the address for the copy operation */ - ret = ccp_reverse_set_dm_area(&src, rsa->src, rsa->src_len, - CCP_SB_BYTES, false); + ret = ccp_reverse_set_dm_area(&src, o_len, rsa->src, 0, rsa->src_len); if (ret) goto e_src; - src.address -= o_len; /* Reset the address to original value */ /* Prepare the output area for the operation */ ret = ccp_init_data(&dst, cmd_q, rsa->dst, rsa->mod_len, @@ -1315,7 +1294,7 @@ static int ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) goto e_dst; } - ccp_reverse_get_dm_area(&dst.dm_wa, rsa->dst, rsa->mod_len); + ccp_reverse_get_dm_area(&dst.dm_wa, 0, rsa->dst, 0, rsa->mod_len); e_dst: ccp_free_data(&dst, cmd_q); @@ -1567,25 +1546,22 @@ static int ccp_run_ecc_mm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) save = src.address; /* Copy the ECC modulus */ - ret = ccp_reverse_set_dm_area(&src, ecc->mod, ecc->mod_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->mod, 0, ecc->mod_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; /* Copy the first operand */ - ret = ccp_reverse_set_dm_area(&src, ecc->u.mm.operand_1, - ecc->u.mm.operand_1_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->u.mm.operand_1, 0, + ecc->u.mm.operand_1_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; if (ecc->function != CCP_ECC_FUNCTION_MINV_384BIT) { /* Copy the second operand */ - ret = ccp_reverse_set_dm_area(&src, ecc->u.mm.operand_2, - ecc->u.mm.operand_2_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->u.mm.operand_2, 0, + ecc->u.mm.operand_2_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; @@ -1624,7 +1600,8 @@ static int ccp_run_ecc_mm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) } /* Save the ECC result */ - ccp_reverse_get_dm_area(&dst, ecc->u.mm.result, CCP_ECC_MODULUS_BYTES); + ccp_reverse_get_dm_area(&dst, 0, ecc->u.mm.result, 0, + CCP_ECC_MODULUS_BYTES); e_dst: ccp_dm_free(&dst); @@ -1692,22 +1669,19 @@ static int ccp_run_ecc_pm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) save = src.address; /* Copy the ECC modulus */ - ret = ccp_reverse_set_dm_area(&src, ecc->mod, ecc->mod_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->mod, 0, ecc->mod_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; /* Copy the first point X and Y coordinate */ - ret = ccp_reverse_set_dm_area(&src, ecc->u.pm.point_1.x, - ecc->u.pm.point_1.x_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->u.pm.point_1.x, 0, + ecc->u.pm.point_1.x_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; - ret = ccp_reverse_set_dm_area(&src, ecc->u.pm.point_1.y, - ecc->u.pm.point_1.y_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->u.pm.point_1.y, 0, + ecc->u.pm.point_1.y_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; @@ -1718,15 +1692,13 @@ static int ccp_run_ecc_pm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) if (ecc->function == CCP_ECC_FUNCTION_PADD_384BIT) { /* Copy the second point X and Y coordinate */ - ret = ccp_reverse_set_dm_area(&src, ecc->u.pm.point_2.x, - ecc->u.pm.point_2.x_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->u.pm.point_2.x, 0, + ecc->u.pm.point_2.x_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; - ret = ccp_reverse_set_dm_area(&src, ecc->u.pm.point_2.y, - ecc->u.pm.point_2.y_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->u.pm.point_2.y, 0, + ecc->u.pm.point_2.y_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; @@ -1736,19 +1708,17 @@ static int ccp_run_ecc_pm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) src.address += CCP_ECC_OPERAND_SIZE; } else { /* Copy the Domain "a" parameter */ - ret = ccp_reverse_set_dm_area(&src, ecc->u.pm.domain_a, - ecc->u.pm.domain_a_len, - CCP_ECC_OPERAND_SIZE, false); + ret = ccp_reverse_set_dm_area(&src, 0, ecc->u.pm.domain_a, 0, + ecc->u.pm.domain_a_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; if (ecc->function == CCP_ECC_FUNCTION_PMUL_384BIT) { /* Copy the scalar value */ - ret = ccp_reverse_set_dm_area(&src, ecc->u.pm.scalar, - ecc->u.pm.scalar_len, - CCP_ECC_OPERAND_SIZE, - false); + ret = ccp_reverse_set_dm_area(&src, 0, + ecc->u.pm.scalar, 0, + ecc->u.pm.scalar_len); if (ret) goto e_src; src.address += CCP_ECC_OPERAND_SIZE; @@ -1793,10 +1763,10 @@ static int ccp_run_ecc_pm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) save = dst.address; /* Save the ECC result X and Y coordinates */ - ccp_reverse_get_dm_area(&dst, ecc->u.pm.result.x, + ccp_reverse_get_dm_area(&dst, 0, ecc->u.pm.result.x, 0, CCP_ECC_MODULUS_BYTES); dst.address += CCP_ECC_OUTPUT_SIZE; - ccp_reverse_get_dm_area(&dst, ecc->u.pm.result.y, + ccp_reverse_get_dm_area(&dst, 0, ecc->u.pm.result.y, 0, CCP_ECC_MODULUS_BYTES); dst.address += CCP_ECC_OUTPUT_SIZE;