From patchwork Thu May 12 15:06:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 9082711 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B4A5A9F1C3 for ; Thu, 12 May 2016 15:06:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D50382024F for ; Thu, 12 May 2016 15:06:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2919620251 for ; Thu, 12 May 2016 15:06:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752648AbcELPGd (ORCPT ); Thu, 12 May 2016 11:06:33 -0400 Received: from mail-bl2on0077.outbound.protection.outlook.com ([65.55.169.77]:1760 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752573AbcELPGb (ORCPT ); Thu, 12 May 2016 11:06:31 -0400 Received: from BLUPR0301CA0037.namprd03.prod.outlook.com (10.162.113.175) by BN1PR0301MB0596.namprd03.prod.outlook.com (10.160.170.23) with Microsoft SMTP Server (TLS) id 15.1.485.9; Thu, 12 May 2016 15:06:24 +0000 Received: from BN1BFFO11OLC002.protection.gbl (2a01:111:f400:7c10::1:185) by BLUPR0301CA0037.outlook.office365.com (2a01:111:e400:5259::47) with Microsoft SMTP Server (TLS) id 15.1.492.11 via Frontend Transport; Thu, 12 May 2016 15:06:24 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) 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.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11OLC002.mail.protection.outlook.com (10.58.145.13) with Microsoft SMTP Server (TLS) id 15.1.492.8 via Frontend Transport; Thu, 12 May 2016 15:06:24 +0000 Received: from enigma.ea.freescale.net (enigma.ea.freescale.net [10.171.77.120]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u4CF6Kn0007042; Thu, 12 May 2016 08:06:22 -0700 From: Tudor Ambarus To: CC: , Tudor Ambarus Subject: [PATCH 1/3] crypto: scatterwak - Add scatterwalk_sg_copychunks Date: Thu, 12 May 2016 18:06:16 +0300 Message-ID: <1463065578-14017-2-git-send-email-tudor-dan.ambarus@nxp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1463065578-14017-1-git-send-email-tudor-dan.ambarus@nxp.com> References: <1463065578-14017-1-git-send-email-tudor-dan.ambarus@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131075391843464119; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(9170700003)(87936001)(50986999)(5008740100001)(36756003)(47776003)(5003940100001)(8936002)(48376002)(92566002)(50466002)(81166006)(6806005)(86362001)(76176999)(2950100001)(104016004)(50226002)(1220700001)(19580395003)(2351001)(19580405001)(229853001)(33646002)(85426001)(586003)(106466001)(105606002)(189998001)(110136002)(11100500001)(77096005)(2906002)(7059030)(4720700001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0301MB0596; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1B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5BPJm5uRik1ElDtSfBPbegt0ocS67fVmRAAzU8/TT7ac+YjFoo1loG9JKfAs71QwOey+crZU1Sv3vUaR87M41xfgtOMJG9JrjZBC6j5edh6gdKHJGfSk/ArRDrIokF+YK1xKB9ibpTNKiiIprzTFME0t1+AIWDpSqT981EMFnw96giJqcUNSKQaAE+tH7dNhM0nkvxdDRbUzK0Y+f7ufSS4npwg0OeeybmY=; 25:U2qLWwVr//Wg1y0FAncCX93+tylH8bLhnXJppbeP5qLNTrUl5bdvscE7waPpXhawvyiV6I4UkdYK3yolA/UJrHBmoVKub3tnCPg56Wdt4dIwcImql/1Z7IrQewmP81QOR/+pnPWdvDEuO2VSYJhiTbcFFVPpJ08ZkIDZJ4pdX3mI0iVzyikHV5Ovb3PZcs6+rxmDiTtgJaSuGMoQ21WUOLRAujoCe2r1ATJRljLrCql7uCyP+6bHqb/bMpttLwem2P/KvBq4tdoQl/EUOhNQLt+O2B2zHe2TGcZ9D+InBYX/YpiR0FeD33jQ14y1Dek7vlpZIMBkHoGoNCFJTy4qJzz/m/fRDr+SdN0LjuzC8y6Vu9DkhK9YLrnENCUYaxSSJFKMBVpbXjrWX9YoXRhXxwG80NO8ypGRnqFERvIp8L4= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR0301MB0596; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(13015025)(13017025)(13023025)(13024025)(13018025)(3002001)(10201501046)(6055026); SRVR:BN1PR0301MB0596; BCL:0; PCL:0; RULEID:(400006); SRVR:BN1PR0301MB0596; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0596; 4:Bh1cKZj4UcXGy7QGnBJKMea5o8BZhTW2C9amNK+5Uy6E3hYttR9GKl9nqmUd/1EGdTxZo3MdLnBp4QzeKezvnKEDxSA2UyZgZ1pz8z2zhjdWMfy9uCHvCHL0zNdVyu2H1bmy0RHOLyViVsxe6rjEk3z6wX7hl4BXmtCanzhaAaePefLeVV6j/pbjQds2QlHKf9kqlkKklX2Msu469gy0NkTS/dEq1t3QH0A5A09szu6/J98MMlwOfZa8QLTkdPAK6TmDlVCl+RpHedtji/Itu7KuamxZ16PANK4Y6550wlVBTbsxJsPKmnYBeVa3hoL7dzVmemAOnfdAP4XIslCbW41g4DQm7Y1plIY9BbvaeM72sVF6TQdiJz3H/0sN6vuZPomnkiCOnsW4xlfNIHjIoBSvjd9eJdx0T3w2tww63Mnx2uW91keCLez982mnUwBmnCO5++E5FT4GD961I1DugDXla0bWguIGyqMjgj/xb0I= X-Forefront-PRVS: 0940A19703 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN1PR0301MB0596; 23:rc8pu7axkd7X1FVQ7xFo/kfzhEa+V8t6/4s63LU?= =?us-ascii?Q?cbOafWJ+SXRIvHIiyd75X4gxApnjgSrgiFzYUsBRHgibZ8oDcdpDPQrwAixj?= =?us-ascii?Q?O1Z6LYYWUiINVDPurQVXb83jxUL3sKGFqBcLVjBArGjO6Qpl1r97p/UkDFke?= =?us-ascii?Q?P3ow+Tkgg1awjGZRZy5HlheMJ2222vKzuPYypXBYVk/bglGzItyaO21N5g0O?= =?us-ascii?Q?UnfDqZ9Dw2N/KWLuLN8S6Ad7LcKah1Ru/bNdK+AatC0VbvqYQsIBJT+q45Lw?= =?us-ascii?Q?gk8eZ4UJDQvC8OWHebgPS5RMZJOZjnUgxpCPfIRnMVqAwRHsRgTkWfBcdMaD?= =?us-ascii?Q?0+kGOR1mNqseF18o2Q9NVpG1jAPXqHBE8+h4zNGtAMTggrJUrSA7VOGikJU3?= =?us-ascii?Q?SDPM25q8G3mOR2InX4ICYb/FvmGdmcs9wWE4/WTpfVTLsqiCsJj0cvc61QfA?= =?us-ascii?Q?3CA7LXmozYlkeR57EHYxArSEjdLmx/2qF9rb3U2BGwlCk15qICLmdr7F2Tzq?= =?us-asc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Tw8cm9gcPoHn6CWNnhuGx0iOq9aarTh2DSiL7ymHqmVjL/OI9Lbyq47Er/EUGg7Q+O8+2hW0tlo4OJW8PwD1DQ6EI7+zY5+z2tfnUXG/42eAc0PlxGPn0/lfy30fqdn2uGBLm6A4xDtbEqDFsTP+VlsZdEREDQOyw64c62qqQJudKjMWcpPOA3V5f/2fQYe SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2016 15:06:24.1124 (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.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR0301MB0596 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-8.3 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);