From patchwork Fri Apr 29 13:10:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 8982071 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 29BA8BF29F for ; Fri, 29 Apr 2016 13:10:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D7B2201C0 for ; Fri, 29 Apr 2016 13:10:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 53E3A201DD for ; Fri, 29 Apr 2016 13:10:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753455AbcD2NKd (ORCPT ); Fri, 29 Apr 2016 09:10:33 -0400 Received: from mail-bn1on0055.outbound.protection.outlook.com ([157.56.110.55]:4165 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753365AbcD2NKb (ORCPT ); Fri, 29 Apr 2016 09:10:31 -0400 Received: from BY2PR03CA005.namprd03.prod.outlook.com (10.255.93.22) by DM2PR0301MB1230.namprd03.prod.outlook.com (10.160.219.19) with Microsoft SMTP Server (TLS) id 15.1.477.8; Fri, 29 Apr 2016 13:10:28 +0000 Received: from BL2FFO11FD044.protection.gbl (10.255.93.4) by BY2PR03CA005.outlook.office365.com (10.255.93.22) with Microsoft SMTP Server (TLS) id 15.1.453.26 via Frontend Transport; Fri, 29 Apr 2016 13:10:28 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD044.mail.protection.outlook.com (10.173.161.140) with Microsoft SMTP Server (TLS) id 15.1.477.4 via Frontend Transport; Fri, 29 Apr 2016 13:10:27 +0000 Received: from enigma.ea.freescale.net (enigma.ea.freescale.net [10.171.77.120]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u3TDAOke002306; Fri, 29 Apr 2016 06:10:26 -0700 From: Tudor Ambarus To: CC: , Tudor Ambarus Subject: [PATCH v4 1/3] crypto: scatterwak - Add scatterwalk_sg_copychunks Date: Fri, 29 Apr 2016 16:10:19 +0300 Message-ID: <1461935421-31363-2-git-send-email-tudor-dan.ambarus@nxp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1461935421-31363-1-git-send-email-tudor-dan.ambarus@nxp.com> References: <1461935421-31363-1-git-send-email-tudor-dan.ambarus@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131064090280784275; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(586003)(2906002)(86362001)(47776003)(48376002)(87936001)(104016004)(50466002)(5008740100001)(5003940100001)(6806005)(106466001)(11100500001)(110136002)(85426001)(33646002)(2950100001)(36756003)(92566002)(189998001)(19580395003)(19580405001)(105606002)(50986999)(76176999)(2351001)(229853001)(4326007)(81166005)(77096005)(1096002)(1220700001)(50226002)(7059030)(4720700001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0301MB1230; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD044; 1:dPJv3iznVsgwral01j8qDw8e/zFPCnhkyQOaQ2+BNAVYP0iU0e/zv5PqSUtk9orcS3ZE1E4Xk2GwWFNygKNe2BrDdvspfDy+D59PJ+bZ+8b7m4tcoFSkSENvurBx6DFA8zPmq9K7t7SBEF2RNtipg7Q6JVeNtn38bym7hwFAvtcR1QrPygo1QcvnPHhqKZaVCyRYduSJCxfZO5QNrb/txqv9cKj9OGTVDQu+pl1tx+Vj81oAWrWjY6NaqNbP0ES4gNvcAzxLyQyja+eK5ynKKF67a6fO4Z1cMwQj1I6QBRLoCffAC/YgNOYVk4HQVBPIEemYo9Zwas0F+q1dYdXydFw4LWTuPSz6OiZyRo9WYG9nFcn3tY+2pjiMzD8g+s+XivpqzBi5Z+m8ALNycj72l+vCLMenHAYuIXE5GOct3a+XcYXk8Tkk2RPP8FP/rVnhjPtsTRhkAI7CcBd8j8vGqBnJnFLxKttxiExeu7Qk4eP4ePYb7s7QQ6xHfQXQxCubPfj75isWK/JgYwBi4k6n9hmMT/WKYMSvWr4YysQ/uO1UShrfmcC5t3BfDtOM6+THc3TCcCixTspDyaEhcpQqPBx3of/rAN8YllxqUI0KApmT9cO+FziOR7JPMP3ykEMQ55WZx89coOrqVGx2BXwjKYQXqT3yWK3gmSyKMsHEqZAYQnP/TwMgMMzudhYaiXucqdEG2g4uxK3p8uVVB2sJ4Q== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 6eb59ef5-af35-429a-f193-08d3702fa275 X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB1230; 2:t5EyygYE+cBGnhMmh+owXAkDXeDVWm//NG0vji4EyX59o2DNvOo5Ya77Q9ydG46vM1IuM7mYeAnDSqxpzmRkNele5pq9QWQ1zBFgy0+Uad3Wy/DOq86TRa7YYL1X+xik95phmfSCqs2k6YFHYMF98kbU6p4xexnNEqWtDMWfIXA7lwolenlP23+osixhbvaU; 3:6gHR72+5zWymbTJqbaaYs+JI7HDM+LNvIZVJhLWhoW0jGEVJvaAkbOmQWUqGG9IvDx4/6jPB1p2AIVY2eX8mfTISg+J5csV3wjnYUd8oxt0FlqgU3v6+r93lDBuqa2svp6R+1zYZDEx06FB7BPs/utikE2cNwaSlyzBokuNZJuN6d81A9zj9zqgKVCVilfMdKJpxs1cO2GOsK9zs4HROmPJ9YM2OYWNP3HAGrRiM1ow=; 25:9z3XabxkGQr+8fde5YEWtu7twp4wKfmojZAjy62XZTsCpBu1ZYjj8U95WgrSkgmCtBdWleZJkIdqiFAwmZyhY97/rzMdH66cdlrhjpp/zLR/d8/R8Sclojjdo7GGSYZnczi0mc4Zwwol/6eggDUmGpkodsQIRMf5782ucbzIimRD3W6MQCC1/fZveKCeO9rFVLH72kCb48qNsIune2g+y/G7aCwobHGUs6YfnpXK1P34Vuu53hLwxqYAsSBlJKxrYX0N9FCTrG76/F7u9iplwfJgOI2fye6/E3GPj61S0HdlKIfXzbH+3Iq0jDmEVZzhMWJYsh+zdj7Ok7iefvXimQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB1230; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13023025)(13015025)(13018025)(13017025)(8121501046)(5005006)(13024025)(3002001)(10201501046)(6055026); SRVR:DM2PR0301MB1230; BCL:0; PCL:0; RULEID:(400006); SRVR:DM2PR0301MB1230; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB1230; 4:mJYpRs0LkJcNs6jwV3bZ9NnzY3JtLtCNmH+NK9EkIg4kt2hAEION0G4CbTQ8I7EWPcKzpv1iQO0BwOR4ouEZGQT6/rcJUUQs/muz63Ve9ou6KXYs8USt+4e5QyjVLGUAyvRtcscb+3Bqhi0jDnoaDDh/FIPd+cUGHhclshR19YmC/u9qXGgNAhSnkldZuZGEVQ1BkqeKcnlet902645z1OKDdVPR1aIlLcsY1P1bbJXfc4aBeMvtcb5H8ddaA0sGpWLw4hR0sfGml229xLzBCh4jc7Qa3hMofCXg1S9rf0/+HHdUkFHBySJZ01kE0WUcL+4ip8k2ZJArd96I+EorDmqRuqTe0VQZ8CxNxr7XuFSGo8JQ9/+rDxypcO7NzGQN5z5kKbPnHkW+xIjmsa6/WJlgAXJUn8tsTArj4iBFqLeNNVF0+pSP/iLqHB4iWYgJSPIpuLTXRBHEw60s6w3hu25hde2ZOXBoT77o40jO72c= X-Forefront-PRVS: 0927AA37C7 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR0301MB1230; 23:MpZZNmR0s4nkMG4ZKf9LVFLqKX1+i4dXEmXerJz?= =?us-ascii?Q?bAnwOZO2ZjVlrZ2XvriH60ccsZ/Jdq0GZ73DRK+SZdxDLDaIyU+c6KHyazts?= =?us-ascii?Q?9nWHWX/xzDlygFOoWX4ZA6ZTnEWl+iiBqzVON2Fuzj/WWNwvF889I/ALk3bF?= =?us-ascii?Q?AkwD8C7vcRR60FP5ul1+FyNnX6tHzrCG4su662E4r2reElZAnQLjMsXvy5ZT?= =?us-ascii?Q?9BY1clOlzvNC1DCKVUWZ/Yfr+835H4x4lmUmAsWcOEXRZKcXMCXuWi9mJtRb?= =?us-ascii?Q?all5szfmNt4VSCV5NRhy+t9umzqQe/CiKRTGTx+I/pOikvI7DEQaRiq3GDP7?= =?us-ascii?Q?OdfywbikTbSW6B2767F9Ur4q6kpwoyxF3uLKL23t7aq8LoApNuv5ZHa1awpI?= =?us-ascii?Q?OFK7NVRackCSp799tOZAIxW/BMHM5PeVKN0MDZXEiLft29BAd4xDijoSz5tF?= =?us-ascii?Q?X/jQBUjv/5OvDoQNcU81nAyiAvJGnDKE9J/Bik20uJJpyOy8R+5tC8u4mBte?= =?us-ascii?Q?woLzFziMy5a1tTfuY6sqKgznyCOuC73WQvlg2aN65rPe2sTZupw1IVcb6G+K?= =?us-ascii?Q?J2ETBySraaX2eABnNuNSTl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wY6849wYwqy8VPz27eRvp7FnDbvPToXB6VRW51YYVt4/mJPBL2ohR2HANAE9vWE2GvGZtbP SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2016 13:10:27.9068 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB1230 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds the function scatterwalk_sg_copychunks which writes a chunk of data from a scatterwalk to another scatterwalk. It will be used by caam driver to remove the leading zeros for the output data of the RSA algorithm, after the computation completes. Signed-off-by: Tudor Ambarus --- crypto/scatterwalk.c | 26 ++++++++++++++++++++++++++ include/crypto/scatterwalk.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/crypto/scatterwalk.c b/crypto/scatterwalk.c index ea5815c..bc3222d 100644 --- a/crypto/scatterwalk.c +++ b/crypto/scatterwalk.c @@ -125,6 +125,32 @@ void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg, } EXPORT_SYMBOL_GPL(scatterwalk_map_and_copy); +void scatterwalk_sg_copychunks(struct scatter_walk *dest, + struct scatter_walk *src, size_t nbytes) +{ + for (;;) { + unsigned int len_this_page = scatterwalk_pagelen(dest); + u8 *vaddr; + + if (len_this_page > nbytes) + len_this_page = nbytes; + + vaddr = scatterwalk_map(dest); + scatterwalk_copychunks(vaddr, src, len_this_page, 0); + scatterwalk_unmap(vaddr); + + scatterwalk_advance(dest, len_this_page); + + if (nbytes == len_this_page) + break; + + nbytes -= len_this_page; + + scatterwalk_pagedone(dest, 0, 1); + } +} +EXPORT_SYMBOL_GPL(scatterwalk_sg_copychunks); + int scatterwalk_bytes_sglen(struct scatterlist *sg, int num_bytes) { int offset = 0, n = 0; diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h index 35f99b6..8b799c5 100644 --- a/include/crypto/scatterwalk.h +++ b/include/crypto/scatterwalk.h @@ -86,6 +86,8 @@ static inline void scatterwalk_unmap(void *vaddr) void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg); void scatterwalk_copychunks(void *buf, struct scatter_walk *walk, size_t nbytes, int out); +void scatterwalk_sg_copychunks(struct scatter_walk *dest, + struct scatter_walk *src, size_t nbytes); void *scatterwalk_map(struct scatter_walk *walk); void scatterwalk_done(struct scatter_walk *walk, int out, int more);