From patchwork Tue Jun 7 14:24:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 9161539 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 12E8660467 for ; Tue, 7 Jun 2016 14:24:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03DC525404 for ; Tue, 7 Jun 2016 14:24:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECED12793B; Tue, 7 Jun 2016 14:24:57 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 D36EC25404 for ; Tue, 7 Jun 2016 14:24:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754747AbcFGOY4 (ORCPT ); Tue, 7 Jun 2016 10:24:56 -0400 Received: from mail-by2on0084.outbound.protection.outlook.com ([207.46.100.84]:62880 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755158AbcFGOYy (ORCPT ); Tue, 7 Jun 2016 10:24:54 -0400 Received: from DM2PR03CA0022.namprd03.prod.outlook.com (10.141.96.21) by SN2PR03MB2383.namprd03.prod.outlook.com (10.166.210.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.511.8; Tue, 7 Jun 2016 14:24:53 +0000 Received: from BL2FFO11FD016.protection.gbl (2a01:111:f400:7c09::174) by DM2PR03CA0022.outlook.office365.com (2a01:111:e400:2428::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.511.8 via Frontend Transport; Tue, 7 Jun 2016 14:24:52 +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; nxp.com; dkim=none (message not signed) header.d=none; 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 BL2FFO11FD016.mail.protection.outlook.com (10.173.160.224) with Microsoft SMTP Server (TLS) id 15.1.497.8 via Frontend Transport; Tue, 7 Jun 2016 14:24:52 +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 u57EOmel003691; Tue, 7 Jun 2016 07:24:50 -0700 From: Tudor Ambarus To: CC: , , Tudor Ambarus Subject: [PATCH 1/3] crypto: scatterwak - Add scatterwalk_sg_copychunks Date: Tue, 7 Jun 2016 17:24:41 +0300 Message-ID: <1465309483-2703-2-git-send-email-tudor-dan.ambarus@nxp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1465309483-2703-1-git-send-email-tudor-dan.ambarus@nxp.com> References: <1465309483-2703-1-git-send-email-tudor-dan.ambarus@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131097830925272055; (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)(199003)(189002)(8666004)(81156014)(106466001)(85426001)(87936001)(81166006)(77096005)(33646002)(68736007)(5003940100001)(4326007)(5008740100001)(19580405001)(48376002)(586003)(105606002)(86362001)(69596002)(36756003)(19580395003)(50466002)(92566002)(2906002)(50226002)(8676002)(2351001)(6806005)(97736004)(8936002)(76176999)(110136002)(189998001)(104016004)(50986999)(11100500001)(229853001)(2950100001)(47776003)(7059030)(4720700001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR03MB2383; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD016; 1:diWZaG8xUk1H5ewNfvSfL9+zt8/5drudd3BOXZV7aYSfFQza6t1xi5piPUK7Ia1ZjcUDLpSduPgzgVEnRjLlEMz9OUbOYwy/ZrNIs/QJ6BdbDpYGoE+iXzAdQScWuVXfsBL2sBAYDCrsVoKMJZ/4HVWrsctizHmf0hcFKIHRfI4m1OPWWqC66Vab3hGa95+XVaKCsx/YM6k4yvFl5f38KkoM7FXPYWxyBq6mXBO1opQwMMragSUyQicQW+O1CJWz9mqpSk/K6STedKHcD4OX85PI8EWoPNA7XTQl0gESmdymQae27SXsl6viE6WLVU9Dk9E6i/7iNCmCOhGCTyIChyNsH81SAqTkGJdBO+f9jgoRqGQQjw+TM8ZSn6goDUIMjW3oGraKGTSxRB90p3EU8VpLuuMhyNQIsLULTd/IbV73AmjN39tLhupB5iB2slUj8S4fx0ZDk6uMxcIvolshdzieGzxTEa47u0AvSfDCWCOnUgqhoYS4yWR/RiJQRR09KmsRzNGrhBCi7zPAvChVAYND1kCXfk50bMwsHwklScr0jEX63uC7L1VrSVn0IFOAUWkvw9WbtxeW1re/GwqSZjwh3iLMXRpgWGZh1l2aKUxBhw11vorpt8ceVihagDJ4Ecr6dU0dWd/hBMXOyNJHKqBNsMQHQi950CxUWTuEchBVnba8Wh0VWQIjBfR0X9jl MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: f36b3a02-87a1-4951-03f7-08d38edf7d97 X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2383; 2:C+zQtpSj+uoNhFzTHukpQ+FvCybJDIO0VF0ESh4CC8W4MpMEbDRQD3Fdr9MT74xhf4Dpy6tRTDmW8fNVenXLkrlOd9yFImbZZUn0z3T2+zimpeA2xiZXmS1KTl4kOwXDVQ964+T4cFBgDBButU7hSsRNYAfMMHoZbVpcpXF6dvCm2xl6+yUTPbiwn1FAyXTr; 3:JHvj1o7awom2XONesx0lPE+weg4/B5OZV27e8W30hbA/vHJYsRdMFyD9U6mlS51ZPr1MwvznmBPAmIYNxHNPKgc6U0DRz6fbKZoCjMs3pJUYkO9iGol2mcism8ZtI7o9IRxtgBLGvCUaslfRSIndMLJR1g5fM00LWDoQ/mBekpFMAbwXfCpaIdtSLMCRtsd2cy+iF6SN6Dg/6vqD5OzZ/P30UE8KYHKq5N1+o9aKfLY= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN2PR03MB2383; X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2383; 25:E8gIq1bIfy5sW3g1quScu94LV5Qe5EV4J2YOaTWl0+q0tlgDoJOsQrfpcn0t/YeoiD5xqqo2meMPxi2vMk0qQOI6MIOkBD/+uQ4yNI1zQtutSiEjRL0H2HNjV2yRT43Be6tU5MmbxzRS3OaKL1gGB0n+buo2NF57BbKy7xiZ4hqD/KsZbTctuNAEo7NmpA/zFtcPI4l6N8zfTCJ2xVvglXb5XMJTBz6WZfu+Y7L9rswLIWG+rahFOEzYaW6wEF4VcwGEYFbeUUrQuL6RyXkxGi+mA6AETtY+voijgD2DKWomBB1PKq1Y3c8IATUEr2xYbXyaarj8d1tfeTE9eynDpllPDoE6lThImyVQSf+02IifkGFvsLSzFBCymUpEN1FXd9F063dQ8U5AbYlj56nrcXujSjY0kgqSEEb9qxaXw3uCnQwqaLaH6Q6hyFGrGWTsFsZz2b9ulmDDidn1XXXJgSl/H3BS0wYn1AmwCFZkRG+VH8xZj9+mo37OFaz8LWlhJ3Aezl6F0hcN1AAr/9+PADZQwlY5ZbKar2WU+8AwFFCl0P6eV9bkSjOYBkBfkXOsgdoLFPhaYonKVhtRgQpHO+E/+h15GbGFESFFizDzE/UBukZYPBr3Lqjwtg1e1ybZUti8W6yKSP9Tl/UI3RUPDbbhyY2HV0Dd07rSyRkFNHOF5eJ08CEJ5KlvpNc5q7jFwCQYKGkONRmUVYjMLm0U/w== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13015025)(13024025)(13023025)(13018025)(8121501046)(13017025)(5005006)(10201501046)(3002001)(6055026); SRVR:SN2PR03MB2383; BCL:0; PCL:0; RULEID:(400006); SRVR:SN2PR03MB2383; X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2383; 4:kBxvqD5JMVlIvWG7c4u2feAWQCeVVCrEya1H7fUUppYSSauLJHzbimZ+wxoBGrLs+JXRK28zxAdktKuKNBR0Lez2ArFFgaol+0OMmKFi0gNgyvFJNDYDK8wJda4+mFP+uWEWPpvQpxpjh0kpzmWprnjUuQgqGuznIkV8n6pDxbSEUNJLDtGUJCU0Qns4eUHY0NPtB0mQucHFQxbWD4vemQFMu9vDdcw9+f3FRPZs1fWhJ2SyxWvrXVMPKYeSUpxW6bQCYLok5HtWYL+L2610JhKPyENuMa5307xtx1BXki56AZgIt5h3A1FvTwidmkwZNy3sC3npgjJXuo6acxxf9rAAZluo3MpXr3TxHt+siOW74GP+jFNrkXlyfF71juxzrvpIOillUyu2HBaQiDowjxWchEdSIiXF7fQrQsTkSmdZ/CJrsqeyuXuvba9+5CdlddQK54F3wrvwP279xhFHfV3rGQlCwbUEjm9ToUUckGVngknB3C1Dx7KAUdMN+3/2k+Y8voZJciSimshUGEGTAg== X-Forefront-PRVS: 09669DB681 X-Microsoft-Ex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If5q1tuj7MSf3rzUkHStjT+gGq5RfmRkEDGKMpux4p/oV?= =?us-ascii?Q?D7TNS12VIH02o9pBn4B/Rku1GqwsH/g4eWSNPKk1zYrrs3dgFWd4IPEz/zsc?= =?us-ascii?Q?4BdChu5lUR8tfM6fIXxQT2Zy4Niwe0EUN1o0n6d+vg/GcrCE4P85zX5Y4ocz?= =?us-ascii?Q?uCs1lZskZ9bIOx2PGKDwHfoPUKKnNMsa1wR742BkUBzZJULwfGBqdB9eEfPQ?= =?us-ascii?Q?2WUty5utZ/OR1GCCT1Z2vRv5x5JaiEktvDLb8DvBXCAVDBY2eJP1r0QVbPFC?= =?us-ascii?Q?cj/YfCMkMXuropOQK5dg7SWZHsGP3DIV9C92v+i9F05MfKAYXsSRqGxqqsYK?= =?us-ascii?Q?a/xEF4JRCjkDPg=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2383; 5:KwofzIsw6GjqLpKIaFcoksKxtVfAmKhRXd9iqcVUzf8ktzkGrCasXjeWTbPWkDJhMEB/aig2pO3PlImPreR1m8t6vS23z6JRoAu3SPWf08Ca9V7DyBeLT1Rd3o6wlwa5nGvIY3B0COaOtI5stABQp70cuc9N8ScFGZL9L0960ic=; 24:PUeIWGqeaqkKg1iN+h+YiARzZZg1vyylWq5pSes+WFyoCGeIqj/g9yj/kS4RN2k/hIiVj3Avu3r/wsF5xNnszxwhuNxmWGb2KQZAjNP4EnQ=; 7:oRELElpt5OCND9Ib4SFxk8ULTX4sPRXCb+vGT4kygrwJOW/7zqVA+DtoK9jxJ6hSIphtFCYjA/xkvTvm7GM80Ean1IUHMeXHayQS7/eO4hFr1b4NL/d7xFFcKdVdDKGojs0n7eRhWMZl/B2u2zpWEhlPU53NcEt6dzRj0gfgWcd5aeztfyzsA0qljf7YAs33Bn5nQP8puMNoE9/D0H2fIeRva9PEPQBHAjo3egy7fxg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2016 14:24:52.3088 (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: SN2PR03MB2383 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 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);