From patchwork Thu May 19 12:15: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: 9127491 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 B55D5BF29F for ; Thu, 19 May 2016 12:15:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 734572021B for ; Thu, 19 May 2016 12:15:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DBAD720221 for ; Thu, 19 May 2016 12:15:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753942AbcESMPe (ORCPT ); Thu, 19 May 2016 08:15:34 -0400 Received: from mail-bl2on0090.outbound.protection.outlook.com ([65.55.169.90]:27265 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751399AbcESMPd (ORCPT ); Thu, 19 May 2016 08:15:33 -0400 Received: from BN3PR0301CA0005.namprd03.prod.outlook.com (10.160.180.143) by BY2PR0301MB0597.namprd03.prod.outlook.com (10.160.124.28) with Microsoft SMTP Server (TLS) id 15.1.492.11; Thu, 19 May 2016 12:15:31 +0000 Received: from BL2FFO11FD032.protection.gbl (2a01:111:f400:7c09::157) by BN3PR0301CA0005.outlook.office365.com (2a01:111:e400:4000::15) with Microsoft SMTP Server (TLS) id 15.1.501.7 via Frontend Transport; Thu, 19 May 2016 12:15:30 +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 BL2FFO11FD032.mail.protection.outlook.com (10.173.160.73) with Microsoft SMTP Server (TLS) id 15.1.497.8 via Frontend Transport; Thu, 19 May 2016 12:15:30 +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 u4JCFQeI028425; Thu, 19 May 2016 05:15:28 -0700 From: Tudor Ambarus To: CC: , , Tudor Ambarus Subject: [PATCH v6 1/3] crypto: scatterwak - Add scatterwalk_sg_copychunks Date: Thu, 19 May 2016 15:15:16 +0300 Message-ID: <1463660118-19188-2-git-send-email-tudor-dan.ambarus@nxp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1463660118-19188-1-git-send-email-tudor-dan.ambarus@nxp.com> References: <1463660118-19188-1-git-send-email-tudor-dan.ambarus@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131081337303815409; (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)(1110001)(1109001)(339900001)(189002)(199003)(9170700003)(5003940100001)(33646002)(86362001)(105606002)(8676002)(110136002)(11100500001)(189998001)(50226002)(19580405001)(106466001)(19580395003)(4326007)(6806005)(81166006)(1220700001)(2950100001)(5008740100001)(92566002)(77096005)(85426001)(229853001)(50986999)(2351001)(50466002)(47776003)(8936002)(104016004)(2906002)(48376002)(76176999)(586003)(36756003)(87936001)(7059030)(4720700001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB0597; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD032; 1:1CEUL8hkF/CT9pJx01QEFpAJDtkyyouXSctQFoOphq5frk89CuPcqGzZcU3GshOP5CJcekQ4SyS6QBlMCypRmso8qctlhVEAsmaDzAOABW1QuZ9KvWP1rCM04V3mK6EAfoZc2yyZRg7Kmf+R6i1cBwA/JGMSJzQuLuxQtkRYyNk4qA/CrVlRhnLj03fJlC1LLxy5neaH17GJbhHpjDR1MrxOZ44Ue9+BTv/ie6a0KTBNhFWnXsn+yGYLJCrm4x5ILACgq0hT18IhNnb1MCFr5FaxH4Fd2tCVZtdhm4B0FoY60zYzhNcWAcbT+3clWL7LRZfRCmvypXHAXndlUjHvQpuIBP6JGEr6JcmtMefNgcyf2PZHf+EYqqZ8cTghdY1XY3eEUBubx77Ph5JwDsr7m+k7kVDyoioL0KJ/5woZxWUO5rWUZsgatT15/dKhSuHy0F9g3J3XeIQNR+1iOVjPtbqUhx8MPKRDhj9S601ITWCpi7qHjt3EDSm6NlS0Iarb3zKmbXojVaLH1NUh6tmJEl/appUklULqCozWp79adCH5PPFu2fkiiFlbedMWeU+KbKGcnB2VR+OKfJnNpFJZ/HL5E72fZLwBthDf947LU77Bq5HFknUG2Eqbw134MeV2XbITDT2+F+C+PRPv2JJ3l47WbJmJgqKqgyCrqo13guM= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 09465c69-f3e3-422b-f390-08d37fdf4521 X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0597; 2:+fpyJmOgddSATxziEt/g3T+1VvRXR8vXjy98ww4A5Sx2RVFhxiOI3bV2k5+aNwFp9sF6FzVH7d0yinAkijtOjX2GQT63veHmaYx//22FlEKHRPQq4TIBRWsvi4ge5Jwcpr2DQWkVgce2lW38RR6rA3wVEF/Be2bC0z7SEzXcga+wg4zsER3Mk1CFNkSywgB/; 3:F9fTqcFHJgUjQkG0L1Aqkzb+t31ydxAKNHgz0l5oZlIqQ8mKy1TJSoYR4Z1rx7it2m6oSxaD7TJYVnp+FWD2aZTFY8iBnxtLXUreeAOjJ48Imro4ayf5g4WUMIBD1L2BoYN1DSjJsoH8H+OnZ79wrjw/kew/uh3uckfsu6WMx0MQCC7Wwb4ZmsHYOfbxJvRNc2I9kA/NIxmS3RE15qrf+8u8Tjc5JPGtOc6eZjB3jHk=; 25:3NXURpVugx+hxUQXlJiFJBmZslv6EAyNoll3XFqiXIBneLTbXO/ctbVGL25kl6UtPOT4o/2Ez21FKIcUxdkuXDZBK68MHo+tKX6HXFA0gHbqPYaaLAs6Y6GpzsWsVYQzmO5IJs7fAQ0msrI62l8cy/x+05ocplEo7am8/1xFd+zsv1gEaux+dIiyBeEtdMZRPkzE777Fi+0u36Hj/29scG1A8fE1PQoLrkNQr+DEVKyIHmIJ5Cf5Yk2mUoREAYGR54BD7QrtxOGHbm10YXE7zV3mrXmFowYjx6bvxk94SxAN6SVxvbtSFk0aqfHGrmpn8yzupEbJTqhEa2fLFyn35D6Y5gY58bcv4bacr85lNE0nUa/J0KdJNmm2Srw8EotYqiAnXdPoqEZDV/AVB2WrbYI7qS+iHdxjCXjFImH8bRg= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB0597; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13018025)(13015025)(13024025)(13017025)(13023025)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:BY2PR0301MB0597; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR0301MB0597; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0597; 4:mloMd2WyZL7sSY3o2Ni+9kSaOLCWGwjNVNChhEkS5TbwkxPopsP6gkHBXjrDOLhs/R6BcaQGrfd6V/TuGZWHs2fA6vu56z2betX+fBENMcqFI59gjgB0VLqBJlvJf+gcBfqjhkuXRNwaQDlpDGn1vlKY9oydO9ID6ecx+MeCpBA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N7zPUDMYPJXocUVYxfqP7qbAWMb/0f0hPxUVgB2HkV2Kf9VK0CiljvuwOUYj69Ft9z9kj+wOhTMjNkM3at0/p8qwDt2hjV23R31aDH5GoNoGKqlo5mHEB+XasdEuNVf1meZj55N5XdZlbdiAKsMAv2f1ElFkPLfxrJgdOid9AFc9PcS7Mu SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2016 12:15:30.1943 (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: BY2PR0301MB0597 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);