From patchwork Mon Feb 22 09:16:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 8373841 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 8FE07C0553 for ; Mon, 22 Feb 2016 09:31:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 99C802025A for ; Mon, 22 Feb 2016 09:31:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4AD152034B for ; Mon, 22 Feb 2016 09:31:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753976AbcBVJbE (ORCPT ); Mon, 22 Feb 2016 04:31:04 -0500 Received: from mail-bn1on0080.outbound.protection.outlook.com ([157.56.110.80]:37351 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753198AbcBVJa7 (ORCPT ); Mon, 22 Feb 2016 04:30:59 -0500 Received: from BLUPR0301CA0029.namprd03.prod.outlook.com (10.162.113.167) by CY1PR03MB1504.namprd03.prod.outlook.com (10.163.17.22) with Microsoft SMTP Server (TLS) id 15.1.409.15; Mon, 22 Feb 2016 09:16:38 +0000 Received: from BN1BFFO11FD038.protection.gbl (2a01:111:f400:7c10::1:140) by BLUPR0301CA0029.outlook.office365.com (2a01:111:e400:5259::39) with Microsoft SMTP Server (TLS) id 15.1.409.15 via Frontend Transport; Mon, 22 Feb 2016 09:16:38 +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 BN1BFFO11FD038.mail.protection.outlook.com (10.58.144.101) with Microsoft SMTP Server (TLS) id 15.1.422.5 via Frontend Transport; Mon, 22 Feb 2016 09:16:38 +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 u1M9GZXX015987; Mon, 22 Feb 2016 02:16:36 -0700 From: Tudor Ambarus To: CC: , , , , Tudor Ambarus Subject: [PATCH 1/3] crypto: scatterwak - Add scatterwalk_sg_copychunks Date: Mon, 22 Feb 2016 11:16:15 +0200 Message-ID: <1456132577-332-1-git-send-email-tudor-dan.ambarus@nxp.com> X-Mailer: git-send-email 1.8.3.1 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131006061985245295; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD038; 1:KRj8sSgVZ+nvr3ibwz1LUmmPo75cFNRgPab7Cp9+zHE4tuQ06THR+k56VRvURjl3H0vT0jWi59NkDkyOijFtJQZ2fygNaRXX4Wx56TG280VGjSv5O4aCGhJcmFwVxjY79Ijzb0vpuR8HOU7JrDdLD7k+RM16YcPfuj+oIODwzlY02/C5u3k6WCpf4VeytfzzAeK0/Co4XLTkZofHooCwU241igUoLDjqRYwPAEKnj1z6JnX9TkyM5AHGaKPx+ej+u383RHLg1MeVXr/myRVanR9vobOt27AW+O7jQL0ppVrSHpCxJgjzDfs56oQerQ5L/8XGsjcI46HgsmaKctbK35LeqTrwFI6ryIs2aqqj7Sv/HopHkTnVzdgKfGgUh+SnWN/r3sBvUSd0AruJ0Q6QGdbHHhuTcWwQBl7OIzmB0p5qqKCcIpWBPqMtb/CIFo+6jvhdJ1GRgeR+0OPRlASdyIB/ToZd+a3yVbWZr1NJvsTH68PfKakMrJxcvvJzCwCdFkQs5ud9g1KWbD94Ejv56QqeLfjDA3CIVIk1T9/1EhhlWeeX2k8OpzJt+wXmmqA3FUmGI9lKbogbo5XEYag82Q== X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(33646002)(110136002)(85426001)(5001960100002)(50986999)(105606002)(77096005)(86362001)(36756003)(50466002)(229853001)(2351001)(106466001)(50226001)(87936001)(2906002)(4326007)(92566002)(104016004)(5008740100001)(11100500001)(6806005)(586003)(48376002)(1096002)(1220700001)(47776003)(189998001)(19580405001)(19580395003)(7059030)(4720700001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR03MB1504; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 75d2b5c0-cba8-4bc0-a86f-08d33b68de84 X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB1504; 2:3z81jcXueMbDTc1s5R14RYtqi5OyiuZvJ7y7XxR2tPo256StTz+hwCW/fSGawkQEnBHZjE1zqWyEwRrnLbUPunrcdJjJiMd7dyYy/mKlaHEoPD5tFDQpDalBsbXKQ+vA6d+S/ieEBCwh2BXA+o5F+o5ZZPlAutULD5/rgK7djxtnaC0lSXp0Jumq+52et/w9; 3:B15uFpRNtl83y6y2Efs4r4ofHw+DiHReUD/tUZ44Ij04q+KcliMUP5PGx/yR7DxUAecel/Kt+io982YpDpN2WQwHPpffI2P/RKrU2hcccYp1VdvjPXtGL768BNuP78SqOmX3GF//m4QOFAnlQvYsh98uizFUcm+LNohb9DI93p/WL7Dzof4ggNXQHQobifqDjn0FZ10Qdm8SNHIIMVdcHaSx+RSVmL76gdAd4iTLrM0=; 25:KNB/zhhN1mQKIYj5cZMaUXzMxdPtqTek2wSFw4L8o8RIMnLgiT5TxknNb7b6H6r/yI3NNQ4f6lONQ4Oc3/WeVKEPG9/s6CvB2UsTzAHQY0JPjqtZce99XydET3JTywIy/DDVGF0bv3mrMGjcVV07tXMhBGymBel+/uAR59HMsYQzLDStnhdkLYzdde2w8ZVTWUOVjLe37EukaVNn5/68AhRJRT8HvUgb13nSd8R1CyOB1ZoNUBFxV+/rgWACiC2Bdg5gXoKNQDjvO+UyGbsrruJST81Bk1y/WjQsm8UGCw1Jj/W0QPMRPbTVIlUsZXK8VSwJxTjewtUSORPV81hVHQZcVgjDX4catfrYaazFJfk= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1504; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(13015025)(13023025)(13024025)(13017025)(13018025)(5005006)(10201501046)(3002001); SRVR:CY1PR03MB1504; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR03MB1504; X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB1504; 4:yT9OndT3p4PPHMcEDlhob2ZVQQdXV1zMV2n3xA0BlPEX2yB+F5DiID1wk6+9v2r3ustekH5jD56RzrimYBlep8sifddSq/Jkpbr1i2nLNDY2PKZ5vG7YaguDvaW6tWF0J/7cdQz/aIOFJsd9MKnumZTUPe6Lzd7XEBWdFLl/zlE7bOHpNMnCWVo59RNmKpxkk1pQY03f195I/01I+JyfhNCvqH+RvQuxHlqZLSAFjZNyxMHx83UQ8Ltva8CKRKxhciGzMn9IAxy3+6jR8TT39tPooIBN5R/+8+0h8jh7VYrroqD+Aqm6dwG0XPob+JB1KTS4qgavUte3R7x2HxHX1fOAoq1bzXanw+rMXySHpt+obiGiR7EHNZkVhzmmqRg6Scp1cQGxRcJ3WDu0fpxZaqRkPQQigg6A3WtmP88wOHtU4jyq5cUiX/fot29B+3dv+t2TtrUrhMDb6jUivL3plGVSoLpYypm9yfDy8vJIfd0DXFlYXGJQbfrcIQIbPI44 X-Forefront-PRVS: 0860FE717F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR03MB1504; 23:J9la3itqUqdwfTOsQ2FSmjzQzeOzX64zHj6BgCRlz?= =?us-ascii?Q?PpVuin6qmC2HQtWAVvgZi76gKR6kLgMqXpvSt26Ja1NUqL8kXwanJ8UB3UUL?= =?us-ascii?Q?XACn0Q5M6MUllcKaTqhIYtnpRifVNTOtlFBeLEKQWvuUkqwiNk6ScRgGw4Yz?= =?us-ascii?Q?zT8ju3bR6LgSOH5LYojeqIOh4V75KFF7QAD4A8V5Nc3GCzFlreCX8NCkuiI7?= =?us-ascii?Q?eOOBddR/Op7arUefNm8J0mVVzcU1u0OnTnO5O0tPYqvtpWBrmJm1TfMKSG7r?= =?us-ascii?Q?OG+Ge+/pzMll/lJEPBE5mk7p3NYieHALDv+pwDaquilgZW5MTn73Fek+CxL1?= =?us-ascii?Q?9pyhp8z//464IiIoIrbpuoXUGV5N907SB9AiDL/k9hSBJBjCZVBQMsE4PVD9?= =?us-ascii?Q?nhJ+2XRwRvMrw1YpKkWOgFPI7YoNSJ1wDgaEwf0e9C/8C3HNyXDaWFUR44ss?= =?us-ascii?Q?Mu6pr1my6ekYfHnPKo5nZHPTWBalZlonaS8kgrTxB80MM632pXkkqldFbJeP?= =?us-ascii?Q?V7bwiCnfzK408oYR55RPYVETQmoASah76LG7Ey5tG2luOezODS4vfk5vzj9k?= =?us-ascii?Q?v+oDJSYul9+btcbPbRXsNR3GsSLV5/IV17C2mczXiOJvFSVmjtFko9JIXmt2?= =?us-ascii?Q?dN8T0Ohfd9+7aZrgCUu5b6AkBeBxuVPPVesKVZn3aGrIDBsC6WHhLtK+IoVU?= =?us-ascii?Q?w28vsX6laQa2cFdrOOZ4R7EIOECy3RdLvLk9sQUq8Usl6ExjB4EwJjCikwqw?= =?us-ascii?Q?CBU+AbqDQw8qKMeVXX7P+RPrzHGKdd7i0KKmDdJSCdzLFG1ou6HejQnFLCHi?= =?us-ascii?Q?+rJJk1FO/uGtAzm6nXg2e9zI7bwbILGMU5kSGd+SAB13twcXaHZCqtrVIBAV?= =?us-ascii?Q?KaKDlpbD35p+gioB1I8EKlZooeaPaotp6ODaErzXLnlGA/FFcymjrhdwBUsY?= =?us-ascii?Q?Oix4JxJlK/c1mZXT0HzuK+xXBoNkUPLTLvTSb1ziZt0wat8N0TCtc1doqP8J?= =?us-ascii?Q?IQN+bxTnb/Vee4sRY/kJ+AHmVjHn9TBBSxeecy6igeoPg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB1504; 5:Ne+Nnr2re9W34BfvfefP16kpbw+3C/rU9ex8CKbGKtUlv3AfPFnsqXuHE3BmjcAYapxJ63/ggvDrkWfqViXvHUZREQoU0vBXxqomIYc/RKbZdQfVimfsnSPU50pp3XVpCSfLfYlpq2OKIsHvyUEM7HKiUtDOCIfaNoSNmHPLSnM=; 24:afPeFGq7es+NSrK8SzZE999EAKDS4d8vImDwKiJGkepEALJzAJjtu6nhLWuqslMfa/tqDRz1/Khqf+5uKzdp16qbr2R9BHfjB7jlF060wDI= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2016 09:16:38.3529 (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: CY1PR03MB1504 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.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);