From patchwork Wed Apr 6 13:37:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 8762371 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 CD9769F39A for ; Wed, 6 Apr 2016 13:38:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D44EC20142 for ; Wed, 6 Apr 2016 13:38:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AFCB220212 for ; Wed, 6 Apr 2016 13:38:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751076AbcDFNiL (ORCPT ); Wed, 6 Apr 2016 09:38:11 -0400 Received: from mail-bl2on0095.outbound.protection.outlook.com ([65.55.169.95]:1953 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751648AbcDFNiI (ORCPT ); Wed, 6 Apr 2016 09:38:08 -0400 Received: from BLUPR0301CA0029.namprd03.prod.outlook.com (10.162.113.167) by DM2PR0301MB0720.namprd03.prod.outlook.com (10.160.97.140) with Microsoft SMTP Server (TLS) id 15.1.447.15; Wed, 6 Apr 2016 13:38:05 +0000 Received: from BY2FFO11FD003.protection.gbl (2a01:111:f400:7c0c::121) by BLUPR0301CA0029.outlook.office365.com (2a01:111:e400:5259::39) with Microsoft SMTP Server (TLS) id 15.1.453.26 via Frontend Transport; Wed, 6 Apr 2016 13:38:04 +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 BY2FFO11FD003.mail.protection.outlook.com (10.1.14.125) with Microsoft SMTP Server (TLS) id 15.1.453.6 via Frontend Transport; Wed, 6 Apr 2016 13:38:04 +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 u36Dbx2w025617; Wed, 6 Apr 2016 06:38:02 -0700 From: Tudor Ambarus To: CC: , , , , Tudor Ambarus Subject: [PATCH v3 1/3] crypto: scatterwak - Add scatterwalk_sg_copychunks Date: Wed, 6 Apr 2016 16:37:54 +0300 Message-ID: <1459949876-11989-2-git-send-email-tudor-dan.ambarus@nxp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1459949876-11989-1-git-send-email-tudor-dan.ambarus@nxp.com> References: <1459949876-11989-1-git-send-email-tudor-dan.ambarus@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131044234843440052; (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)(50226001)(6806005)(11100500001)(85426001)(5008740100001)(106466001)(77096005)(105606002)(86362001)(189998001)(104016004)(48376002)(81166005)(33646002)(229853001)(36756003)(2351001)(87936001)(50466002)(19580395003)(5003940100001)(110136002)(50986999)(2950100001)(2906002)(76176999)(1096002)(47776003)(19580405001)(1220700001)(586003)(4326007)(92566002)(7059030)(4720700001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0301MB0720; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD003; 1:n3pbbJYdMSLhoLB7ppLDbc68fdnIIodp63jCT0LQet66WZvacGXsqL3zOp5CcO/kAdgBE3FtLXJyQKy9n8ZQcbp/lzGPHitXPjSN/8nQb0beDsCYMZ7ryBCv4hwj4z1huS5O1kV6OfaMy7HscR8vx9rUmFS6TJHYUSGcGfzfVBqzM+D3A35ccaLd794I5Q0iHbNZryAqyHUiufYCFtcX1jZEGKJotn0b/hPLyrtg7Gxr8PgmgI+M5PFhywQngiw07hASK0DfAJPUSViRMxRA8WV6D2KfB5m7VrUwbZbv2DMcIwZdRhBc3SrQ1kLV/ds2Xr46WPjPrAMMuNgFo+IbUGdtCd1fxJgIjjiPA3Tf8O1oIla8gM5i4Zxh+Q9pyxW9HA2q/lqljZMz3vanjK4U1XecmSgUIFo6F0lWUoK1NGmexEx9nLi7fFXekY1QP5Ed8nVncvBGyzhus67Z5C9WkvC3fYqWk3MGb8mBkxtmRyrNH6so2cSNOE/U3YQWbrNIxuvG2STQiCZa641+UOiwz3sIAdK23U/TE8N0aR6dFAY6tvnPn2GF6litw/axpyBBOGWOUIVeFXRpaijUShx4Z/TO0Uxxkb5GLJtOuM+dZtPwEFzJDYxc+9qW5FnJfgjqHZ1cQQb+HfFMajwywFRyt5ScMRgGga5E187/qP1G1MsgzTTdcHjvnJ6sccEqw0BF MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 7852cad4-9120-41d4-7b6e-08d35e20ae1d X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0720; 2:ushiWxqHVuODVG3iaiaYvWrwKc+FCNKrEE4kItbf85RPbvCMQlDPOXVB0d3c7tuHv0+CBhrvln+WeRBdTrbdx6Zqb46j7uD+WT/+V/7sXPuhz7sA1rIeyya0UW6DHATxzxiiQn7hhgRuW1GTqbAOC7jKJ5V6wLjGjqcDU1BWBw+TntropIa+92YhoLbP3Cip; 3:Q6rsdaRhtjb8ZI+Jr2NF3M/ru23CuQznnotwleYjcThG4737CLVGSoNUHKnnXCrRZpTDhZ1tP4qoz9ZAkH8MMthmjAgOg/WqDU8/ZTL4hZk/L1NNy/YUzFSoegvzgBcFB6FZDsJJnA7TDAPBKZGAA8oqTi8if5fo7FS7XDx8ZKcF/nzcBIuni/qIt7iSZGuhRN9yeAibzSpcetXDspyO1zuwY5lk+I/KstMnOdYguY0=; 25:ctMgDntE1MmJ6+fg4S9XSu7QkjRhAnywkJocJVDyyboWdP93G+6Ha5x1JAvmbG+nmiUqne0xULAxm90SeMcWjY10UxrvdpC/WRhf67NZIB8gEvJcm/H+JnqcJMyHoI/q2LNRwRfGSNi8C4N4armNQI1R9yPBXyt6lbDEX9Ama3vDv5MiBADk87buRS77nyPPkWrCN+FAoJ/pDksoU+OyPxNC77MWk+NvJfPxt9U9kT4Ltd1ie04cSkFwyUyCc/AAOy1KkB+CBfSLQ6CLIiVqJayEk2qwztdR2d2gaoDSt21WbS6Z6YKmoqBk9dpo1P+5lQqaRhwqOjeRkEcAK0Zi9w== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0720; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13024025)(8121501046)(13017025)(13018025)(13023025)(13015025)(5005006)(3002001)(10201501046)(6055026); SRVR:DM2PR0301MB0720; BCL:0; PCL:0; RULEID:(400006); SRVR:DM2PR0301MB0720; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0720; 4:gfPF9ElhDXsbrI2W5xnGyACDgBBKIqM1c0tBYovOE7f8s2wBkEQyC7D5uP967UTwpnTVs2klQXnNpBubMCPSkQ4cpLlm/ca4gA3Y43iIKnnO65Rw7jUxYOLnU4IObFgBZSWbCnj1xPFNhYP/l7g/GfT3L0gujyuRdydARIraG/Q/JQVpTjYINEtsjA+hxNPxuIIRUHSgop60ncx5F8XCG5f4I4Aq/NU48729YB9Wv+eTZz6byfvTp/rrprki/E8oa8Qekfc0CGuC9KpAsj57EmxhLN9+Q+57KSWnwj/FXa5Ii8zoAlvAfgv68Il7X0LF4YwV8+Uhb26K34VjSM+dT4Q5a5JC8SdBN1i2BHQxloFTSyvmhphCSn248MRZD0ugXt0KAA2K8iVX6nQAcJgBzA+icnPJ+J9CrLMuKUEFphK1E2fLdSu8mNpwusYJOQ4M9GUtWmjaibNRxkZwNykrdOgH5RyImTzx2FzRDttRTa0= X-Forefront-PRVS: 0904004ECB X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR0301MB0720; 23:SY66ZAeZYcfT4YrHPgppbifHp3SWhV1kThbRYsX?= =?us-ascii?Q?S3YBkdLWMK3jlDE+6GkZS3LK8BRlEu5Yef0xh4tmSR7Of1EZIHh8telJmBoz?= =?us-ascii?Q?L/5WSyQ9OVW8//0bGuQwSbOYIdbTkx78UPpxiWyTpdkTjPx1AZNMKSKUGBfL?= =?us-ascii?Q?RtJSDguAVZz0Uy7hOdhhsZIgU/wp1Qv0fZrZhe+E4ucQ4prq8odGrjhmcdru?= =?us-ascii?Q?fpH3Yyul3noPm0yTBZhDBDIsAG1wBjRasF+S1mDga0RwwqwjtnwpuK6VIlmZ?= =?us-ascii?Q?F56bE5PNvp2rw/rL+zz3g3UraFXJOlxdNj++oua6yWwdwi6eo0gFIyK/ZzOK?= =?us-ascii?Q?g26BNbhMuLYSWCjlg+XkRnpabL0JPXW7iC+B3KaF+qOG0FirO5fPZbmHFWNS?= =?us-ascii?Q?Kkh6SrDvB5JdIQJTOocpZKxu7IGxapChHZpQ1sZHAnhZod1sgWyzhKlwnwTI?= =?us-ascii?Q?wvu7XPz72hutnsbjV9jV4RWsCptHhhTffMjGlcambkAll06iZuWF87Ks1Dzo?= =?us-ascii?Q?7rNogqIamLEgAd8NrqrkjbBm5wbZmrCdV6O3NCENG4EvMutVuP0lCeXN4SGZ?= =?us-ascii?Q?ezbd7mZnkUnIvsIcYeDqGALVMIdD3xtiq4Pn/pubvR0XXV5jCYETsbtl2NgJ?= =?us-ascii?Q?PTVyEjgLvVGVHRZyoWTDntW4iJ4tfDL03NrALAHgJKsk0PpBZTDpiD+emaCH?= =?us-ascii?Q?qPNPaqAjVKI8kqVbEHuOSqLPw3kvn7qVSzZAamETdR3qpKGjnT/SU84nEaeS?= =?us-ascii?Q?ov3u2VcOw+ieK3kMCeHem7QJreQINhV6d+Pu8Z7rxMZzW+tlsitqROEy/M3d?= =?us-ascii?Q?hv1ovxV7d/ZP2EK2yL78MB4rghXgwEzocDH0RtX/7WU4J4V1cT4uFyCj1uOL?= =?us-ascii?Q?r2uloYfi4OMlwN5qUkaA6w6d1CLbBNH4A5slv32rZn7hcNC1TxP4wsfyrFAQ?= =?us-ascii?Q?dt0j6gcmG5vnKTUXKZ5hTlpfYtCxwHXDCcElihUX+bd6fPFuIfSI7PTMfy0D?= =?us-ascii?Q?y/EAf/6EUI1SzKqljeMcBnwPyaoCslNGejkj56ts+GKgUK0VRAkbN3rot+3R?= =?us-ascii?Q?yKPZz05JiV6b7FDQixeY7VbIYfspsPoPChXxtOHLJAOlKQp6xqw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0720; 5:mguFdUQOKRu2gSQtXbTUZaHTyWUg/UBa0v9j4gYtBVxB9O11ulynJjZjrrQmZp/o4+/Z5MhqjdEWREP23CC7680lRY0NuN9eAGhXNLZWx+DMQQE4EIkVv7ntmfz2IAuIDl4fB1Y6qEaKRwdAI4/ZXlT8U792weao7LodNzYqhhQ=; 24:lg2ot2JB/OQ15tAAwjGIqz0qIhlzOeTp1YIAu4/8DdXjN01p8yZOGFNLixEQMV2W1etKojX9kv2oHMqtsIYb3svk6HjlCcckhbzfptq5Xg0= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2016 13:38:04.0476 (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: DM2PR0301MB0720 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 of RSA's algorithm output. 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);